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][5], "%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][6] != "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"))
410 os.chmod(os.path.join(movepath,title+".ts.b25"),0777)
411 recque.writeRecQue(movepath, chtxt, title, opt)
412 os.chmod(os.path.join(movepath,title+".recq"),0777)
413 except Exception, inst:
414 recdblist.Commonlogex("Error", "Move option(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
415 recdb.rec_reckey(recdblist.REC_MOVE_END, newtitle, chtxt, btime, etime, opt)
417 def type_keyword(typetxt,chtxt,title,bt,et,opt,deltatime):
418 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
419 etime = et.strftime("%Y-%m-%d %H:%M:%S")
422 if typetxt==recdblist.REC_KEYWORD:
423 typetxtres=recdblist.REC_RESERVE
424 tnow = datetime.datetime.now()
426 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
427 recdblist.printutf8(str(dt), verbose_level=800)
429 recdata = epgdb.searchtime2(title, btime, deltatime, chtxt)
438 bt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
439 et = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
440 btimet = bt.strftime("%Y-%m-%d %H:%M:%S")
441 etimet = et.strftime("%Y-%m-%d %H:%M:%S")
443 recdb.del_reckey(typetxtnow, title, chtxt, btime)
444 recdb.rec_reckey(typetxtres, titlet, chtxtt, btimet, etimet, opt)
445 recdb.rec_reclog(titlet, chtxtt, btimet, etimet, opt, exp,longexp,category)
446 auto_rec.add_key(chtxt, titlet,exp+" "+longexp)
447 auto_rec.add_key("ALL", titlet,exp+" "+longexp)
448 recdblist.Commonlogex(u"通常","timerec.py",u"key "+title+u" : "+titlet+u" "+btimet+u" "+etimet,"",log_level=500)
449 #except Exception, inst:
450 # recdblist.printutf8("Error happened in REC_KEYWORD DB")
451 # recdblist.printutf8(type(inst))
452 # recdblist.printutf8(inst)
454 recdblist.printutf8("nothing match")
455 def type_keyword_every_day(type,chtxt,title,bt,et,opt,deltatime,deltaday,counter):
456 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
457 etime = et.strftime("%Y-%m-%d %H:%M:%S")
458 tnow = datetime.datetime.now()
460 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
461 dd = datetime.timedelta(days=int(deltaday))
463 recdb.del_reckey(recdblist.REC_KEYWORD_EVERY_SOME_DAYS, title, chtxt, btime)
466 btxt = bt.strftime("%Y-%m-%d %H:%M:%S")
467 etxt = et.strftime("%Y-%m-%d %H:%M:%S")
468 recdb.everyreserv(title, chtxt, btxt, etxt, deltatime, opt, deltaday)
470 recdb.del_reckey(recdblist.REC_KEYWORD_EVERY_SOME_DAYS, title, chtxt, btime)
473 btxt = bt.strftime("%Y-%m-%d %H:%M:%S")
474 etxt = et.strftime("%Y-%m-%d %H:%M:%S")
476 recdb.everyreserv(title, chtxt, btxt, etxt, deltatime, opt, deltaday,counter-1)
478 recdb.everyreserv(title, chtxt, btxt, etxt, deltatime, opt, deltaday,-1)
479 recdata = epgdb.searchtime2(title, btime, deltatime, chtxt)
488 bt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
489 et = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
490 btimet = bt.strftime("%Y-%m-%d %H:%M:%S")
491 etimet = et.strftime("%Y-%m-%d %H:%M:%S")
493 recdb.keyreserv(titlet, chtxtt, btimet, etimet, deltatime, opt)
495 recdb.keyreserv(title, chtxt, btime, etime, deltatime, opt)
496 def type_decode_que(typetxt,chtxt,title,bt,et,opt):
497 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
498 etime = et.strftime("%Y-%m-%d %H:%M:%S")
499 tnow = datetime.datetime.now()
501 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
506 if typetxt== recdblist.REC_TS_DECODE_QUE:
507 typetxting=recdblist.REC_TS_DECODING
508 typetxtmiss=recdblist.REC_MISS_DECODE
509 typetxtencque=recdblist.REC_ENCODE_QUE
510 tnow = datetime.datetime.now()
512 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
514 if status.getB25Decoding() < 2:
515 pin = recpath + "/" + title
516 recdb.del_reckey(typetxtnow, title, chtxt, btime)
517 recdb.rec_reckey(typetxting, title, chtxt, btime, etime, opt)
518 tv2avi.b252ts(pin, chtxt, btime, etime, opt)
519 recdb.del_reckey(typetxting, title, chtxt, btime)
520 if not os.access(recpath + "/" + title + ".ts", os.F_OK):
521 recdb.del_reckey(typetxting, title, chtxt, btime)
522 recdb.rec_reckey(typetxtmiss, title, chtxt, btime, etime, opt)
524 auto_process.deltmpfile(recpath, title, ".ts")
525 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
526 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
528 if not re.search("D", opt):
529 tnow = datetime.datetime.now()
530 bt = tnow + datetime.timedelta(seconds=600)
532 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
533 etime = et.strftime("%Y-%m-%d %H:%M:%S")
534 recdb.rec_reckey(typetxtencque, title, chtxt, btime, etime, opt)
538 shutil.copy(os.path.join(recpath,title+".ts"), os.path.join(movepath,title+".ts"))
541 os.chmod(os.path.join(movepath,title+".ts"),0777)
542 recque.writeRecQue(movepath, chtxt, title, opt)
543 os.chmod(os.path.join(movepath,title+".recq"),0777)
545 if os.path.getsize(os.path.join(recpath,title+".ts"))==os.path.getsize(os.path.join(movepath,title+".ts")):
546 os.remove(os.path.join(recpath,title+".ts"))
547 except Exception, inst:
548 errtxt1="move ts error.\n"
549 errtxt2=str(type(inst))+"\n"
550 errtxt2=errtxt2+str(inst)
551 recdblist.Commonlogex("Error", "type_decode_que(timerec.py)", errtxt1,errtxt2+traceback.format_exc(),log_level=200)
552 recdb.rec_reckey(recdblist.REC_MOVE_END, title, chtxt, btime, etime, opt)
554 recdb.del_reckey(typetxtnow, title, chtxt, btime)
555 bt = bt + datetime.timedelta(seconds=600)
556 et = et + datetime.timedelta(seconds=600)
557 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
558 etime = et.strftime("%Y-%m-%d %H:%M:%S")
559 recdb.rec_reckey(typetxtnow, title, chtxt, btime, etime, opt)
562 def type_encode_que(typetxt,chtxt,title,bt,et,opt):
563 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
564 etime = et.strftime("%Y-%m-%d %H:%M:%S")
565 tnow = datetime.datetime.now()
567 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
571 if typetxt==recdblist.REC_ENCODE_QUE:
572 typetxting=recdblist.REC_ENCODE_LOCAL
573 typetxtfin=recdblist.REC_FIN_LOCAL
575 if status.getEncoding() < int(configreader.getenv("enc_max")):
576 recdb.del_reckey(typetxtnow, title, chtxt, btime)
577 recdb.rec_reckey(typetxting, title, chtxt, btime, etime, opt)
578 recdblist.printutf8(opt)
579 pin = recpath + "/" + title + ".ts"
580 if re.search("d", opt):
581 pin = recpath + "/" + title + ".m2v"
582 if not os.path.exists(pin) or os.path.getsize(pin)<100*1000:
583 paac2 = recpath + "/" + title + "_2.aac"
584 pmp32 = recpath + "/" + title + "_2.mp3"
585 if not os.path.exists(paac2) and not os.path.exists(pmp32):
586 tv2audio.ts2dualaudio_BonTsDemux(os.path.join(recpath, title+".ts"),recdblist.BONTSDEMUX_DELAY,opt)
588 elif re.search("5", opt):
589 pin = recpath + "/" + title + ".m2v"
590 if not os.path.exists(pin) or os.path.getsize(pin)<100*1000:
591 paac2 = recpath + "/" + title + "_2.aac"
592 pmp32 = recpath + "/" + title + "_2.mp3"
593 if not os.path.exists(paac2) and not os.path.exists(pmp32):
594 tv2audio.ts2pentaaudio_BonTsDemux(os.path.join(recpath, title+".ts"), recdblist.BONTSDEMUX_DELAY, opt)
598 if configreader.getenv("make_mp4")=="1":
602 if re.search("m", opt):
604 if re.search("4", opt):
606 recdblist.printutf8(pin)
607 if not re.search("0", opt):
609 pout = recpath + "/" + title + ".mp4"
610 tv2mp4.ts2mp4(pin, pout, opt)
612 pout = recpath + "/" + title + ".mkv"
613 tv2mkv.ts2mkv(pin, pout, opt)
614 if re.search("8", opt) or re.search("9", opt):
616 optt=optt.replace("8","MW8")
617 optt=optt.replace("9","MW9")
618 poutt = recpath + "/" + "m_"+title + ".mp4"
619 if re.search("d", opt) or re.search("5", opt):
620 if os.path.exists(os.path.join(recpath, "m_"+title+".m2v")):
621 shutil.move(os.path.join(recpath, title+".m2v"),os.path.join(recpath, "m_"+title+".m2v"))
622 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.aac")):
623 shutil.move(os.path.join(recpath, title+"_1.aac"),os.path.join(recpath, "m_"+title+"_1.aac"))
624 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.mp3")):
625 shutil.move(os.path.join(recpath, title+"_1.mp3"),os.path.join(recpath, "m_"+title+"_1.mp3"))
626 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.aac")):
627 shutil.move(os.path.join(recpath, title+"_2.aac"),os.path.join(recpath, "m_"+title+"_2.aac"))
628 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.mp3")):
629 shutil.move(os.path.join(recpath, title+"_2.mp3"),os.path.join(recpath, "m_"+title+"_2.mp3"))
630 shutil.move(os.path.join(recpath, title+".ts"),os.path.join(recpath, "m_"+title+".ts"))
631 tv2mp4.ts2mp4(os.path.join(recpath, "m_"+title+".ts"), poutt, optt)
632 shutil.move(os.path.join(recpath, "m_"+title+".ts"),os.path.join(recpath, title+".ts"))
635 optt=optt.replace("8","MW8")
636 optt=optt.replace("9","MW9")
637 poutt = recpath + "/" + "m_"+title + ".mp4"
638 shutil.move(os.path.join(recpath, title+".ts"),os.path.join(recpath, "m_"+title+".ts"))
639 if re.search("d", opt) or re.search("5", opt):
640 if os.path.exists(os.path.join(recpath, "m_"+title+".m2v")):
641 shutil.move(os.path.join(recpath, title+".m2v"),os.path.join(recpath, "m_"+title+".m2v"))
642 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.aac")):
643 shutil.move(os.path.join(recpath, title+"_1.aac"),os.path.join(recpath, "m_"+title+"_1.aac"))
644 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.mp3")):
645 shutil.move(os.path.join(recpath, title+"_1.mp3"),os.path.join(recpath, "m_"+title+"_1.mp3"))
646 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.aac")):
647 shutil.move(os.path.join(recpath, title+"_2.aac"),os.path.join(recpath, "m_"+title+"_2.aac"))
648 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.mp3")):
649 shutil.move(os.path.join(recpath, title+"_2.mp3"),os.path.join(recpath, "m_"+title+"_2.mp3"))
650 tv2mp4.ts2mp4(os.path.join(recpath, "m_"+title+".ts"), poutt, optt)
651 shutil.move(os.path.join(recpath, "m_"+title+".ts"),os.path.join(recpath, title+".ts"))
652 recdb.del_reckey(typetxting, title, chtxt, btime)
654 if re.search("E", opt):
656 if os.path.exists(os.path.join(recpath,title+".mp4")):
658 shutil.copy(os.path.join(recpath,title+".mp4"), os.path.join(movepath,title+".mp4"))
661 os.chmod(os.path.join(movepath,title+".mp4"),0777)
662 recque.writeRecQue(movepath, chtxt, title, opt)
663 os.chmod(os.path.join(movepath,title+".recq"),0777)
664 elif os.path.exists(os.path.join(recpath,title+".mkv")):
666 shutil.copy(os.path.join(recpath,title+".mkv"), os.path.join(movepath,title+".mkv"))
669 os.chmod(os.path.join(movepath,title+".mkv"),0777)
670 recque.writeRecQue(movepath, chtxt, title, opt)
671 os.chmod(os.path.join(movepath,title+".recq"),0777)
672 except Exception, inst:
673 errtxt1="move mkv/mp4 error."
674 errtxt2=str(type(inst))+"\n"
675 errtxt2=errtxt2+str(inst)
676 recdblist.Commonlogex("Error", "type_encode_que(timerec.py)", errtxt1,errtxt2+traceback.format_exc(),log_level=200)
677 recdb.rec_reckey(recdblist.REC_MOVE_END, title, chtxt, btime, etime, opt)
678 recdb.rec_reckey(typetxtfin, title, chtxt, btime, etime, opt)
681 recdb.del_reckey(typetxtnow, title, chtxt, btime)
682 bt = bt + datetime.timedelta(seconds=600)
683 et = et + datetime.timedelta(seconds=600)
684 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
685 etime = et.strftime("%Y-%m-%d %H:%M:%S")
686 recdb.rec_reckey(typetxtnow, title, chtxt, btime, etime, opt)