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')
75 ext = os.path.splitext(file)[1]
77 title=title.replace(".ts","")
78 dbs=rec10d.rec10db.select_by_name_time_timeline(title,tbtime,tbtime2)
80 proc=check_process(dir, title)
81 chtxtt=rec10d.rec10db.select_chtxt_by_title_timeline_log(title)
86 """chtxtt=rec10d.rec10db.select_chtxt_by_title_timeline_log(title)
90 add.append([recdblist.REC_AUTO_SUGGEST_DECODE,title,nchtxt])
92 add.append([recdblist.REC_AUTO_SUGGEST_ENCODE,title,nchtxt])
94 add.append([recdblist.REC_AUTO_SUGGEST_AVI2FP,title,nchtxt])
96 # add.append([recdblist.REC_AUTO_SUGGEST_AP2FP,title,nchtxt])
99 rec10d.rec10db.new_auto_proc()
101 rec10d.rec10db.add_auto_proc(a[0],a[1],a[2])
104 処理がどの段階まで言ったのかを調査し返す。
116 def check_process(path,title):
117 path1 = os.path.join(path,title+".mkv")
118 if os.path.exists(path1):
119 if int(time.time()-os.path.getmtime(path1))>300:
123 elif os.path.exists(os.path.join(path,title+".mp4")):
124 if int(time.time()-os.path.getmtime(os.path.join(path,title+".mp4")))>300:
128 elif os.path.exists(os.path.join(path,title+".264")):
129 if int(time.time()-os.path.getmtime(os.path.join(path,title+".264")))>300:
133 elif os.path.exists(os.path.join(path,title+".ts.log")):
134 if int(time.time()-os.path.getmtime(os.path.join(path,title+".ts")))<300:
138 elif os.path.exists(os.path.join(path,title+".ts")):
139 if int(time.time()-os.path.getmtime(os.path.join(path,title+".ts")))>300:
143 elif os.path.exists(os.path.join(path,title+".sa.avi")):
144 if int(time.time()-os.path.getmtime(os.path.join(path,title+".sa.avi")))>300:
148 elif os.path.exists(os.path.join(path,title+".ts.b25")):
149 if int(time.time()-os.path.getmtime(os.path.join(path,title+".ts.b25")))>300:
153 def update_timeline_epg(btime,etime):
154 update_timeline_epg_schedule(btime,etime)
155 update_timeline_dup(btime,etime)
157 def update_timeline_epg_schedule(btime,etime):
158 dbl=rec10d.rec10db.select_bytime_all_timeline(btime, etime)
162 #[chtxtt, title, btime, etime,exp,longexp,category]
163 if db['type']==recdblist.REC_KEYWORD or db['type']==recdblist.REC_KEYWORD_EVERY_SOME_DAYS:
164 ret=epgdb.searchtime2(db['title'], db['btime'], db['deltatime'], db['chtxt'])
165 rec10d.rec10db.update_epg_timeline(db['type'], db['chtxt'], db['title'], db['btime'], ret[2],ret[3],ret[1])
166 if not (db['btime'] == ret[2] and db['etime']==ret[3]):
167 rec10d.rec10db.update_status_change_timeline(db['type'], db['chtxt'], db['title'], db['btime'], "1")
168 elif db['type']==recdblist.REC_RESERVE or db['type']==recdblist.REC_FINAL_RESERVE :
169 ret=epgdb.searchtime2(db['title'], db['btime'],"5", db['chtxt'])
170 rec10d.rec10db.update_epg_timeline(db['type'], db['chtxt'], db['title'], db['btime'], ret[2],ret[3],ret[1])
171 if not (db['btime'] == ret[2] and db['etime']==ret[3]):
172 rec10d.rec10db.update_status_change_timeline(db['type'], db['chtxt'], db['title'], db['btime'], "1")
173 def update_timeline_dup(epgbtime,epgetime):
174 dbl=rec10d.rec10db.select_byepgtime_all_timeline(epgbtime, epgetime)
177 if db['type']==recdblist.REC_KEYWORD or db['type']==recdblist.REC_KEYWORD_EVERY_SOME_DAYS:
178 dbn=epgdb.count_epgschedule(db['epgbtime'], db['epgetime'])
179 bctypet=chdb.chtxtsearch(db['chtxt'])['bctype']
180 if bctypet.find("cs") > -1 or bctypet.find("bs") > -1 :
181 if dbn[1]>status.getRecordingMax()[1]:
182 rec10d.rec10db.update_status_dup_timeline(db['type'], db['chtxt'], db['title'], db['btime'], "1")
184 rec10d.rec10db.update_status_dup_timeline(db['type'], db['chtxt'], db['title'], db['btime'], "0")
186 if dbn[0]>status.getRecordingMax()[0]:
187 rec10d.rec10db.update_status_dup_timeline(db['type'], db['chtxt'], db['title'], db['btime'], "1")
189 rec10d.rec10db.update_status_dup_timeline(db['type'], db['chtxt'], db['title'], db['btime'], "0")