3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009-2010 Yukikaze
26 recpath = configreader.getpath('recpath')
27 movepath = configreader.getpath('move_destpath')
28 path = str(os.path.dirname(os.path.abspath(__file__))) + "/"
35 if rec10d.rec10db.select_installed_in_status()==0 or rec10d.rec10db.select_version_in_status()<recdblist.version:
39 recdb.delete_old("24")
40 recdb.delete_old_auto_bayes("1")
41 recdb.delete_old_auto_keyword("1")
42 tasks = recdb.getnow("3")
43 inum = recdb.countRecNow_minutes("10")
44 recdblist.printutf8(u"rec10処理開始"+ datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),verbose_level=800)
45 recdblist.printutf8(u"直近録画予約件数:" + str(inum) + u"BS/CS録画中件数:" + str(status.getBSCSRecording()) + u"TE録画中件数:" + str(status.getTERecording()) ,verbose_level=800)
48 dnow=datetime.datetime.now()
54 for k in recdb.get_key():
63 auto_process.auto_check(recpath)
65 auto_process.kill_dead_encode(recpath)
67 update = chdb.update()
76 if bctype.find('te') > -1:
77 recnum = status.getTERecording() + recdb.countRecNow_minutes_TE("10")
78 recdblist.printutf8(u"放送種別:"+bctype + u"||該当チューナー実行中件数:" + str(status.getTERecording()) + u":直近予約件数:" + str(recdb.countRecNow_minutes_TE("10")),verbose_level=800)
79 recnum = int(configreader.getenv("te_max")) -recnum
81 recnum = status.getBSCSRecording() + recdb.countRecNow_minutes_BSCS("10")
82 recdblist.printutf8(u"放送種別:"+bctype + u"||該当チューナー実行中件数:" + str(status.getBSCSRecording()) + u":直近予約件数:" + str(recdb.countRecNow_minutes_BSCS("10")),verbose_level=800)
83 recnum = int(configreader.getenv("bscs_max")) -recnum
85 recdblist.printutf8(str(update))
86 rec10d.rec10db.update_status_by_bctype_epg_ch(bctype, "0",verbose_level=750)
87 epgdb.updatebc(bctype)
88 update = chdb.update()
93 auto_process.update_all_timeline_epg()
100 auto_process.update_all_timeline_epg()
103 typetxt = task["type"]
105 chtxt = task['chtxt']
109 title = task['title']
113 btime = task['btime']
114 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
117 bt = datetime.datetime.strptime("2009-01-01 00:00:00", "%Y-%m-%d %H:%M:%S")
119 etime = task['etime']
120 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
123 et = datetime.datetime.strptime("2009-01-01 00:00:00", "%Y-%m-%d %H:%M:%S")
128 tnow = datetime.datetime.now()
130 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
131 if task["type"] == recdblist.REC_RESERVE:#"res,"+chtxt+","+title+","+btime+","+etime+","+opt
133 if pid != 0:#親プロセスの場合
135 else:#子プロセスの場合 アップデートを行って終了
136 type_reserve(task["type"],chtxt,title,bt,et,opt)
138 elif task["type"] == recdblist.REC_KEYWORD:#"key,"+chtxt+","+keyword+","+btime+","+deltatime+","+opt
139 deltatime = task['deltatime']
141 if pid != 0:#親プロセスの場合
143 else:#子プロセスの場合 アップデートを行って終了
144 type_keyword(task["type"],chtxt,title, bt, et, opt, deltatime)
146 elif task["type"] == recdblist.REC_KEYWORD_EVERY_SOME_DAYS:#"keyevery,"+chtxt+","+keyword+","+btime+","+deltatime+","+opt+","+deltaday
147 deltatime = task['deltatime']
148 deltaday = task['deltaday']
150 keyeverycounter=task['counter']
154 if pid != 0:#親プロセスの場合
156 else:#子プロセスの場合 アップデートを行って終了
157 type_keyword_every_day(task["type"],chtxt, title, bt, et, opt, deltatime, deltaday,keyeverycounter)
159 elif task["type"] == recdblist.REC_FINAL_RESERVE:#"rec,"+chtxt+","+title+","+btime+","+etime+","+opt
161 if pid != 0:#親プロセスの場合
163 else:#子プロセスの場合 アップデートを行って終了
164 type_final(task["type"],chtxt, title, bt, et, opt)
166 elif task["type"] == recdblist.REC_TS_DECODE_QUE:
169 if pid != 0:#親プロセスの場合
171 else:#子プロセスの場合 アップデートを行って終了
173 type_decode_que(task["type"],chtxt, title, bt, et, opt)
175 elif task["type"] == recdblist.REC_ENCODE_QUE:
176 encodenum=encodenum+1
178 if pid != 0:#親プロセスの場合
180 else:#子プロセスの場合 アップデートを行って終了
181 time.sleep(5*encodenum)
182 type_encode_que(task["type"],chtxt, title, bt, et, opt)
184 elif task["type"] == recdblist.REC_AVI_TO_MKV:
192 if configreader.getenv("make_mp4")==1:
196 if re.search("m", opt):
198 if re.search("4", opt):
200 recdb.del_reckey(recdblist.REC_AVI_TO_MKV, title, chtxt, btime)
201 recdb.rec_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
203 tv2mp4.raw2mp4(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mp4"),opt)
205 tv2mkv.raw2mkv(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mkv"),opt)
206 recdb.del_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime)
208 elif task["type"] == recdblist.REC_AVI_TO_MP4:
216 if configreader.getenv("make_mp4")==1:
220 if re.search("m", opt):
222 if re.search("4", opt):
224 recdb.del_reckey(recdblist.REC_AVI_TO_MP4, title, chtxt, btime)
225 recdb.rec_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
227 tv2mp4.ts2mp4(pin, pout, opt)
228 tv2mp4.raw2mp4(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mp4"),opt)
230 tv2mkv.raw2mkv(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mkv"),opt)
231 recdb.del_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime)
233 elif task["type"] == recdblist.REC_MKV_TO_MP4:
239 recdb.del_reckey(recdblist.REC_MKV_TO_MP4, title, chtxt, btime)
240 recdb.rec_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
241 tv2mp4.mkv2mp4(os.path.join(recpath,title+".mkv"),os.path.join(recpath,title+".mp4"))
242 recdb.del_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime)
245 def search_keyword(key):
246 tnow = datetime.datetime.now()
247 nows =tnow.strftime("%Y-%m-%d %H:%M:%S")
249 recdatum = epgdb.searchtime_auto(k,nows, "144")
250 for recdata in recdatum:
256 btt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
257 ett = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
258 btimet = btt.strftime("%Y-%m-%d %H:%M:%S")
259 etimet = ett.strftime("%Y-%m-%d %H:%M:%S")
260 if status.getSettings_auto_jbk()==1:
261 topt=status.getSettings_auto_opt()
265 maxnum=epgdb.count_schedule_timeline(btimet, etimet)[1]
266 maxnum=int(configreader.getenv("bscs_max"))-maxnum
268 maxnum=epgdb.count_schedule_timeline(btimet, etimet)[0]
269 maxnum=int(configreader.getenv("te_max"))-maxnum
271 topt=status.getSettings_auto_opt()
272 recdb.recreserv(titlet,chtxtt, btimet, etimet,topt)
273 except Exception, inst:
274 recdblist.Commonlogex("Error", "search_keyword_auto_jbk(timerec.py)", str(type(inst)),str(inst),log_level=200)
277 recdb.add_auto_keyword(chtxtt, titlet, btimet, etimet)
278 except Exception, inst:
279 recdblist.Commonlogex("Error", "search_keyword(timerec.py)", str(type(inst)),str(inst),log_level=200)
280 def type_reserve(typetxt,chtxt,title,bt,et,opt):
281 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
282 etime = et.strftime("%Y-%m-%d %H:%M:%S")
285 if typetxt==recdblist.REC_RESERVE:
286 typetxtfinal=recdblist.REC_FINAL_RESERVE
287 tnow = datetime.datetime.now()
289 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
290 if (dt < 58 * 60 and dt > 30 * 60):
291 bctypet = chdb.chtxtsearch(chtxt)['bctype']
292 chdatat = rec10d.rec10db.select_by_bctype_epg_ch(bctypet)
293 dt1 = datetime.datetime.strptime(chdatat[0][5], "%Y-%m-%d %H:%M:%S")-datetime.datetime.now()
294 dt1 = dt1.days * 24 * 60 * 60 + dt1.seconds
296 recdata = epgdb.searchtime2(title, btime, "5", chtxt)
304 bt = datetime.datetime.strptime(btimen, "%Y-%m-%d %H:%M:%S")
305 et = datetime.datetime.strptime(etimen, "%Y-%m-%d %H:%M:%S")
306 btimen = bt.strftime("%Y-%m-%d %H:%M:%S")
307 etimen = et.strftime("%Y-%m-%d %H:%M:%S")
310 recdb.del_reckey(typetxtnow, title, chtxt, btime)
311 recdb.rec_reckey(typetxtfinal, titlen, chtxtn, btimen, etimen, opt)
312 recdb.rec_reclog(titlen, chtxtn, btimen, etimen, opt, exp, longexp, category)
313 auto_rec.add_key(chtxt, titlen,exp+" "+longexp)
314 auto_rec.add_key("ALL", titlen,exp+" "+longexp)
315 recdblist.printutf8(u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen)
316 except Exception, inst:
317 recdblist.Commonlogex("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst),log_level=200)
319 recdblist.printutf8(u"追いかけ機能エラー:番組データが見付かりません。")
321 if rec10d.rec10db.select_by_bctype_epg_ch(bctypet)[0][6] != "0":
322 rec10d.rec10db.update_status_by_bctype_epg_ch(bctypet, "3")
324 elif (dt <= 30 * 60 and dt > 20 * 60):
325 recdata = epgdb.searchtime2(title, btime, "5", chtxt)
333 bt = datetime.datetime.strptime(btimen, "%Y-%m-%d %H:%M:%S")
334 et = datetime.datetime.strptime(etimen, "%Y-%m-%d %H:%M:%S")
335 btimen = bt.strftime("%Y-%m-%d %H:%M:%S")
336 etimen = et.strftime("%Y-%m-%d %H:%M:%S")
339 recdb.del_reckey(typetxtnow, title, chtxt, btime)
340 recdb.rec_reckey(typetxtfinal, titlen, chtxtn, btimen, etimen, opt)
341 recdb.rec_reclog(titlen, chtxtn, btimen, etimen, opt, exp, longexp, category)
342 auto_rec.add_key(chtxt, titlen,exp+" "+longexp)
343 auto_rec.add_key("ALL", titlen,exp+" "+longexp)
344 #recdblist.printutf8(u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen)
345 recdblist.Commonlogex(u"通常", "Oikake (timerec.py)",u"追いかけ機能実行中",u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen,log_level=500)
346 except Exception, inst:
347 recdblist.Commonlogex("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst),log_level=200)
350 recdb.del_reckey(typetxtnow, title, chtxt, btime)
351 recdb.rec_reckey(typetxtfinal, title, chtxt, btime, etime, opt)
352 except Exception, inst:
353 recdblist.Commonlogex("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst),log_level=200)
354 def type_final(typetxt,chtxt,title,bt,et,opt):
355 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
356 etime = et.strftime("%Y-%m-%d %H:%M:%S")
360 if typetxt==recdblist.REC_FINAL_RESERVE:
361 typetxting=recdblist.REC_TS_RECORDING
362 typetxtdecque=recdblist.REC_TS_DECODE_QUE
363 tnow = datetime.datetime.now()
365 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
366 if dt < 6 * 60 and dt > 0:
368 recdb.del_reckey(typetxtnow, title, chtxt, btime)
369 testpath=[os.path.join(recpath,title+".ts.b25")]
370 testpath.append(os.path.join(recpath,title+".ts"))
371 testpath.append(os.path.join(recpath,title+".avi"))
372 testpath.append(os.path.join(recpath,title+".mp4"))
373 testpath.append(os.path.join(recpath,title+".log"))
376 if os.path.exists(ti):
378 if re.search("N", opt) or tcheck>0:
381 iff=u"("+configreader.getenv("iff")+u")_"
385 newtitle=newtitle+u"_"+iff+newtime.strftime("%Y-%m-%dT%H-%M-%S")
386 recdb.rec_reckey(typetxting, newtitle, chtxt, btime, etime, opt)
387 recdblist.Commonlogex(u"通常","timerec.py",u"録画開始 "+newtitle+" "+btime+" "+etime,"",log_level=500)
388 tv2avi.timetv2b25(recpath + "/" + newtitle + ".avi", chtxt, btime, etime, opt)
389 recdb.del_reckey(typetxting, newtitle, chtxt, btime)
390 if not re.search("R", opt):
391 tnow = datetime.datetime.now()
392 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
393 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
395 bt = tnow + datetime.timedelta(seconds=600)
396 et = et + dt + datetime.timedelta(seconds=600)
397 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
398 etime = et.strftime("%Y-%m-%d %H:%M:%S")
399 recdb.rec_reckey(typetxtdecque, newtitle, chtxt, btime, etime, opt)
402 shutil.copy(os.path.join(recpath,title+".ts.b25"), os.path.join(movepath,title+".ts.b25"))
405 recdb.rec_reckey(recdblist.REC_MOVE_END, newtitle, chtxt, btime, etime, opt)
407 def type_keyword(typetxt,chtxt,title,bt,et,opt,deltatime):
408 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
409 etime = et.strftime("%Y-%m-%d %H:%M:%S")
412 if typetxt==recdblist.REC_KEYWORD:
413 typetxtres=recdblist.REC_RESERVE
414 tnow = datetime.datetime.now()
416 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
419 recdata = epgdb.searchtime2(title, btime, deltatime, chtxt)
428 bt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
429 et = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
430 btimet = bt.strftime("%Y-%m-%d %H:%M:%S")
431 etimet = et.strftime("%Y-%m-%d %H:%M:%S")
433 recdb.del_reckey(typetxtnow, title, chtxt, btime)
434 recdb.rec_reckey(typetxtres, titlet, chtxtt, btimet, etimet, opt)
435 recdb.rec_reclog(titlet, chtxtt, btimet, etimet, opt, exp,longexp,category)
436 auto_rec.add_key(chtxt, titlet,exp+" "+longexp)
437 auto_rec.add_key("ALL", titlet,exp+" "+longexp)
438 recdblist.Commonlogex(u"通常","timerec.py",u"key "+title+u" : "+titlet+u" "+btimet+u" "+etimet,"",log_level=500)
439 #except Exception, inst:
440 # recdblist.printutf8("Error happened in REC_KEYWORD DB")
441 # recdblist.printutf8(type(inst))
442 # recdblist.printutf8(inst)
444 recdblist.printutf8("nothing match")
445 def type_keyword_every_day(type,chtxt,title,bt,et,opt,deltatime,deltaday,counter):
446 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
447 etime = et.strftime("%Y-%m-%d %H:%M:%S")
448 tnow = datetime.datetime.now()
450 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
451 dd = datetime.timedelta(days=int(deltaday))
453 recdb.del_reckey(recdblist.REC_KEYWORD_EVERY_SOME_DAYS, title, chtxt, btime)
456 btxt = bt.strftime("%Y-%m-%d %H:%M:%S")
457 etxt = et.strftime("%Y-%m-%d %H:%M:%S")
458 recdb.everyreserv(title, chtxt, btxt, etxt, deltatime, opt, deltaday)
460 recdb.del_reckey(recdblist.REC_KEYWORD_EVERY_SOME_DAYS, title, chtxt, btime)
463 btxt = bt.strftime("%Y-%m-%d %H:%M:%S")
464 etxt = et.strftime("%Y-%m-%d %H:%M:%S")
466 recdb.everyreserv(title, chtxt, btxt, etxt, deltatime, opt, deltaday,counter-1)
468 recdb.everyreserv(title, chtxt, btxt, etxt, deltatime, opt, deltaday,-1)
469 recdata = epgdb.searchtime2(title, btime, deltatime, chtxt)
478 bt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
479 et = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
480 btimet = bt.strftime("%Y-%m-%d %H:%M:%S")
481 etimet = et.strftime("%Y-%m-%d %H:%M:%S")
483 recdb.keyreserv(titlet, chtxtt, btimet, etimet, deltatime, opt)
485 recdb.keyreserv(title, chtxt, btime, etime, deltatime, opt)
486 def type_decode_que(typetxt,chtxt,title,bt,et,opt):
487 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
488 etime = et.strftime("%Y-%m-%d %H:%M:%S")
489 tnow = datetime.datetime.now()
491 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
496 if typetxt== recdblist.REC_TS_DECODE_QUE:
497 typetxting=recdblist.REC_TS_DECODING
498 typetxtmiss=recdblist.REC_MISS_DECODE
499 typetxtencque=recdblist.REC_ENCODE_QUE
500 tnow = datetime.datetime.now()
502 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
504 if status.getB25Decoding() < 2:
505 pin = recpath + "/" + title
506 recdb.del_reckey(typetxtnow, title, chtxt, btime)
507 recdb.rec_reckey(typetxting, title, chtxt, btime, etime, opt)
508 tv2avi.b252ts(pin, chtxt, btime, etime, opt)
509 recdb.del_reckey(typetxting, title, chtxt, btime)
510 if not os.access(recpath + "/" + title + ".ts", os.F_OK):
511 recdb.del_reckey(typetxting, title, chtxt, btime)
512 recdb.rec_reckey(typetxtmiss, title, chtxt, btime, etime, opt)
514 auto_process.deltmpfile(recpath, title, ".ts")
515 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
516 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
518 if not re.search("D", opt):
519 tnow = datetime.datetime.now()
520 bt = tnow + datetime.timedelta(seconds=600)
522 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
523 etime = et.strftime("%Y-%m-%d %H:%M:%S")
524 recdb.rec_reckey(typetxtencque, title, chtxt, btime, etime, opt)
527 shutil.copy(os.path.join(recpath,title+".ts"), os.path.join(movepath,title+".ts"))
529 if os.path.getsize(os.path.join(recpath,title+".ts"))==os.path.getsize(os.path.join(movepath,title+".ts")):
530 os.remove(os.path.join(recpath,title+".ts"))
531 except Exception, inst:
532 errtxt1="move ts error.\n"
533 errtxt2=str(type(inst))+"\n"
534 errtxt2=errtxt2+str(inst)
535 recdblist.Commonlogex("Error", "type_decode_que(timerec.py)", errtxt1,errtxt2,log_level=200)
536 recdb.rec_reckey(recdblist.REC_MOVE_END, title, chtxt, btime, etime, opt)
538 recdb.del_reckey(typetxtnow, title, chtxt, btime)
539 bt = bt + datetime.timedelta(seconds=600)
540 et = et + datetime.timedelta(seconds=600)
541 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
542 etime = et.strftime("%Y-%m-%d %H:%M:%S")
543 recdb.rec_reckey(typetxtnow, title, chtxt, btime, etime, opt)
546 def type_encode_que(typetxt,chtxt,title,bt,et,opt):
547 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
548 etime = et.strftime("%Y-%m-%d %H:%M:%S")
549 tnow = datetime.datetime.now()
551 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
555 if typetxt==recdblist.REC_ENCODE_QUE:
556 typetxting=recdblist.REC_ENCODE_LOCAL
557 typetxtfin=recdblist.REC_FIN_LOCAL
559 if status.getEncoding() < int(configreader.getenv("enc_max")):
560 recdb.del_reckey(typetxtnow, title, chtxt, btime)
561 recdb.rec_reckey(typetxting, title, chtxt, btime, etime, opt)
562 recdblist.printutf8(opt)
563 pin = recpath + "/" + title + ".ts"
564 if re.search("d", opt):
565 pin = recpath + "/" + title + ".m2v"
566 if not os.path.exists(pin) or os.path.getsize(pin)<100*1000:
567 paac2 = recpath + "/" + title + "_2.aac"
568 pmp32 = recpath + "/" + title + "_2.mp3"
569 if not os.path.exists(paac2) and not os.path.exists(pmp32):
570 tv2avi.dualaudio2sep(os.path.join(recpath, title+".ts"),"167")
572 elif re.search("5", opt):
573 pin = recpath + "/" + title + ".m2v"
574 if not os.path.exists(pin) or os.path.getsize(pin)<100*1000:
575 paac2 = recpath + "/" + title + "_2.aac"
576 pmp32 = recpath + "/" + title + "_2.mp3"
577 if not os.path.exists(paac2) and not os.path.exists(pmp32):
578 tv2avi.pentaaudio2sep(os.path.join(recpath, title+".ts"))
580 elif re.search("b", opt):
581 pin = recpath + "/" + title + ".m2v"
582 if not os.path.exists(pin) or os.path.getsize(pin)<100*1000:
583 paac2 = recpath + "/" + title + "_1.aac"
584 pmp32 = recpath + "/" + title + "_1.mp3"
585 if not os.path.exists(paac2) and not os.path.exists(pmp32):
586 tv2avi.singleaudio2sep(os.path.join(recpath, title+".ts"))
590 if configreader.getenv("make_mp4")=="1":
594 if re.search("m", opt):
596 if re.search("4", opt):
598 recdblist.printutf8(pin)
599 if not re.search("0", opt):
601 pout = recpath + "/" + title + ".mp4"
602 tv2mp4.ts2mp4(pin, pout, opt)
604 pout = recpath + "/" + title + ".mkv"
605 tv2mkv.ts2mkv(pin, pout, opt)
606 if re.search("8", opt) or re.search("9", opt):
608 optt=optt.replace("8","MW8")
609 optt=optt.replace("9","MW9")
610 poutt = recpath + "/" + "m_"+title + ".mp4"
611 if re.search("d", opt) or re.search("5", opt):
612 if os.path.exists(os.path.join(recpath, "m_"+title+".m2v")):
613 shutil.move(os.path.join(recpath, title+".m2v"),os.path.join(recpath, "m_"+title+".m2v"))
614 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.aac")):
615 shutil.move(os.path.join(recpath, title+"_1.aac"),os.path.join(recpath, "m_"+title+"_1.aac"))
616 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.mp3")):
617 shutil.move(os.path.join(recpath, title+"_1.mp3"),os.path.join(recpath, "m_"+title+"_1.mp3"))
618 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.aac")):
619 shutil.move(os.path.join(recpath, title+"_2.aac"),os.path.join(recpath, "m_"+title+"_2.aac"))
620 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.mp3")):
621 shutil.move(os.path.join(recpath, title+"_2.mp3"),os.path.join(recpath, "m_"+title+"_2.mp3"))
622 shutil.move(os.path.join(recpath, title+".ts"),os.path.join(recpath, "m_"+title+".ts"))
623 tv2mp4.ts2mp4(os.path.join(recpath, "m_"+title+".ts"), poutt, optt)
624 shutil.move(os.path.join(recpath, "m_"+title+".ts"),os.path.join(recpath, title+".ts"))
627 optt=optt.replace("8","MW8")
628 optt=optt.replace("9","MW9")
629 poutt = recpath + "/" + "m_"+title + ".mp4"
630 shutil.move(os.path.join(recpath, title+".ts"),os.path.join(recpath, "m_"+title+".ts"))
631 if re.search("d", opt) or re.search("5", opt):
632 if os.path.exists(os.path.join(recpath, "m_"+title+".m2v")):
633 shutil.move(os.path.join(recpath, title+".m2v"),os.path.join(recpath, "m_"+title+".m2v"))
634 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.aac")):
635 shutil.move(os.path.join(recpath, title+"_1.aac"),os.path.join(recpath, "m_"+title+"_1.aac"))
636 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.mp3")):
637 shutil.move(os.path.join(recpath, title+"_1.mp3"),os.path.join(recpath, "m_"+title+"_1.mp3"))
638 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.aac")):
639 shutil.move(os.path.join(recpath, title+"_2.aac"),os.path.join(recpath, "m_"+title+"_2.aac"))
640 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.mp3")):
641 shutil.move(os.path.join(recpath, title+"_2.mp3"),os.path.join(recpath, "m_"+title+"_2.mp3"))
642 tv2mp4.ts2mp4(os.path.join(recpath, "m_"+title+".ts"), poutt, optt)
643 shutil.move(os.path.join(recpath, "m_"+title+".ts"),os.path.join(recpath, title+".ts"))
644 recdb.del_reckey(typetxting, title, chtxt, btime)
646 if re.search("E", opt):
648 if os.path.exists(os.path.join(recpath,title+".mp4")):
649 shutil.copy(os.path.join(recpath,title+".mp4"), os.path.join(movepath,title+".mp4"))
650 elif os.path.exists(os.path.join(recpath,title+".mkv")):
651 shutil.copy(os.path.join(recpath,title+".mkv"), os.path.join(movepath,title+".mkv"))
652 except Exception, inst:
653 errtxt1="move mkv/mp4 error."
654 errtxt2=str(type(inst))+"\n"
655 errtxt2=errtxt2+str(inst)
656 recdblist.Commonlogex("Error", "type_encode_que(timerec.py)", errtxt1,errtxt2,log_level=200)
657 recdb.rec_reckey(recdblist.REC_MOVE_END, title, chtxt, btime, etime, opt)
658 recdb.rec_reckey(typetxtfin, title, chtxt, btime, etime, opt)
661 recdb.del_reckey(typetxtnow, title, chtxt, btime)
662 bt = bt + datetime.timedelta(seconds=600)
663 et = et + datetime.timedelta(seconds=600)
664 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
665 etime = et.strftime("%Y-%m-%d %H:%M:%S")
666 recdb.rec_reckey(typetxtnow, title, chtxt, btime, etime, opt)