3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009-2010 Yukikaze
29 recpath = configreader.getpath('recpath')
30 movepath = configreader.getpath('move_destpath')
31 path = str(os.path.dirname(os.path.abspath(__file__))) + "/"
38 if rec10d.rec10db.select_installed_in_status()==0 or rec10d.rec10db.select_version_in_status()<recdblist.version:
42 recdb.delete_old("24")
43 recdb.delete_old_auto_bayes("1")
44 recdb.delete_old_auto_keyword("1")
45 tasks = recdb.getnow("3")
46 inum = recdb.countRecNow_minutes("10")
47 recdblist.printutf8(u"rec10処理開始"+ datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),verbose_level=800)
48 recdblist.printutf8(u"直近録画予約件数:" + str(inum) + u"BS/CS録画中件数:" + str(status.getBSCSRecording()) + u"TE録画中件数:" + str(status.getTERecording()) ,verbose_level=800)
51 dnow=datetime.datetime.now()
57 for k in recdb.get_key():
59 recque.searchRecQue(recpath)
67 auto_process.auto_check(recpath)
69 auto_process.kill_dead_encode(recpath)
71 update = chdb.update()
80 if bctype.find('te') > -1:
81 recnum = status.getTERecording() + recdb.countRecNow_minutes_TE("10")
82 recdblist.printutf8(u"放送種別:"+bctype + u"||該当チューナー実行中件数:" + str(status.getTERecording()) + u":直近予約件数:" + str(recdb.countRecNow_minutes_TE("10")),verbose_level=800)
83 recnum = int(configreader.getenv("te_max")) -recnum
85 recnum = status.getBSCSRecording() + recdb.countRecNow_minutes_BSCS("10")
86 recdblist.printutf8(u"放送種別:"+bctype + u"||該当チューナー実行中件数:" + str(status.getBSCSRecording()) + u":直近予約件数:" + str(recdb.countRecNow_minutes_BSCS("10")),verbose_level=800)
87 recnum = int(configreader.getenv("bscs_max")) -recnum
89 recdblist.printutf8(str(update),verbose_level=750)
90 rec10d.rec10db.update_status_by_bctype_epg_ch(bctype, "0")
91 epgdb.updatebc(bctype)
92 update = chdb.update()
97 auto_process.update_all_timeline_epg()
104 auto_process.update_all_timeline_epg()
107 typetxt = task["type"]
109 chtxt = task['chtxt']
113 title = task['title']
117 btime = task['btime']
118 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
121 bt = datetime.datetime.strptime("2009-01-01 00:00:00", "%Y-%m-%d %H:%M:%S")
123 etime = task['etime']
124 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
127 et = datetime.datetime.strptime("2009-01-01 00:00:00", "%Y-%m-%d %H:%M:%S")
132 tnow = datetime.datetime.now()
134 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
135 if task["type"] == recdblist.REC_RESERVE:#"res,"+chtxt+","+title+","+btime+","+etime+","+opt
137 if pid != 0:#親プロセスの場合
139 else:#子プロセスの場合 アップデートを行って終了
140 type_reserve(task["type"],chtxt,title,bt,et,opt)
142 elif task["type"] == recdblist.REC_KEYWORD:#"key,"+chtxt+","+keyword+","+btime+","+deltatime+","+opt
143 deltatime = task['deltatime']
145 if pid != 0:#親プロセスの場合
147 else:#子プロセスの場合 アップデートを行って終了
148 type_keyword(task["type"],chtxt,title, bt, et, opt, deltatime)
150 elif task["type"] == recdblist.REC_KEYWORD_EVERY_SOME_DAYS:#"keyevery,"+chtxt+","+keyword+","+btime+","+deltatime+","+opt+","+deltaday
151 deltatime = task['deltatime']
152 deltaday = task['deltaday']
154 keyeverycounter=task['counter']
158 if pid != 0:#親プロセスの場合
160 else:#子プロセスの場合 アップデートを行って終了
161 type_keyword_every_day(task["type"],chtxt, title, bt, et, opt, deltatime, deltaday,keyeverycounter)
163 elif task["type"] == recdblist.REC_FINAL_RESERVE:#"rec,"+chtxt+","+title+","+btime+","+etime+","+opt
165 if pid != 0:#親プロセスの場合
167 else:#子プロセスの場合 アップデートを行って終了
168 type_final(task["type"],chtxt, title, bt, et, opt)
170 elif task["type"] == recdblist.REC_TS_DECODE_QUE:
173 if pid != 0:#親プロセスの場合
175 else:#子プロセスの場合 アップデートを行って終了
177 type_decode_que(task["type"],chtxt, title, bt, et, opt)
179 elif task["type"] == recdblist.REC_ENCODE_QUE:
180 encodenum=encodenum+1
182 if pid != 0:#親プロセスの場合
184 else:#子プロセスの場合 アップデートを行って終了
185 time.sleep(5*encodenum)
186 type_encode_que(task["type"],chtxt, title, bt, et, opt)
188 elif task["type"] == recdblist.REC_AVI_TO_MKV:
196 if configreader.getenv("make_mp4")==1:
200 if re.search("m", opt):
202 if re.search("4", opt):
204 recdb.del_reckey(recdblist.REC_AVI_TO_MKV, title, chtxt, btime)
205 recdb.rec_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
207 tv2mp4.raw2mp4(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mp4"),opt)
209 tv2mkv.raw2mkv(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mkv"),opt)
210 recdb.del_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime)
212 elif task["type"] == recdblist.REC_AVI_TO_MP4:
220 if configreader.getenv("make_mp4")==1:
224 if re.search("m", opt):
226 if re.search("4", opt):
228 recdb.del_reckey(recdblist.REC_AVI_TO_MP4, title, chtxt, btime)
229 recdb.rec_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
231 tv2mp4.ts2mp4(pin, pout, opt)
232 tv2mp4.raw2mp4(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mp4"),opt)
234 tv2mkv.raw2mkv(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mkv"),opt)
235 recdb.del_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime)
237 elif task["type"] == recdblist.REC_MKV_TO_MP4:
243 recdb.del_reckey(recdblist.REC_MKV_TO_MP4, title, chtxt, btime)
244 recdb.rec_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
245 tv2mp4.mkv2mp4(os.path.join(recpath,title+".mkv"),os.path.join(recpath,title+".mp4"))
246 recdb.del_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime)
249 def search_keyword(key):
250 tnow = datetime.datetime.now()
251 nows =tnow.strftime("%Y-%m-%d %H:%M:%S")
253 recdatum = epgdb.searchtime_auto(k,nows, "144")
254 for recdata in recdatum:
260 btt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
261 ett = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
262 btimet = btt.strftime("%Y-%m-%d %H:%M:%S")
263 etimet = ett.strftime("%Y-%m-%d %H:%M:%S")
264 if status.getSettings_auto_jbk()==1:
265 topt=status.getSettings_auto_opt()
269 maxnum=epgdb.count_schedule_timeline(btimet, etimet)[1]
270 maxnum=int(configreader.getenv("bscs_max"))-maxnum
272 maxnum=epgdb.count_schedule_timeline(btimet, etimet)[0]
273 maxnum=int(configreader.getenv("te_max"))-maxnum
275 topt=status.getSettings_auto_opt()
276 recdb.recreserv(titlet,chtxtt, btimet, etimet,topt)
277 except Exception, inst:
278 recdblist.Commonlogex("Error", "search_keyword_auto_jbk(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
281 recdb.add_auto_keyword(chtxtt, titlet, btimet, etimet)
282 except Exception, inst:
283 recdblist.Commonlogex("Error", "search_keyword(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
284 def type_reserve(typetxt,chtxt,title,bt,et,opt):
285 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
286 etime = et.strftime("%Y-%m-%d %H:%M:%S")
289 if typetxt==recdblist.REC_RESERVE:
290 typetxtfinal=recdblist.REC_FINAL_RESERVE
291 tnow = datetime.datetime.now()
293 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
294 if (dt < 58 * 60 and dt > 30 * 60):
295 bctypet = chdb.chtxtsearch(chtxt)['bctype']
296 chdatat = rec10d.rec10db.select_by_bctype_epg_ch(bctypet)
297 dt1 = datetime.datetime.strptime(chdatat[0][4], "%Y-%m-%d %H:%M:%S")-datetime.datetime.now()
298 dt1 = dt1.days * 24 * 60 * 60 + dt1.seconds
300 recdata = epgdb.searchtime2(title, btime, "5", chtxt)
308 bt = datetime.datetime.strptime(btimen, "%Y-%m-%d %H:%M:%S")
309 et = datetime.datetime.strptime(etimen, "%Y-%m-%d %H:%M:%S")
310 btimen = bt.strftime("%Y-%m-%d %H:%M:%S")
311 etimen = et.strftime("%Y-%m-%d %H:%M:%S")
314 recdb.del_reckey(typetxtnow, title, chtxt, btime)
315 recdb.rec_reckey(typetxtfinal, titlen, chtxtn, btimen, etimen, opt)
316 recdb.rec_reclog(titlen, chtxtn, btimen, etimen, opt, exp, longexp, category)
317 auto_rec.add_key(chtxt, titlen,exp+" "+longexp)
318 auto_rec.add_key("ALL", titlen,exp+" "+longexp)
319 recdblist.printutf8(u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen)
320 except Exception, inst:
321 recdblist.Commonlogex("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
323 recdblist.printutf8(u"追いかけ機能エラー:番組データが見付かりません。")
325 if rec10d.rec10db.select_by_bctype_epg_ch(bctypet)[0][5] != "0":
326 rec10d.rec10db.update_status_by_bctype_epg_ch(bctypet, "3")
328 elif (dt <= 30 * 60 and dt > 20 * 60):
329 recdata = epgdb.searchtime2(title, btime, "5", chtxt)
337 bt = datetime.datetime.strptime(btimen, "%Y-%m-%d %H:%M:%S")
338 et = datetime.datetime.strptime(etimen, "%Y-%m-%d %H:%M:%S")
339 btimen = bt.strftime("%Y-%m-%d %H:%M:%S")
340 etimen = et.strftime("%Y-%m-%d %H:%M:%S")
343 recdb.del_reckey(typetxtnow, title, chtxt, btime)
344 recdb.rec_reckey(typetxtfinal, titlen, chtxtn, btimen, etimen, opt)
345 recdb.rec_reclog(titlen, chtxtn, btimen, etimen, opt, exp, longexp, category)
346 auto_rec.add_key(chtxt, titlen,exp+" "+longexp)
347 auto_rec.add_key("ALL", titlen,exp+" "+longexp)
348 #recdblist.printutf8(u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen)
349 recdblist.Commonlogex(u"通常", "Oikake (timerec.py)",u"追いかけ機能実行中",u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen,log_level=500)
350 except Exception, inst:
351 recdblist.Commonlogex("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
354 recdb.del_reckey(typetxtnow, title, chtxt, btime)
355 recdb.rec_reckey(typetxtfinal, title, chtxt, btime, etime, opt)
356 except Exception, inst:
357 recdblist.Commonlogex("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
358 def type_final(typetxt,chtxt,title,bt,et,opt):
359 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
360 etime = et.strftime("%Y-%m-%d %H:%M:%S")
364 if typetxt==recdblist.REC_FINAL_RESERVE:
365 typetxting=recdblist.REC_TS_RECORDING
366 typetxtdecque=recdblist.REC_TS_DECODE_QUE
367 tnow = datetime.datetime.now()
369 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
370 if dt < 6 * 60 and dt > 0:
372 recdb.del_reckey(typetxtnow, title, chtxt, btime)
373 testpath=[os.path.join(recpath,title+".ts.b25")]
374 testpath.append(os.path.join(recpath,title+".ts"))
375 testpath.append(os.path.join(recpath,title+".avi"))
376 testpath.append(os.path.join(recpath,title+".mp4"))
377 testpath.append(os.path.join(recpath,title+".log"))
380 if os.path.exists(ti):
382 if re.search("N", opt) or tcheck>0:
385 iff=u"("+configreader.getenv("iff")+u")_"
389 newtitle=newtitle+u"_"+iff+newtime.strftime("%Y-%m-%dT%H-%M-%S")
390 recdb.rec_reckey(typetxting, newtitle, chtxt, btime, etime, opt)
391 recdblist.Commonlogex(u"通常","timerec.py",u"録画開始 "+newtitle+" "+btime+" "+etime,"",log_level=500)
392 tv2avi.timetv2b25(recpath + "/" + newtitle + ".avi", chtxt, btime, etime, opt)
393 recdb.del_reckey(typetxting, newtitle, chtxt, btime)
394 if not re.search("R", opt):
395 tnow = datetime.datetime.now()
396 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
397 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
399 bt = tnow + datetime.timedelta(seconds=600)
400 et = et + dt + datetime.timedelta(seconds=600)
401 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
402 etime = et.strftime("%Y-%m-%d %H:%M:%S")
403 recdb.rec_reckey(typetxtdecque, newtitle, chtxt, btime, etime, opt)
407 shutil.copy(os.path.join(recpath,title+".ts.b25"), os.path.join(movepath,title+".ts.b25"))
411 os.chmod(os.path.join(movepath,title+".ts.b25"),0777)
414 recque.writeRecQue(movepath, chtxt, title, opt)
416 os.chmod(os.path.join(movepath,title+".recq"),0777)
419 except Exception, inst:
420 recdblist.Commonlogex("Error", "Move option(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
421 recdb.rec_reckey(recdblist.REC_MOVE_END, newtitle, chtxt, btime, etime, opt)
423 def type_keyword(typetxt,chtxt,title,bt,et,opt,deltatime):
424 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
425 etime = et.strftime("%Y-%m-%d %H:%M:%S")
428 if typetxt==recdblist.REC_KEYWORD:
429 typetxtres=recdblist.REC_RESERVE
430 tnow = datetime.datetime.now()
432 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
433 recdblist.printutf8(str(dt), verbose_level=800)
435 recdata = epgdb.searchtime2(title, btime, deltatime, chtxt)
444 bt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
445 et = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
446 btimet = bt.strftime("%Y-%m-%d %H:%M:%S")
447 etimet = et.strftime("%Y-%m-%d %H:%M:%S")
449 recdb.del_reckey(typetxtnow, title, chtxt, btime)
450 recdb.rec_reckey(typetxtres, titlet, chtxtt, btimet, etimet, opt)
451 recdb.rec_reclog(titlet, chtxtt, btimet, etimet, opt, exp,longexp,category)
452 auto_rec.add_key(chtxt, titlet,exp+" "+longexp)
453 auto_rec.add_key("ALL", titlet,exp+" "+longexp)
454 recdblist.Commonlogex(u"通常","timerec.py",u"key "+title+u" : "+titlet+u" "+btimet+u" "+etimet,"",log_level=500)
455 #except Exception, inst:
456 # recdblist.printutf8("Error happened in REC_KEYWORD DB")
457 # recdblist.printutf8(type(inst))
458 # recdblist.printutf8(inst)
460 recdblist.printutf8("nothing match")
461 def type_keyword_every_day(type,chtxt,title,bt,et,opt,deltatime,deltaday,counter):
462 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
463 etime = et.strftime("%Y-%m-%d %H:%M:%S")
464 tnow = datetime.datetime.now()
466 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
467 dd = datetime.timedelta(days=int(deltaday))
469 recdb.del_reckey(recdblist.REC_KEYWORD_EVERY_SOME_DAYS, title, chtxt, btime)
472 btxt = bt.strftime("%Y-%m-%d %H:%M:%S")
473 etxt = et.strftime("%Y-%m-%d %H:%M:%S")
474 recdb.everyreserv(title, chtxt, btxt, etxt, deltatime, opt, deltaday)
476 recdb.del_reckey(recdblist.REC_KEYWORD_EVERY_SOME_DAYS, title, chtxt, btime)
479 btxt = bt.strftime("%Y-%m-%d %H:%M:%S")
480 etxt = et.strftime("%Y-%m-%d %H:%M:%S")
482 recdb.everyreserv(title, chtxt, btxt, etxt, deltatime, opt, deltaday,counter-1)
484 recdb.everyreserv(title, chtxt, btxt, etxt, deltatime, opt, deltaday,-1)
485 recdata = epgdb.searchtime2(title, btime, deltatime, chtxt)
494 bt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
495 et = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
496 btimet = bt.strftime("%Y-%m-%d %H:%M:%S")
497 etimet = et.strftime("%Y-%m-%d %H:%M:%S")
499 recdb.keyreserv(titlet, chtxtt, btimet, etimet, deltatime, opt)
501 recdb.keyreserv(title, chtxt, btime, etime, deltatime, opt)
502 def type_decode_que(typetxt,chtxt,title,bt,et,opt):
503 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
504 etime = et.strftime("%Y-%m-%d %H:%M:%S")
505 tnow = datetime.datetime.now()
507 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
512 if typetxt== recdblist.REC_TS_DECODE_QUE:
513 typetxting=recdblist.REC_TS_DECODING
514 typetxtmiss=recdblist.REC_MISS_DECODE
515 typetxtencque=recdblist.REC_ENCODE_QUE
516 tnow = datetime.datetime.now()
518 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
520 if status.getB25Decoding() < 2:
521 pin = recpath + "/" + title
522 recdb.del_reckey(typetxtnow, title, chtxt, btime)
523 recdb.rec_reckey(typetxting, title, chtxt, btime, etime, opt)
524 tv2avi.b252ts(pin, chtxt, btime, etime, opt)
525 recdb.del_reckey(typetxting, title, chtxt, btime)
526 if not os.access(recpath + "/" + title + ".ts", os.F_OK):
527 recdb.del_reckey(typetxting, title, chtxt, btime)
528 recdb.rec_reckey(typetxtmiss, title, chtxt, btime, etime, opt)
530 auto_process.deltmpfile(recpath, title, ".ts")
531 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
532 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
534 if not re.search("D", opt):
535 tnow = datetime.datetime.now()
536 bt = tnow + datetime.timedelta(seconds=600)
538 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
539 etime = et.strftime("%Y-%m-%d %H:%M:%S")
540 recdb.rec_reckey(typetxtencque, title, chtxt, btime, etime, opt)
544 shutil.copy(os.path.join(recpath,title+".ts"), os.path.join(movepath,title+".ts"))
548 os.chmod(os.path.join(movepath,title+".ts"),0777)
551 recque.writeRecQue(movepath, chtxt, title, opt)
553 os.chmod(os.path.join(movepath,title+".recq"),0777)
557 if os.path.getsize(os.path.join(recpath,title+".ts"))==os.path.getsize(os.path.join(movepath,title+".ts")):
558 os.remove(os.path.join(recpath,title+".ts"))
559 except Exception, inst:
560 errtxt1="move ts error.\n"
561 errtxt2=str(type(inst))+"\n"
562 errtxt2=errtxt2+str(inst)
563 recdblist.Commonlogex("Error", "type_decode_que(timerec.py)", errtxt1,errtxt2+traceback.format_exc(),log_level=200)
564 recdb.rec_reckey(recdblist.REC_MOVE_END, title, chtxt, btime, etime, opt)
566 recdb.del_reckey(typetxtnow, title, chtxt, btime)
567 bt = bt + datetime.timedelta(seconds=600)
568 et = et + datetime.timedelta(seconds=600)
569 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
570 etime = et.strftime("%Y-%m-%d %H:%M:%S")
571 recdb.rec_reckey(typetxtnow, title, chtxt, btime, etime, opt)
574 def type_encode_que(typetxt,chtxt,title,bt,et,opt):
575 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
576 etime = et.strftime("%Y-%m-%d %H:%M:%S")
577 tnow = datetime.datetime.now()
579 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
583 if typetxt==recdblist.REC_ENCODE_QUE:
584 typetxting=recdblist.REC_ENCODE_LOCAL
585 typetxtfin=recdblist.REC_FIN_LOCAL
587 if status.getEncoding() < int(configreader.getenv("enc_max")):
588 recdb.del_reckey(typetxtnow, title, chtxt, btime)
589 recdb.rec_reckey(typetxting, title, chtxt, btime, etime, opt)
590 recdblist.printutf8(opt)
591 pin = recpath + "/" + title + ".ts"
592 if re.search("d", opt):
593 pin = recpath + "/" + title + ".m2v"
594 if not os.path.exists(pin) or os.path.getsize(pin)<100*1000:
595 paac2 = recpath + "/" + title + "_2.aac"
596 pmp32 = recpath + "/" + title + "_2.mp3"
597 if not os.path.exists(paac2) and not os.path.exists(pmp32):
598 tv2audio.ts2dualaudio_BonTsDemux(os.path.join(recpath, title+".ts"),recdblist.BONTSDEMUX_DELAY,opt)
600 elif re.search("5", opt):
601 pin = recpath + "/" + title + ".m2v"
602 if not os.path.exists(pin) or os.path.getsize(pin)<100*1000:
603 paac2 = recpath + "/" + title + "_2.aac"
604 pmp32 = recpath + "/" + title + "_2.mp3"
605 if not os.path.exists(paac2) and not os.path.exists(pmp32):
606 tv2audio.ts2pentaaudio_BonTsDemux(os.path.join(recpath, title+".ts"), recdblist.BONTSDEMUX_DELAY, opt)
610 if configreader.getenv("make_mp4")=="1":
614 if re.search("m", opt):
616 if re.search("4", opt):
618 recdblist.printutf8(pin)
619 if not re.search("0", opt):
621 pout = recpath + "/" + title + ".mp4"
622 tv2mp4.ts2mp4(pin, pout, opt)
624 pout = recpath + "/" + title + ".mkv"
625 tv2mkv.ts2mkv(pin, pout, opt)
626 if re.search("8", opt) or re.search("9", opt):
628 optt=optt.replace("8","MW8")
629 optt=optt.replace("9","MW9")
630 poutt = recpath + "/" + "m_"+title + ".mp4"
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 shutil.move(os.path.join(recpath, title+".ts"),os.path.join(recpath, "m_"+title+".ts"))
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"))
647 optt=optt.replace("8","MW8")
648 optt=optt.replace("9","MW9")
649 poutt = recpath + "/" + "m_"+title + ".mp4"
650 shutil.move(os.path.join(recpath, title+".ts"),os.path.join(recpath, "m_"+title+".ts"))
651 if re.search("d", opt) or re.search("5", opt):
652 if os.path.exists(os.path.join(recpath, "m_"+title+".m2v")):
653 shutil.move(os.path.join(recpath, title+".m2v"),os.path.join(recpath, "m_"+title+".m2v"))
654 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.aac")):
655 shutil.move(os.path.join(recpath, title+"_1.aac"),os.path.join(recpath, "m_"+title+"_1.aac"))
656 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.mp3")):
657 shutil.move(os.path.join(recpath, title+"_1.mp3"),os.path.join(recpath, "m_"+title+"_1.mp3"))
658 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.aac")):
659 shutil.move(os.path.join(recpath, title+"_2.aac"),os.path.join(recpath, "m_"+title+"_2.aac"))
660 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.mp3")):
661 shutil.move(os.path.join(recpath, title+"_2.mp3"),os.path.join(recpath, "m_"+title+"_2.mp3"))
662 tv2mp4.ts2mp4(os.path.join(recpath, "m_"+title+".ts"), poutt, optt)
663 shutil.move(os.path.join(recpath, "m_"+title+".ts"),os.path.join(recpath, title+".ts"))
664 recdb.del_reckey(typetxting, title, chtxt, btime)
666 if re.search("E", opt):
668 if os.path.exists(os.path.join(recpath,title+".mp4")):
670 shutil.copy(os.path.join(recpath,title+".mp4"), os.path.join(movepath,title+".mp4"))
674 os.chmod(os.path.join(movepath,title+".mp4"),0777)
677 recque.writeRecQue(movepath, chtxt, title, opt)
679 os.chmod(os.path.join(movepath,title+".recq"),0777)
682 elif os.path.exists(os.path.join(recpath,title+".mkv")):
684 shutil.copy(os.path.join(recpath,title+".mkv"), os.path.join(movepath,title+".mkv"))
688 os.chmod(os.path.join(movepath,title+".mkv"),0777)
691 recque.writeRecQue(movepath, chtxt, title, opt)
693 os.chmod(os.path.join(movepath,title+".recq"),0777)
696 except Exception, inst:
697 errtxt1="move mkv/mp4 error."
698 errtxt2=str(type(inst))+"\n"
699 errtxt2=errtxt2+str(inst)
700 recdblist.Commonlogex("Error", "type_encode_que(timerec.py)", errtxt1,errtxt2+traceback.format_exc(),log_level=200)
701 recdb.rec_reckey(recdblist.REC_MOVE_END, title, chtxt, btime, etime, opt)
702 recdb.rec_reckey(typetxtfin, title, chtxt, btime, etime, opt)
705 recdb.del_reckey(typetxtnow, title, chtxt, btime)
706 bt = bt + datetime.timedelta(seconds=600)
707 et = et + datetime.timedelta(seconds=600)
708 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
709 etime = et.strftime("%Y-%m-%d %H:%M:%S")
710 recdb.rec_reckey(typetxtnow, title, chtxt, btime, etime, opt)