3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009-2010 Yukikaze
27 recpath = configreader.getpath('recpath')
28 movepath = configreader.getpath('move_destpath')
29 path = str(os.path.dirname(os.path.abspath(__file__))) + "/"
36 if rec10d.rec10db.select_installed_in_status()==0 or rec10d.rec10db.select_version_in_status()<recdblist.version:
40 recdb.delete_old("24")
41 recdb.delete_old_auto_bayes("1")
42 recdb.delete_old_auto_keyword("1")
43 tasks = recdb.getnow("3")
44 inum = recdb.countRecNow_minutes("10")
45 recdblist.printutf8(u"rec10処理開始"+ datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
46 recdblist.printutf8(u"直近録画予約件数:" + str(inum) + u"BS/CS録画中件数:" + str(status.getBSCSRecording()) + u"TE録画中件数:" + str(status.getTERecording()) )
49 dnow=datetime.datetime.now()
55 for k in recdb.get_key():
64 auto_process.auto_check(recpath)
66 auto_process.kill_dead_encode(recpath)
68 update = chdb.update()
77 if bctype.find('te') > -1:
78 recnum = status.getTERecording() + recdb.countRecNow_minutes_TE("10")
79 recdblist.printutf8(u"放送種別:"+bctype + u"||該当チューナー実行中件数:" + str(status.getTERecording()) + u":直近予約件数:" + str(recdb.countRecNow_minutes_TE("10")))
80 recnum = int(configreader.getenv("te_max")) -recnum
82 recnum = status.getBSCSRecording() + recdb.countRecNow_minutes_BSCS("10")
83 recdblist.printutf8(u"放送種別:"+bctype + u"||該当チューナー実行中件数:" + str(status.getBSCSRecording()) + u":直近予約件数:" + str(recdb.countRecNow_minutes_BSCS("10")))
84 recnum = int(configreader.getenv("bscs_max")) -recnum
86 recdblist.printutf8(str(update))
87 rec10d.rec10db.update_status_by_bctype_epg_ch(bctype, "0")
88 epgdb.updatebc(bctype)
89 update = chdb.update()
94 auto_process.update_all_timeline_epg()
101 auto_process.update_all_timeline_epg()
104 typetxt = task["type"]
106 chtxt = task['chtxt']
110 title = task['title']
114 btime = task['btime']
115 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
118 bt = datetime.datetime.strptime("2009-01-01 00:00:00", "%Y-%m-%d %H:%M:%S")
120 etime = task['etime']
121 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
124 et = datetime.datetime.strptime("2009-01-01 00:00:00", "%Y-%m-%d %H:%M:%S")
129 tnow = datetime.datetime.now()
131 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
132 if task["type"] == recdblist.REC_RESERVE:#"res,"+chtxt+","+title+","+btime+","+etime+","+opt
134 if pid != 0:#親プロセスの場合
136 else:#子プロセスの場合 アップデートを行って終了
137 type_reserve(task["type"],chtxt,title,bt,et,opt)
139 elif task["type"] == recdblist.REC_KEYWORD:#"key,"+chtxt+","+keyword+","+btime+","+deltatime+","+opt
140 deltatime = task['deltatime']
142 if pid != 0:#親プロセスの場合
144 else:#子プロセスの場合 アップデートを行って終了
145 type_keyword(task["type"],chtxt,title, bt, et, opt, deltatime)
147 elif task["type"] == recdblist.REC_KEYWORD_EVERY_SOME_DAYS:#"keyevery,"+chtxt+","+keyword+","+btime+","+deltatime+","+opt+","+deltaday
148 deltatime = task['deltatime']
149 deltaday = task['deltaday']
151 keyeverycounter=task['counter']
155 if pid != 0:#親プロセスの場合
157 else:#子プロセスの場合 アップデートを行って終了
158 type_keyword_every_day(task["type"],chtxt, title, bt, et, opt, deltatime, deltaday,keyeverycounter)
160 elif task["type"] == recdblist.REC_FINAL_RESERVE:#"rec,"+chtxt+","+title+","+btime+","+etime+","+opt
162 if pid != 0:#親プロセスの場合
164 else:#子プロセスの場合 アップデートを行って終了
165 type_final(task["type"],chtxt, title, bt, et, opt)
167 elif task["type"] == recdblist.REC_TS_DECODE_QUE:
170 if pid != 0:#親プロセスの場合
172 else:#子プロセスの場合 アップデートを行って終了
174 type_decode_que(task["type"],chtxt, title, bt, et, opt)
176 elif task["type"] == recdblist.REC_ENCODE_QUE:
177 encodenum=encodenum+1
179 if pid != 0:#親プロセスの場合
181 else:#子プロセスの場合 アップデートを行って終了
182 time.sleep(5*encodenum)
183 type_encode_que(task["type"],chtxt, title, bt, et, opt)
185 elif task["type"] == recdblist.REC_AVI_TO_MKV:
193 if configreader.getenv("make_mp4")==1:
197 if re.search("m", opt):
199 if re.search("4", opt):
201 recdb.del_reckey(recdblist.REC_AVI_TO_MKV, title, chtxt, btime)
202 recdb.rec_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
204 tv2mp4.raw2mp4(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mp4"),opt)
206 tv2mkv.raw2mkv(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mkv"),opt)
207 recdb.del_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime)
209 elif task["type"] == recdblist.REC_AVI_TO_MP4:
217 if configreader.getenv("make_mp4")==1:
221 if re.search("m", opt):
223 if re.search("4", opt):
225 recdb.del_reckey(recdblist.REC_AVI_TO_MP4, title, chtxt, btime)
226 recdb.rec_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
228 tv2mp4.ts2mp4(pin, pout, opt)
229 tv2mp4.raw2mp4(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mp4"),opt)
231 tv2mkv.raw2mkv(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mkv"),opt)
232 recdb.del_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime)
234 elif task["type"] == recdblist.REC_MKV_TO_MP4:
240 recdb.del_reckey(recdblist.REC_MKV_TO_MP4, title, chtxt, btime)
241 recdb.rec_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
242 tv2mp4.mkv2mp4(os.path.join(recpath,title+".mkv"),os.path.join(recpath,title+".mp4"))
243 recdb.del_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime)
246 def search_keyword(key):
247 tnow = datetime.datetime.now()
248 nows =tnow.strftime("%Y-%m-%d %H:%M:%S")
250 recdatum = epgdb.searchtime_auto(k,nows, "144")
251 for recdata in recdatum:
257 btt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
258 ett = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
259 btimet = btt.strftime("%Y-%m-%d %H:%M:%S")
260 etimet = ett.strftime("%Y-%m-%d %H:%M:%S")
261 if status.getSettings_auto_jbk()==1:
262 topt=status.getSettings_auto_opt()
266 maxnum=epgdb.count_schedule_timeline(btimet, etimet)[1]
267 maxnum=int(configreader.getenv("bscs_max"))-maxnum
269 maxnum=epgdb.count_schedule_timeline(btimet, etimet)[0]
270 maxnum=int(configreader.getenv("te_max"))-maxnum
272 topt=status.getSettings_auto_opt()
273 recdb.recreserv(titlet,chtxtt, btimet, etimet,topt)
274 except Exception, inst:
275 recdblist.Commonlogex("Error", "search_keyword_auto_jbk(timerec.py)", str(type(inst)),str(inst))
278 recdb.add_auto_keyword(chtxtt, titlet, btimet, etimet)
279 except Exception, inst:
280 recdblist.Commonlogex("Error", "search_keyword(timerec.py)", str(type(inst)),str(inst))
281 def type_reserve(typetxt,chtxt,title,bt,et,opt):
282 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
283 etime = et.strftime("%Y-%m-%d %H:%M:%S")
286 if typetxt==recdblist.REC_RESERVE:
287 typetxtfinal=recdblist.REC_FINAL_RESERVE
288 tnow = datetime.datetime.now()
290 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
291 if (dt < 58 * 60 and dt > 30 * 60):
292 bctypet = chdb.chtxtsearch(chtxt)['bctype']
293 chdatat = rec10d.rec10db.select_by_bctype_epg_ch(bctypet)
294 dt1 = datetime.datetime.strptime(chdatat[0][5], "%Y-%m-%d %H:%M:%S")-datetime.datetime.now()
295 dt1 = dt1.days * 24 * 60 * 60 + dt1.seconds
297 recdata = epgdb.searchtime2(title, btime, "5", chtxt)
305 bt = datetime.datetime.strptime(btimen, "%Y-%m-%d %H:%M:%S")
306 et = datetime.datetime.strptime(etimen, "%Y-%m-%d %H:%M:%S")
307 btimen = bt.strftime("%Y-%m-%d %H:%M:%S")
308 etimen = et.strftime("%Y-%m-%d %H:%M:%S")
311 recdb.del_reckey(typetxtnow, title, chtxt, btime)
312 recdb.rec_reckey(typetxtfinal, titlen, chtxtn, btimen, etimen, opt)
313 recdb.rec_reclog(titlen, chtxtn, btimen, etimen, opt, exp, longexp, category)
314 auto_rec.add_key(chtxt, titlen,exp+" "+longexp)
315 auto_rec.add_key("ALL", titlen,exp+" "+longexp)
316 recdblist.printutf8(u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen)
317 except Exception, inst:
318 recdblist.Commonlogex("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst))
320 recdblist.printutf8(u"追いかけ機能エラー:番組データが見付かりません。")
322 if rec10d.rec10db.select_by_bctype_epg_ch(bctypet)[0][6] != "0":
323 rec10d.rec10db.update_status_by_bctype_epg_ch(bctypet, "3")
325 elif (dt <= 30 * 60 and dt > 20 * 60):
326 recdata = epgdb.searchtime2(title, btime, "5", chtxt)
334 bt = datetime.datetime.strptime(btimen, "%Y-%m-%d %H:%M:%S")
335 et = datetime.datetime.strptime(etimen, "%Y-%m-%d %H:%M:%S")
336 btimen = bt.strftime("%Y-%m-%d %H:%M:%S")
337 etimen = et.strftime("%Y-%m-%d %H:%M:%S")
340 recdb.del_reckey(typetxtnow, title, chtxt, btime)
341 recdb.rec_reckey(typetxtfinal, titlen, chtxtn, btimen, etimen, opt)
342 recdb.rec_reclog(titlen, chtxtn, btimen, etimen, opt, exp, longexp, category)
343 auto_rec.add_key(chtxt, titlen,exp+" "+longexp)
344 auto_rec.add_key("ALL", titlen,exp+" "+longexp)
345 #recdblist.printutf8(u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen)
346 recdblist.Commonlogex(u"通常", "Oikake (timerec.py)",u"追いかけ機能実行中",u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen)
347 except Exception, inst:
348 recdblist.Commonlogex("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst))
351 recdb.del_reckey(typetxtnow, title, chtxt, btime)
352 recdb.rec_reckey(typetxtfinal, title, chtxt, btime, etime, opt)
353 except Exception, inst:
354 recdblist.Commonlogex("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst))
355 def type_final(typetxt,chtxt,title,bt,et,opt):
356 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
357 etime = et.strftime("%Y-%m-%d %H:%M:%S")
361 if typetxt==recdblist.REC_FINAL_RESERVE:
362 typetxting=recdblist.REC_TS_RECORDING
363 typetxtdecque=recdblist.REC_TS_DECODE_QUE
364 tnow = datetime.datetime.now()
366 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
367 if dt < 6 * 60 and dt > 0:
369 recdb.del_reckey(typetxtnow, title, chtxt, btime)
370 testpath=[os.path.join(recpath,title+".ts.b25")]
371 testpath.append(os.path.join(recpath,title+".ts"))
372 testpath.append(os.path.join(recpath,title+".avi"))
373 testpath.append(os.path.join(recpath,title+".mp4"))
374 testpath.append(os.path.join(recpath,title+".log"))
377 if os.path.exists(ti):
379 if re.search("N", opt) or tcheck>0:
382 iff=u"("+configreader.getenv("iff")+u")_"
386 newtitle=newtitle+u"_"+iff+newtime.strftime("%Y-%m-%dT%H-%M-%S")
387 recdb.rec_reckey(typetxting, newtitle, chtxt, btime, etime, opt)
388 recdblist.Commonlogex(u"通常","timerec.py",u"録画開始 "+newtitle+" "+btime+" "+etime)
389 tv2avi.timetv2b25(recpath + "/" + newtitle + ".avi", chtxt, btime, etime, opt)
390 recdb.del_reckey(typetxting, newtitle, chtxt, btime)
391 if not re.search("R", opt):
392 tnow = datetime.datetime.now()
393 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
394 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
396 bt = tnow + datetime.timedelta(seconds=600)
397 et = et + dt + datetime.timedelta(seconds=600)
398 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
399 etime = et.strftime("%Y-%m-%d %H:%M:%S")
400 recdb.rec_reckey(typetxtdecque, newtitle, chtxt, btime, etime, opt)
403 shutil.copy(os.path.join(recpath,title+".ts.b25"), os.path.join(movepath,title+".ts.b25"))
406 recdb.rec_reckey(recdblist.REC_MOVE_END, newtitle, chtxt, btime, etime, opt)
408 def type_keyword(typetxt,chtxt,title,bt,et,opt,deltatime):
409 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
410 etime = et.strftime("%Y-%m-%d %H:%M:%S")
413 if typetxt==recdblist.REC_KEYWORD:
414 typetxtres=recdblist.REC_RESERVE
415 tnow = datetime.datetime.now()
417 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
420 recdata = epgdb.searchtime2(title, btime, deltatime, chtxt)
429 bt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
430 et = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
431 btimet = bt.strftime("%Y-%m-%d %H:%M:%S")
432 etimet = et.strftime("%Y-%m-%d %H:%M:%S")
434 recdb.del_reckey(typetxtnow, title, chtxt, btime)
435 recdb.rec_reckey(typetxtres, titlet, chtxtt, btimet, etimet, opt)
436 recdb.rec_reclog(titlet, chtxtt, btimet, etimet, opt, exp,longexp,category)
437 auto_rec.add_key(chtxt, titlet,exp+" "+longexp)
438 auto_rec.add_key("ALL", titlet,exp+" "+longexp)
439 recdblist.Commonlogex(u"通常","timerec.py",u"key "+title+u" : "+titlet+u" "+btimet+u" "+etimet,"")
440 #except Exception, inst:
441 # recdblist.printutf8("Error happened in REC_KEYWORD DB")
442 # recdblist.printutf8(type(inst))
443 # recdblist.printutf8(inst)
445 recdblist.printutf8("nothing match")
446 def type_keyword_every_day(type,chtxt,title,bt,et,opt,deltatime,deltaday,counter):
447 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
448 etime = et.strftime("%Y-%m-%d %H:%M:%S")
449 tnow = datetime.datetime.now()
451 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
452 dd = datetime.timedelta(days=int(deltaday))
454 recdb.del_reckey(recdblist.REC_KEYWORD_EVERY_SOME_DAYS, title, chtxt, btime)
457 btxt = bt.strftime("%Y-%m-%d %H:%M:%S")
458 etxt = et.strftime("%Y-%m-%d %H:%M:%S")
459 recdb.everyreserv(title, chtxt, btxt, etxt, deltatime, opt, deltaday)
461 recdb.del_reckey(recdblist.REC_KEYWORD_EVERY_SOME_DAYS, title, chtxt, btime)
464 btxt = bt.strftime("%Y-%m-%d %H:%M:%S")
465 etxt = et.strftime("%Y-%m-%d %H:%M:%S")
467 recdb.everyreserv(title, chtxt, btxt, etxt, deltatime, opt, deltaday,counter-1)
469 recdb.everyreserv(title, chtxt, btxt, etxt, deltatime, opt, deltaday,-1)
470 recdata = epgdb.searchtime2(title, btime, deltatime, chtxt)
479 bt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
480 et = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
481 btimet = bt.strftime("%Y-%m-%d %H:%M:%S")
482 etimet = et.strftime("%Y-%m-%d %H:%M:%S")
484 recdb.keyreserv(titlet, chtxtt, btimet, etimet, deltatime, opt)
486 recdb.keyreserv(title, chtxt, btime, etime, deltatime, opt)
487 def type_decode_que(typetxt,chtxt,title,bt,et,opt):
488 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
489 etime = et.strftime("%Y-%m-%d %H:%M:%S")
490 tnow = datetime.datetime.now()
492 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
497 if typetxt== recdblist.REC_TS_DECODE_QUE:
498 typetxting=recdblist.REC_TS_DECODING
499 typetxtmiss=recdblist.REC_MISS_DECODE
500 typetxtencque=recdblist.REC_ENCODE_QUE
501 tnow = datetime.datetime.now()
503 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
505 if status.getB25Decoding() < 2:
506 pin = recpath + "/" + title
507 recdb.del_reckey(typetxtnow, title, chtxt, btime)
508 recdb.rec_reckey(typetxting, title, chtxt, btime, etime, opt)
509 tv2avi.b252ts(pin, chtxt, btime, etime, opt)
510 recdb.del_reckey(typetxting, title, chtxt, btime)
511 if not os.access(recpath + "/" + title + ".ts", os.F_OK):
512 recdb.del_reckey(typetxting, title, chtxt, btime)
513 recdb.rec_reckey(typetxtmiss, title, chtxt, btime, etime, opt)
515 auto_process.deltmpfile(recpath, title, ".ts")
516 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
517 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
519 if not re.search("D", opt):
520 tnow = datetime.datetime.now()
521 bt = tnow + datetime.timedelta(seconds=600)
523 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
524 etime = et.strftime("%Y-%m-%d %H:%M:%S")
525 recdb.rec_reckey(typetxtencque, title, chtxt, btime, etime, opt)
528 shutil.copy(os.path.join(recpath,title+".ts"), os.path.join(movepath,title+".ts"))
530 if os.path.getsize(os.path.join(recpath,title+".ts"))==os.path.getsize(os.path.join(movepath,title+".ts")):
531 os.remove(os.path.join(recpath,title+".ts"))
532 except Exception, inst:
533 errtxt1="move ts error.\n"
534 errtxt2=str(type(inst))+"\n"
535 errtxt2=errtxt2+str(inst)
536 recdblist.Commonlogex("Error", "type_decode_que(timerec.py)", errtxt1,errtxt2)
537 recdb.rec_reckey(recdblist.REC_MOVE_END, title, chtxt, btime, etime, opt)
539 recdb.del_reckey(typetxtnow, title, chtxt, btime)
540 bt = bt + datetime.timedelta(seconds=600)
541 et = et + datetime.timedelta(seconds=600)
542 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
543 etime = et.strftime("%Y-%m-%d %H:%M:%S")
544 recdb.rec_reckey(typetxtnow, title, chtxt, btime, etime, opt)
547 def type_encode_que(typetxt,chtxt,title,bt,et,opt):
548 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
549 etime = et.strftime("%Y-%m-%d %H:%M:%S")
550 tnow = datetime.datetime.now()
552 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
556 if typetxt==recdblist.REC_ENCODE_QUE:
557 typetxting=recdblist.REC_ENCODE_LOCAL
558 typetxtfin=recdblist.REC_FIN_LOCAL
560 if status.getEncoding() < int(configreader.getenv("enc_max")):
561 recdb.del_reckey(typetxtnow, title, chtxt, btime)
562 recdb.rec_reckey(typetxting, title, chtxt, btime, etime, opt)
563 recdblist.printutf8(opt)
564 pin = recpath + "/" + title + ".ts"
565 if re.search("d", opt):
566 pin = recpath + "/" + title + ".m2v"
567 if not os.path.exists(pin) or os.path.getsize(pin)<100*1000:
568 paac2 = recpath + "/" + title + "_2.aac"
569 pmp32 = recpath + "/" + title + "_2.mp3"
570 if not os.path.exists(paac2) and not os.path.exists(pmp32):
571 tv2avi.dualaudio2sep(os.path.join(recpath, title+".ts"),"167")
573 elif re.search("5", opt):
574 pin = recpath + "/" + title + ".m2v"
575 if not os.path.exists(pin) or os.path.getsize(pin)<100*1000:
576 paac2 = recpath + "/" + title + "_2.aac"
577 pmp32 = recpath + "/" + title + "_2.mp3"
578 if not os.path.exists(paac2) and not os.path.exists(pmp32):
579 tv2avi.pentaaudio2sep(os.path.join(recpath, title+".ts"))
581 elif re.search("b", opt):
582 pin = recpath + "/" + title + ".m2v"
583 if not os.path.exists(pin) or os.path.getsize(pin)<100*1000:
584 paac2 = recpath + "/" + title + "_1.aac"
585 pmp32 = recpath + "/" + title + "_1.mp3"
586 if not os.path.exists(paac2) and not os.path.exists(pmp32):
587 tv2avi.singleaudio2sep(os.path.join(recpath, title+".ts"))
591 if configreader.getenv("make_mp4")=="1":
595 if re.search("m", opt):
597 if re.search("4", opt):
599 recdblist.printutf8(pin)
600 if not re.search("0", opt):
602 pout = recpath + "/" + title + ".mp4"
603 tv2mp4.ts2mp4(pin, pout, opt)
605 pout = recpath + "/" + title + ".mkv"
606 tv2mkv.ts2mkv(pin, pout, opt)
607 if re.search("8", opt) or re.search("9", opt):
609 optt=optt.replace("8","MW8")
610 optt=optt.replace("9","MW9")
611 poutt = recpath + "/" + "m_"+title + ".mp4"
612 if re.search("d", opt) or re.search("5", opt):
613 if os.path.exists(os.path.join(recpath, "m_"+title+".m2v")):
614 shutil.move(os.path.join(recpath, title+".m2v"),os.path.join(recpath, "m_"+title+".m2v"))
615 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.aac")):
616 shutil.move(os.path.join(recpath, title+"_1.aac"),os.path.join(recpath, "m_"+title+"_1.aac"))
617 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.mp3")):
618 shutil.move(os.path.join(recpath, title+"_1.mp3"),os.path.join(recpath, "m_"+title+"_1.mp3"))
619 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.aac")):
620 shutil.move(os.path.join(recpath, title+"_2.aac"),os.path.join(recpath, "m_"+title+"_2.aac"))
621 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.mp3")):
622 shutil.move(os.path.join(recpath, title+"_2.mp3"),os.path.join(recpath, "m_"+title+"_2.mp3"))
623 shutil.move(os.path.join(recpath, title+".ts"),os.path.join(recpath, "m_"+title+".ts"))
624 tv2mp4.ts2mp4(os.path.join(recpath, "m_"+title+".ts"), poutt, optt)
625 shutil.move(os.path.join(recpath, "m_"+title+".ts"),os.path.join(recpath, title+".ts"))
628 optt=optt.replace("8","MW8")
629 optt=optt.replace("9","MW9")
630 poutt = recpath + "/" + "m_"+title + ".mp4"
631 shutil.move(os.path.join(recpath, title+".ts"),os.path.join(recpath, "m_"+title+".ts"))
632 if re.search("d", opt) or re.search("5", opt):
633 if os.path.exists(os.path.join(recpath, "m_"+title+".m2v")):
634 shutil.move(os.path.join(recpath, title+".m2v"),os.path.join(recpath, "m_"+title+".m2v"))
635 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.aac")):
636 shutil.move(os.path.join(recpath, title+"_1.aac"),os.path.join(recpath, "m_"+title+"_1.aac"))
637 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.mp3")):
638 shutil.move(os.path.join(recpath, title+"_1.mp3"),os.path.join(recpath, "m_"+title+"_1.mp3"))
639 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.aac")):
640 shutil.move(os.path.join(recpath, title+"_2.aac"),os.path.join(recpath, "m_"+title+"_2.aac"))
641 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.mp3")):
642 shutil.move(os.path.join(recpath, title+"_2.mp3"),os.path.join(recpath, "m_"+title+"_2.mp3"))
643 tv2mp4.ts2mp4(os.path.join(recpath, "m_"+title+".ts"), poutt, optt)
644 shutil.move(os.path.join(recpath, "m_"+title+".ts"),os.path.join(recpath, title+".ts"))
645 recdb.del_reckey(typetxting, title, chtxt, btime)
647 if re.search("E", opt):
649 if os.path.exists(os.path.join(recpath,title+".mp4")):
650 shutil.copy(os.path.join(recpath,title+".mp4"), os.path.join(movepath,title+".mp4"))
651 elif os.path.exists(os.path.join(recpath,title+".mkv")):
652 shutil.copy(os.path.join(recpath,title+".mkv"), os.path.join(movepath,title+".mkv"))
653 except Exception, inst:
654 errtxt1="move mkv/mp4 error."
655 errtxt2=str(type(inst))+"\n"
656 errtxt2=errtxt2+str(inst)
657 recdblist.Commonlogex("Error", "type_encode_que(timerec.py)", errtxt1,errtxt2)
658 recdb.rec_reckey(recdblist.REC_MOVE_END, title, chtxt, btime, etime, opt)
659 recdb.rec_reckey(typetxtfin, title, chtxt, btime, etime, opt)
662 recdb.del_reckey(typetxtnow, title, chtxt, btime)
663 bt = bt + datetime.timedelta(seconds=600)
664 et = et + datetime.timedelta(seconds=600)
665 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
666 etime = et.strftime("%Y-%m-%d %H:%M:%S")
667 recdb.rec_reckey(typetxtnow, title, chtxt, btime, etime, opt)