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:
40 elif rec10d.rec10db.select_installed_in_status()==1:
42 rec10d.rec10db.new_epg_ch()
44 rec10d.rec10db.change_chscaned_in_status()
47 recdb.delete_old("24")
48 recdb.delete_old_auto_bayes("1")
49 recdb.delete_old_auto_keyword("1")
50 tasks = recdb.getnow("3")
51 inum = recdb.countRecNow_minutes("10")
52 recdblist.printutf8(u"rec10処理開始"+ datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),verbose_level=800)
53 recdblist.printutf8(u"直近録画予約件数:" + str(inum) + u"BS/CS録画中件数:" + str(status.getBSCSRecording()) + u"TE録画中件数:" + str(status.getTERecording()) ,verbose_level=800)
56 dnow=datetime.datetime.now()
62 for k in recdb.get_key():
64 recque.searchRecQue(recpath)
72 auto_process.auto_check(recpath)
74 auto_process.kill_dead_encode(recpath)
76 update = chdb.update()
85 if bctype.find('te') > -1:
86 recnum = status.getTERecording() + recdb.countRecNow_minutes_TE("10")
87 recdblist.printutf8(u"放送種別:"+bctype + u"||該当チューナー実行中件数:" + str(status.getTERecording()) + u":直近予約件数:" + str(recdb.countRecNow_minutes_TE("10")),verbose_level=800)
88 recnum = int(configreader.getenv("te_max")) -recnum
90 recnum = status.getBSCSRecording() + recdb.countRecNow_minutes_BSCS("10")
91 recdblist.printutf8(u"放送種別:"+bctype + u"||該当チューナー実行中件数:" + str(status.getBSCSRecording()) + u":直近予約件数:" + str(recdb.countRecNow_minutes_BSCS("10")),verbose_level=800)
92 recnum = int(configreader.getenv("bscs_max")) -recnum
94 recdblist.printutf8(str(update),verbose_level=750)
95 rec10d.rec10db.update_status_by_bctype_epg_ch(bctype, "0")
96 epgdb.updatebc(bctype)
97 update = chdb.update()
102 auto_process.update_all_timeline_epg()
109 auto_process.update_all_timeline_epg()
112 typetxt = task["type"]
114 chtxt = task['chtxt']
118 title = task['title']
122 btime = task['btime']
123 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
126 bt = datetime.datetime.strptime("2009-01-01 00:00:00", "%Y-%m-%d %H:%M:%S")
128 etime = task['etime']
129 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
132 et = datetime.datetime.strptime("2009-01-01 00:00:00", "%Y-%m-%d %H:%M:%S")
137 tnow = datetime.datetime.now()
139 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
140 if task["type"] == recdblist.REC_RESERVE:#"res,"+chtxt+","+title+","+btime+","+etime+","+opt
142 if pid != 0:#親プロセスの場合
144 else:#子プロセスの場合 アップデートを行って終了
145 type_reserve(task["type"],chtxt,title,bt,et,opt)
147 elif task["type"] == recdblist.REC_KEYWORD:#"key,"+chtxt+","+keyword+","+btime+","+deltatime+","+opt
148 deltatime = task['deltatime']
150 if pid != 0:#親プロセスの場合
152 else:#子プロセスの場合 アップデートを行って終了
153 type_keyword(task["type"],chtxt,title, bt, et, opt, deltatime)
155 elif task["type"] == recdblist.REC_KEYWORD_EVERY_SOME_DAYS:#"keyevery,"+chtxt+","+keyword+","+btime+","+deltatime+","+opt+","+deltaday
156 deltatime = task['deltatime']
157 deltaday = task['deltaday']
159 keyeverycounter=task['counter']
163 if pid != 0:#親プロセスの場合
165 else:#子プロセスの場合 アップデートを行って終了
166 type_keyword_every_day(task["type"],chtxt, title, bt, et, opt, deltatime, deltaday,keyeverycounter)
168 elif task["type"] == recdblist.REC_FINAL_RESERVE:#"rec,"+chtxt+","+title+","+btime+","+etime+","+opt
170 if pid != 0:#親プロセスの場合
172 else:#子プロセスの場合 アップデートを行って終了
173 type_final(task["type"],chtxt, title, bt, et, opt)
175 elif task["type"] == recdblist.REC_TS_DECODE_QUE:
178 if pid != 0:#親プロセスの場合
180 else:#子プロセスの場合 アップデートを行って終了
182 type_decode_que(task["type"],chtxt, title, bt, et, opt)
184 elif task["type"] == recdblist.REC_ENCODE_QUE:
185 encodenum=encodenum+1
187 if pid != 0:#親プロセスの場合
189 else:#子プロセスの場合 アップデートを行って終了
190 time.sleep(5*encodenum)
191 type_encode_que(task["type"],chtxt, title, bt, et, opt)
193 elif task["type"] == recdblist.REC_AVI_TO_MKV:
201 if configreader.getenv("make_mp4")==1:
205 if re.search("m", opt):
207 if re.search("4", opt):
209 recdb.del_reckey(recdblist.REC_AVI_TO_MKV, title, chtxt, btime)
210 recdb.rec_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
212 tv2mp4.raw2mp4(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mp4"),opt)
214 tv2mkv.raw2mkv(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mkv"),opt)
215 recdb.del_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime)
217 elif task["type"] == recdblist.REC_AVI_TO_MP4:
225 if configreader.getenv("make_mp4")==1:
229 if re.search("m", opt):
231 if re.search("4", opt):
233 recdb.del_reckey(recdblist.REC_AVI_TO_MP4, title, chtxt, btime)
234 recdb.rec_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
236 tv2mp4.ts2mp4(pin, pout, opt)
237 tv2mp4.raw2mp4(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mp4"),opt)
239 tv2mkv.raw2mkv(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mkv"),opt)
240 recdb.del_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime)
242 elif task["type"] == recdblist.REC_MKV_TO_MP4:
248 recdb.del_reckey(recdblist.REC_MKV_TO_MP4, title, chtxt, btime)
249 recdb.rec_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
250 tv2mp4.mkv2mp4(os.path.join(recpath,title+".mkv"),os.path.join(recpath,title+".mp4"))
251 recdb.del_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime)
254 def search_keyword(key):
255 tnow = datetime.datetime.now()
256 nows =tnow.strftime("%Y-%m-%d %H:%M:%S")
258 recdatum = epgdb.searchtime_auto(k,nows, "144")
259 for recdata in recdatum:
265 btt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
266 ett = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
267 btimet = btt.strftime("%Y-%m-%d %H:%M:%S")
268 etimet = ett.strftime("%Y-%m-%d %H:%M:%S")
269 if status.getSettings_auto_jbk()==1:
270 topt=status.getSettings_auto_opt()
274 maxnum=epgdb.count_schedule_timeline(btimet, etimet)[1]
275 maxnum=int(configreader.getenv("bscs_max"))-maxnum
277 maxnum=epgdb.count_schedule_timeline(btimet, etimet)[0]
278 maxnum=int(configreader.getenv("te_max"))-maxnum
280 topt=status.getSettings_auto_opt()
281 recdb.recreserv(titlet,chtxtt, btimet, etimet,topt)
282 except Exception, inst:
283 recdblist.Commonlogex("Error", "search_keyword_auto_jbk(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
286 recdb.add_auto_keyword(chtxtt, titlet, btimet, etimet)
287 except Exception, inst:
288 recdblist.Commonlogex("Error", "search_keyword(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
289 def type_reserve(typetxt,chtxt,title,bt,et,opt):
290 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
291 etime = et.strftime("%Y-%m-%d %H:%M:%S")
294 if typetxt==recdblist.REC_RESERVE:
295 typetxtfinal=recdblist.REC_FINAL_RESERVE
296 tnow = datetime.datetime.now()
298 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
299 if (dt < 58 * 60 and dt > 30 * 60):
300 bctypet = chdb.chtxtsearch(chtxt)['bctype']
301 chdatat = rec10d.rec10db.select_by_bctype_epg_ch(bctypet)
302 dt1 = datetime.datetime.strptime(chdatat[0][4], "%Y-%m-%d %H:%M:%S")-datetime.datetime.now()
303 dt1 = dt1.days * 24 * 60 * 60 + dt1.seconds
305 recdata = epgdb.searchtime2(title, btime, "5", chtxt)
313 bt = datetime.datetime.strptime(btimen, "%Y-%m-%d %H:%M:%S")
314 et = datetime.datetime.strptime(etimen, "%Y-%m-%d %H:%M:%S")
315 btimen = bt.strftime("%Y-%m-%d %H:%M:%S")
316 etimen = et.strftime("%Y-%m-%d %H:%M:%S")
319 recdb.del_reckey(typetxtnow, title, chtxt, btime)
320 recdb.rec_reckey(typetxtfinal, titlen, chtxtn, btimen, etimen, opt)
321 recdb.rec_reclog(titlen, chtxtn, btimen, etimen, opt, exp, longexp, category)
322 auto_rec.add_key(chtxt, titlen,exp+" "+longexp)
323 auto_rec.add_key("ALL", titlen,exp+" "+longexp)
324 recdblist.printutf8(u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen)
325 except Exception, inst:
326 recdblist.Commonlogex("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
328 recdblist.printutf8(u"追いかけ機能エラー:番組データが見付かりません。")
330 if rec10d.rec10db.select_by_bctype_epg_ch(bctypet)[0][5] != "0":
331 rec10d.rec10db.update_status_by_bctype_epg_ch(bctypet, "3")
333 elif (dt <= 30 * 60 and dt > 20 * 60):
334 recdata = epgdb.searchtime2(title, btime, "5", chtxt)
342 bt = datetime.datetime.strptime(btimen, "%Y-%m-%d %H:%M:%S")
343 et = datetime.datetime.strptime(etimen, "%Y-%m-%d %H:%M:%S")
344 btimen = bt.strftime("%Y-%m-%d %H:%M:%S")
345 etimen = et.strftime("%Y-%m-%d %H:%M:%S")
348 recdb.del_reckey(typetxtnow, title, chtxt, btime)
349 recdb.rec_reckey(typetxtfinal, titlen, chtxtn, btimen, etimen, opt)
350 recdb.rec_reclog(titlen, chtxtn, btimen, etimen, opt, exp, longexp, category)
351 auto_rec.add_key(chtxt, titlen,exp+" "+longexp)
352 auto_rec.add_key("ALL", titlen,exp+" "+longexp)
353 #recdblist.printutf8(u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen)
354 recdblist.Commonlogex(u"通常", "Oikake (timerec.py)",u"追いかけ機能実行中",u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen,log_level=500)
355 except Exception, inst:
356 recdblist.Commonlogex("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
359 recdb.del_reckey(typetxtnow, title, chtxt, btime)
360 recdb.rec_reckey(typetxtfinal, title, chtxt, btime, etime, opt)
361 except Exception, inst:
362 recdblist.Commonlogex("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
363 def type_final(typetxt,chtxt,title,bt,et,opt):
364 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
365 etime = et.strftime("%Y-%m-%d %H:%M:%S")
369 if typetxt==recdblist.REC_FINAL_RESERVE:
370 typetxting=recdblist.REC_TS_RECORDING
371 typetxtdecque=recdblist.REC_TS_DECODE_QUE
372 tnow = datetime.datetime.now()
374 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
375 if dt < 6 * 60 and dt > 0:
377 recdb.del_reckey(typetxtnow, title, chtxt, btime)
378 testpath=[os.path.join(recpath,title+".ts.b25")]
379 testpath.append(os.path.join(recpath,title+".ts"))
380 testpath.append(os.path.join(recpath,title+".avi"))
381 testpath.append(os.path.join(recpath,title+".mp4"))
382 testpath.append(os.path.join(recpath,title+".log"))
385 if os.path.exists(ti):
387 if re.search("N", opt) or tcheck>0:
390 iff=u"("+configreader.getenv("iff")+u")_"
394 newtitle=newtitle+u"_"+iff+newtime.strftime("%Y-%m-%dT%H-%M-%S")
395 recdb.rec_reckey(typetxting, newtitle, chtxt, btime, etime, opt)
396 recdblist.Commonlogex(u"通常","timerec.py",u"録画開始 "+newtitle+" "+btime+" "+etime,"",log_level=500)
397 tv2avi.timetv2b25(recpath + "/" + newtitle + ".avi", chtxt, btime, etime, opt)
398 recdb.del_reckey(typetxting, newtitle, chtxt, btime)
399 if not re.search("R", opt):
400 tnow = datetime.datetime.now()
401 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
402 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
404 bt = tnow + datetime.timedelta(seconds=600)
405 et = et + dt + datetime.timedelta(seconds=600)
406 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
407 etime = et.strftime("%Y-%m-%d %H:%M:%S")
408 recdb.rec_reckey(typetxtdecque, newtitle, chtxt, btime, etime, opt)
412 shutil.copy(os.path.join(recpath,title+".ts.b25"), os.path.join(movepath,title+".ts.b25"))
416 os.chmod(os.path.join(movepath,title+".ts.b25"),0777)
419 recque.writeRecQue(movepath, chtxt, title, opt)
421 os.chmod(os.path.join(movepath,title+".recq"),0777)
424 except Exception, inst:
425 recdblist.Commonlogex("Error", "Move option(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
426 recdb.rec_reckey(recdblist.REC_MOVE_END, newtitle, chtxt, btime, etime, opt)
428 def type_keyword(typetxt,chtxt,title,bt,et,opt,deltatime):
429 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
430 etime = et.strftime("%Y-%m-%d %H:%M:%S")
433 if typetxt==recdblist.REC_KEYWORD:
434 typetxtres=recdblist.REC_RESERVE
435 tnow = datetime.datetime.now()
437 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
438 recdblist.printutf8(str(dt), verbose_level=800)
440 recdata = epgdb.searchtime2(title, btime, deltatime, chtxt)
449 bt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
450 et = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
451 btimet = bt.strftime("%Y-%m-%d %H:%M:%S")
452 etimet = et.strftime("%Y-%m-%d %H:%M:%S")
454 recdb.del_reckey(typetxtnow, title, chtxt, btime)
455 recdb.rec_reckey(typetxtres, titlet, chtxtt, btimet, etimet, opt)
456 recdb.rec_reclog(titlet, chtxtt, btimet, etimet, opt, exp,longexp,category)
457 auto_rec.add_key(chtxt, titlet,exp+" "+longexp)
458 auto_rec.add_key("ALL", titlet,exp+" "+longexp)
459 recdblist.Commonlogex(u"通常","timerec.py",u"key "+title+u" : "+titlet+u" "+btimet+u" "+etimet,"",log_level=500)
460 #except Exception, inst:
461 # recdblist.printutf8("Error happened in REC_KEYWORD DB")
462 # recdblist.printutf8(type(inst))
463 # recdblist.printutf8(inst)
465 recdblist.printutf8("nothing match")
466 def type_keyword_every_day(type,chtxt,title,bt,et,opt,deltatime,deltaday,counter):
467 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
468 etime = et.strftime("%Y-%m-%d %H:%M:%S")
469 tnow = datetime.datetime.now()
471 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
472 dd = datetime.timedelta(days=int(deltaday))
474 recdb.del_reckey(recdblist.REC_KEYWORD_EVERY_SOME_DAYS, title, chtxt, btime)
477 btxt = bt.strftime("%Y-%m-%d %H:%M:%S")
478 etxt = et.strftime("%Y-%m-%d %H:%M:%S")
479 recdb.everyreserv(title, chtxt, btxt, etxt, deltatime, opt, deltaday)
481 recdb.del_reckey(recdblist.REC_KEYWORD_EVERY_SOME_DAYS, title, chtxt, btime)
484 btxt = bt.strftime("%Y-%m-%d %H:%M:%S")
485 etxt = et.strftime("%Y-%m-%d %H:%M:%S")
487 recdb.everyreserv(title, chtxt, btxt, etxt, deltatime, opt, deltaday,counter-1)
489 recdb.everyreserv(title, chtxt, btxt, etxt, deltatime, opt, deltaday,-1)
490 recdata = epgdb.searchtime2(title, btime, deltatime, chtxt)
499 bt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
500 et = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
501 btimet = bt.strftime("%Y-%m-%d %H:%M:%S")
502 etimet = et.strftime("%Y-%m-%d %H:%M:%S")
504 recdb.keyreserv(titlet, chtxtt, btimet, etimet, deltatime, opt)
506 recdb.keyreserv(title, chtxt, btime, etime, deltatime, opt)
507 def type_decode_que(typetxt,chtxt,title,bt,et,opt):
508 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
509 etime = et.strftime("%Y-%m-%d %H:%M:%S")
510 tnow = datetime.datetime.now()
512 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
517 if typetxt== recdblist.REC_TS_DECODE_QUE:
518 typetxting=recdblist.REC_TS_DECODING
519 typetxtmiss=recdblist.REC_MISS_DECODE
520 typetxtencque=recdblist.REC_ENCODE_QUE
521 tnow = datetime.datetime.now()
523 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
525 if status.getB25Decoding() < 2:
526 pin = recpath + "/" + title
527 recdb.del_reckey(typetxtnow, title, chtxt, btime)
528 recdb.rec_reckey(typetxting, title, chtxt, btime, etime, opt)
529 tv2avi.b252ts(pin, chtxt, btime, etime, opt)
530 recdb.del_reckey(typetxting, title, chtxt, btime)
531 if not os.access(recpath + "/" + title + ".ts", os.F_OK):
532 recdb.del_reckey(typetxting, title, chtxt, btime)
533 recdb.rec_reckey(typetxtmiss, title, chtxt, btime, etime, opt)
535 auto_process.deltmpfile(recpath, title, ".ts")
536 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
537 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
539 if not re.search("D", opt):
540 tnow = datetime.datetime.now()
541 bt = tnow + datetime.timedelta(seconds=600)
543 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
544 etime = et.strftime("%Y-%m-%d %H:%M:%S")
545 recdb.rec_reckey(typetxtencque, title, chtxt, btime, etime, opt)
549 shutil.copy(os.path.join(recpath,title+".ts"), os.path.join(movepath,title+".ts"))
553 os.chmod(os.path.join(movepath,title+".ts"),0777)
556 recque.writeRecQue(movepath, chtxt, title, opt)
558 os.chmod(os.path.join(movepath,title+".recq"),0777)
562 if os.path.getsize(os.path.join(recpath,title+".ts"))==os.path.getsize(os.path.join(movepath,title+".ts")):
563 os.remove(os.path.join(recpath,title+".ts"))
564 except Exception, inst:
565 errtxt1="move ts error.\n"
566 errtxt2=str(type(inst))+"\n"
567 errtxt2=errtxt2+str(inst)
568 recdblist.Commonlogex("Error", "type_decode_que(timerec.py)", errtxt1,errtxt2+traceback.format_exc(),log_level=200)
569 recdb.rec_reckey(recdblist.REC_MOVE_END, title, chtxt, btime, etime, opt)
571 recdb.del_reckey(typetxtnow, title, chtxt, btime)
572 bt = bt + datetime.timedelta(seconds=600)
573 et = et + datetime.timedelta(seconds=600)
574 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
575 etime = et.strftime("%Y-%m-%d %H:%M:%S")
576 recdb.rec_reckey(typetxtnow, title, chtxt, btime, etime, opt)
579 def type_encode_que(typetxt,chtxt,title,bt,et,opt):
580 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
581 etime = et.strftime("%Y-%m-%d %H:%M:%S")
582 tnow = datetime.datetime.now()
584 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
588 if typetxt==recdblist.REC_ENCODE_QUE:
589 typetxting=recdblist.REC_ENCODE_LOCAL
590 typetxtfin=recdblist.REC_FIN_LOCAL
592 if status.getEncoding() < int(configreader.getenv("enc_max")):
593 recdb.del_reckey(typetxtnow, title, chtxt, btime)
594 recdb.rec_reckey(typetxting, title, chtxt, btime, etime, opt)
595 recdblist.printutf8(opt)
596 pin = recpath + "/" + title + ".ts"
597 if re.search("d", opt):
598 pin = recpath + "/" + title + ".m2v"
599 if not os.path.exists(pin) or os.path.getsize(pin)<100*1000:
600 paac2 = recpath + "/" + title + "_2.aac"
601 pmp32 = recpath + "/" + title + "_2.mp3"
602 if not os.path.exists(paac2) and not os.path.exists(pmp32):
603 tv2audio.ts2dualaudio_BonTsDemux(os.path.join(recpath, title+".ts"),recdblist.BONTSDEMUX_DELAY,opt)
605 elif re.search("5", opt):
606 pin = recpath + "/" + title + ".m2v"
607 if not os.path.exists(pin) or os.path.getsize(pin)<100*1000:
608 paac2 = recpath + "/" + title + "_2.aac"
609 pmp32 = recpath + "/" + title + "_2.mp3"
610 if not os.path.exists(paac2) and not os.path.exists(pmp32):
611 tv2audio.ts2pentaaudio_BonTsDemux(os.path.join(recpath, title+".ts"), recdblist.BONTSDEMUX_DELAY, opt)
615 if configreader.getenv("make_mp4")=="1":
619 if re.search("m", opt):
621 if re.search("4", opt):
623 recdblist.printutf8(pin)
624 if not re.search("0", opt):
626 pout = recpath + "/" + title + ".mp4"
627 tv2mp4.ts2mp4(pin, pout, opt)
629 pout = recpath + "/" + title + ".mkv"
630 tv2mkv.ts2mkv(pin, pout, opt)
631 if re.search("8", opt) or re.search("9", opt):
633 optt=optt.replace("8","MW8")
634 optt=optt.replace("9","MW9")
635 poutt = recpath + "/" + "m_"+title + ".mp4"
636 if re.search("d", opt) or re.search("5", opt):
637 if os.path.exists(os.path.join(recpath, "m_"+title+".m2v")):
638 shutil.move(os.path.join(recpath, title+".m2v"),os.path.join(recpath, "m_"+title+".m2v"))
639 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.aac")):
640 shutil.move(os.path.join(recpath, title+"_1.aac"),os.path.join(recpath, "m_"+title+"_1.aac"))
641 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.mp3")):
642 shutil.move(os.path.join(recpath, title+"_1.mp3"),os.path.join(recpath, "m_"+title+"_1.mp3"))
643 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.aac")):
644 shutil.move(os.path.join(recpath, title+"_2.aac"),os.path.join(recpath, "m_"+title+"_2.aac"))
645 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.mp3")):
646 shutil.move(os.path.join(recpath, title+"_2.mp3"),os.path.join(recpath, "m_"+title+"_2.mp3"))
647 shutil.move(os.path.join(recpath, title+".ts"),os.path.join(recpath, "m_"+title+".ts"))
648 tv2mp4.ts2mp4(os.path.join(recpath, "m_"+title+".ts"), poutt, optt)
649 shutil.move(os.path.join(recpath, "m_"+title+".ts"),os.path.join(recpath, title+".ts"))
652 optt=optt.replace("8","MW8")
653 optt=optt.replace("9","MW9")
654 poutt = recpath + "/" + "m_"+title + ".mp4"
655 shutil.move(os.path.join(recpath, title+".ts"),os.path.join(recpath, "m_"+title+".ts"))
656 if re.search("d", opt) or re.search("5", opt):
657 if os.path.exists(os.path.join(recpath, "m_"+title+".m2v")):
658 shutil.move(os.path.join(recpath, title+".m2v"),os.path.join(recpath, "m_"+title+".m2v"))
659 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.aac")):
660 shutil.move(os.path.join(recpath, title+"_1.aac"),os.path.join(recpath, "m_"+title+"_1.aac"))
661 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.mp3")):
662 shutil.move(os.path.join(recpath, title+"_1.mp3"),os.path.join(recpath, "m_"+title+"_1.mp3"))
663 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.aac")):
664 shutil.move(os.path.join(recpath, title+"_2.aac"),os.path.join(recpath, "m_"+title+"_2.aac"))
665 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.mp3")):
666 shutil.move(os.path.join(recpath, title+"_2.mp3"),os.path.join(recpath, "m_"+title+"_2.mp3"))
667 tv2mp4.ts2mp4(os.path.join(recpath, "m_"+title+".ts"), poutt, optt)
668 shutil.move(os.path.join(recpath, "m_"+title+".ts"),os.path.join(recpath, title+".ts"))
669 recdb.del_reckey(typetxting, title, chtxt, btime)
671 if re.search("E", opt):
673 if os.path.exists(os.path.join(recpath,title+".mp4")):
675 shutil.copy(os.path.join(recpath,title+".mp4"), os.path.join(movepath,title+".mp4"))
679 os.chmod(os.path.join(movepath,title+".mp4"),0777)
682 recque.writeRecQue(movepath, chtxt, title, opt)
684 os.chmod(os.path.join(movepath,title+".recq"),0777)
687 elif os.path.exists(os.path.join(recpath,title+".mkv")):
689 shutil.copy(os.path.join(recpath,title+".mkv"), os.path.join(movepath,title+".mkv"))
693 os.chmod(os.path.join(movepath,title+".mkv"),0777)
696 recque.writeRecQue(movepath, chtxt, title, opt)
698 os.chmod(os.path.join(movepath,title+".recq"),0777)
701 except Exception, inst:
702 errtxt1="move mkv/mp4 error."
703 errtxt2=str(type(inst))+"\n"
704 errtxt2=errtxt2+str(inst)
705 recdblist.Commonlogex("Error", "type_encode_que(timerec.py)", errtxt1,errtxt2+traceback.format_exc(),log_level=200)
706 recdb.rec_reckey(recdblist.REC_MOVE_END, title, chtxt, btime, etime, opt)
707 recdb.rec_reckey(typetxtfin, title, chtxt, btime, etime, opt)
710 recdb.del_reckey(typetxtnow, title, chtxt, btime)
711 bt = bt + datetime.timedelta(seconds=600)
712 et = et + datetime.timedelta(seconds=600)
713 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
714 etime = et.strftime("%Y-%m-%d %H:%M:%S")
715 recdb.rec_reckey(typetxtnow, title, chtxt, btime, etime, opt)