3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009-2010 Yukikaze
17 def Update_to_MP4(path):
21 avilist = glob.glob(path + "/*.avi")
22 mkvlist = glob.glob(path+"/*.mkv")
23 avilist=avilist+mkvlist
24 #recdblist.printutf8(avilist)
26 if avif.rfind("sa.avi")==-1:
27 ##b25f is title.ts.b25 avi is title.avi
28 dir = os.path.split(avif)[0]
29 title = os.path.split(avif)[1]
30 title = title.replace(".avi", "")
31 title = title.replace(".mkv", "")
32 avipath = os.path.join(dir, title + ".avi")
33 mkvpath = os.path.join(dir, title + ".mkv")
34 mp4path = os.path.join(dir, title + ".mp4")
35 if not os.path.exists(mp4path):
36 if os.path.exists(avipath):
37 avidtime = int(time.time()-os.path.getmtime(avipath))
39 if os.path.exists(mkvpath):
40 mkvdtime = int(time.time()-os.path.getmtime(mkvpath))
42 recdblist.printutf8(mkvpath+":"+mp4path)
43 tv2mp4.mkv2mp4(mkvpath,mp4path)
45 recdblist.printutf8(avipath+":"+mp4path)
46 tv2mp4.avi2mp4(avipath,mp4path)
48 recdblist.printutf8(avipath+":"+mp4path)
49 tv2mp4.avi2mp4(avipath,mp4path)
51 if not os.path.exists(avipath):
52 if os.path.exists(mkvpath):
53 mkvdtime = int(time.time()-os.path.getmtime(mkvpath))
55 recdblist.printutf8(mkvpath+":"+mp4path)
56 tv2mp4.mkv2mp4(mkvpath,mp4path)
58 avilist = glob.glob(path + "/*.avi")
59 mkvlist = glob.glob(path+"/*.mkv")
60 mp4list = glob.glob(path+"/*.mp4")
61 tslist = glob.glob(path+"/*.ts")
62 b25list = glob.glob(path+"/*.ts.b25")
63 filelist=avilist+mkvlist+tslist+b25list+mp4list
65 tbtime=datetime.datetime.now()+datetime.timedelta(seconds=60)
66 tbtime2=datetime.datetime.now()+datetime.timedelta(seconds=1200)
68 if fn.rfind("sa.avi")==-1 and fn.rfind(".120.avi")==-1 and os.path.getsize(fn)>1*1000*1000:
69 dir = os.path.split(fn)[0]
70 file = os.path.split(fn)[1]
71 title = os.path.splitext(file)[0]
72 title = unicode(title,'utf-8')
73 ext = os.path.splitext(file)[1]
75 title=title.replace(".ts","")
76 dbs=rec10d.rec10db.select_by_name_time_timeline(title,tbtime,tbtime2)
78 proc=check_process(dir, title)
79 chtxtt=rec10d.rec10db.select_chtxt_by_title_timeline_log(title)
84 add.append([recdblist.REC_AUTO_SUGGEST_DECODE,title,nchtxt])
86 add.append([recdblist.REC_AUTO_SUGGEST_ENCODE,title,nchtxt])
88 add.append([recdblist.REC_AUTO_SUGGEST_AVI2FP,title,nchtxt])
90 # add.append([recdblist.REC_AUTO_SUGGEST_AP2FP,title,nchtxt])
93 rec10d.rec10db.new_auto_proc()
95 rec10d.rec10db.add_auto_proc(a[0],a[1],a[2])
110 def check_process(path,title):
111 path1 = os.path.join(path,title+".mkv")
112 if os.path.exists(path1):
113 if int(time.time()-os.path.getmtime(path1))>300:
117 elif os.path.exists(os.path.join(path,title+".mp4")):
118 if int(time.time()-os.path.getmtime(os.path.join(path,title+".mp4")))>300:
122 elif os.path.exists(os.path.join(path,title+".264")):
123 if int(time.time()-os.path.getmtime(os.path.join(path,title+".264")))>300:
127 elif os.path.exists(os.path.join(path,title+".ts.log")):
128 if int(time.time()-os.path.getmtime(os.path.join(path,title+".ts")))<300:
132 elif os.path.exists(os.path.join(path,title+".ts")):
133 if int(time.time()-os.path.getmtime(os.path.join(path,title+".ts")))>300:
137 elif os.path.exists(os.path.join(path,title+".sa.avi")):
138 if int(time.time()-os.path.getmtime(os.path.join(path,title+".sa.avi")))>300:
142 elif os.path.exists(os.path.join(path,title+".ts.b25")):
143 if int(time.time()-os.path.getmtime(os.path.join(path,title+".ts.b25")))>300:
147 def update_all_timeline_epg():
148 now=datetime.datetime.now()
149 et=now+datetime.timedelta(days=7)
150 update_timeline_epg(now.strftime("%Y-%m-%d %H:%M:%S"), et.strftime("%Y-%m-%d %H:%M:%S"))
151 def update_timeline_epg(btime,etime):
152 update_timeline_epg_schedule(btime,etime)
153 update_timeline_dup(btime,etime)
154 def update_timeline_epg_schedule(btime,etime):
155 dbl=rec10d.rec10db.select_bytime_all_timeline(btime, etime)
159 #[chtxtt, title, btime, etime,exp,longexp,category]
160 if db['type']==recdblist.REC_KEYWORD or db['type']==recdblist.REC_KEYWORD_EVERY_SOME_DAYS:
161 ret=epgdb.searchtime2(db['title'], db['btime'], db['deltatime'], db['chtxt'])
162 if len(ret)>4 and len(ret[2])>18:
163 rec10d.rec10db.update_epg_timeline(db['type'], db['chtxt'], db['title'], db['btime'], ret[2],ret[3],ret[1])
164 if not (db['btime'] == ret[2] and db['etime']==ret[3]):
165 rec10d.rec10db.update_status_change_timeline(db['type'], db['chtxt'], db['title'], db['btime'], "1")
167 rec10d.rec10db.update_status_change_timeline(db['type'], db['chtxt'], db['title'], db['btime'], "0")
169 rec10d.rec10db.update_status_change_timeline(db['type'], db['chtxt'], db['title'], db['btime'], "1")
170 elif db['type']==recdblist.REC_RESERVE or db['type']==recdblist.REC_FINAL_RESERVE :
171 ret=epgdb.searchtime2(db['title'], db['btime'],"5", db['chtxt'])
172 if len(ret)>4 and len(ret[2])>18:
173 rec10d.rec10db.update_epg_timeline(db['type'], db['chtxt'], db['title'], db['btime'], ret[2],ret[3],ret[1])
174 if not (db['btime'] == ret[2] and db['etime']==ret[3]):
175 rec10d.rec10db.update_status_change_timeline(db['type'], db['chtxt'], db['title'], db['btime'], "1")
177 rec10d.rec10db.update_status_change_timeline(db['type'], db['chtxt'], db['title'], db['btime'], "0")
179 rec10d.rec10db.update_status_change_timeline(db['type'], db['chtxt'], db['title'], db['btime'], "1")
180 def update_timeline_dup(epgbtime,epgetime):
181 dbl=rec10d.rec10db.select_byepgtime_all_timeline(epgbtime, epgetime)
183 if db['type']==recdblist.REC_KEYWORD or db['type']==recdblist.REC_KEYWORD_EVERY_SOME_DAYS:
184 dbn=epgdb.count_epgschedule(db['epgbtime'], db['epgetime'])
185 bctypet=chdb.chtxtsearch(db['chtxt'])['bctype']
186 if bctypet.find("cs") > -1 or bctypet.find("bs") > -1 :
187 if dbn[1]>status.getRecordingMax()[1]:
188 rec10d.rec10db.update_status_dup_timeline(db['type'], db['chtxt'], db['title'], db['btime'], "1")
190 rec10d.rec10db.update_status_dup_timeline(db['type'], db['chtxt'], db['title'], db['btime'], "0")
192 if dbn[0]>status.getRecordingMax()[0]:
193 rec10d.rec10db.update_status_dup_timeline(db['type'], db['chtxt'], db['title'], db['btime'], "1")
195 rec10d.rec10db.update_status_dup_timeline(db['type'], db['chtxt'], db['title'], db['btime'], "0")