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 for k,auto,opt in key:
259 recdatum = epgdb.searchtime_auto(k,nows, "144")
260 for recdata in recdatum:
266 btt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
267 ett = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
268 btimet = btt.strftime("%Y-%m-%d %H:%M:%S")
269 etimet = ett.strftime("%Y-%m-%d %H:%M:%S")
270 #if status.getSettings_auto_jbk()==1:
271 if auto==1 or status.getSettings_auto_jbk()==1:
274 topt=status.getSettings_auto_opt()
278 maxnum=epgdb.count_schedule_timeline(btimet, etimet)[1]
279 maxnum=int(configreader.getenv("bscs_max"))-maxnum
281 maxnum=epgdb.count_schedule_timeline(btimet, etimet)[0]
282 maxnum=int(configreader.getenv("te_max"))-maxnum
284 if recdb.checkduplicate(titlet, chtxtt, btimet, etimet)==0:
285 recdb.recreserv(titlet,chtxtt, btimet, etimet,topt)
286 except Exception, inst:
287 recdblist.Commonlogex("Error", "search_keyword_auto_jbk(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
290 recdb.add_auto_keyword(chtxtt, titlet, btimet, etimet)
291 except Exception, inst:
292 recdblist.Commonlogex("Error", "search_keyword(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
293 def type_reserve(typetxt,chtxt,title,bt,et,opt):
294 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
295 etime = et.strftime("%Y-%m-%d %H:%M:%S")
298 if typetxt==recdblist.REC_RESERVE:
299 typetxtfinal=recdblist.REC_FINAL_RESERVE
300 tnow = datetime.datetime.now()
302 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
303 if (dt < 58 * 60 and dt > 30 * 60):
304 bctypet = chdb.chtxtsearch(chtxt)['bctype']
305 chdatat = rec10d.rec10db.select_by_bctype_epg_ch(bctypet)
306 dt1 = datetime.datetime.strptime(chdatat[0][4], "%Y-%m-%d %H:%M:%S")-datetime.datetime.now()
307 dt1 = dt1.days * 24 * 60 * 60 + dt1.seconds
309 recdata = epgdb.searchtime2(title, btime, "5", chtxt)
317 bt = datetime.datetime.strptime(btimen, "%Y-%m-%d %H:%M:%S")
318 et = datetime.datetime.strptime(etimen, "%Y-%m-%d %H:%M:%S")
319 btimen = bt.strftime("%Y-%m-%d %H:%M:%S")
320 etimen = et.strftime("%Y-%m-%d %H:%M:%S")
323 recdb.del_reckey(typetxtnow, title, chtxt, btime)
324 recdb.rec_reckey(typetxtfinal, titlen, chtxtn, btimen, etimen, opt)
325 recdb.rec_reclog(titlen, chtxtn, btimen, etimen, opt, exp, longexp, category)
326 auto_rec.add_key(chtxt, titlen,exp+" "+longexp)
327 auto_rec.add_key("ALL", titlen,exp+" "+longexp)
328 recdblist.printutf8(u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen)
329 except Exception, inst:
330 recdblist.Commonlogex("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
332 recdblist.printutf8(u"追いかけ機能エラー:番組データが見付かりません。")
334 if rec10d.rec10db.select_by_bctype_epg_ch(bctypet)[0][5] != "0":
335 rec10d.rec10db.update_status_by_bctype_epg_ch(bctypet, "3")
337 elif (dt <= 30 * 60 and dt > 20 * 60):
338 recdata = epgdb.searchtime2(title, btime, "5", chtxt)
346 bt = datetime.datetime.strptime(btimen, "%Y-%m-%d %H:%M:%S")
347 et = datetime.datetime.strptime(etimen, "%Y-%m-%d %H:%M:%S")
348 btimen = bt.strftime("%Y-%m-%d %H:%M:%S")
349 etimen = et.strftime("%Y-%m-%d %H:%M:%S")
352 recdb.del_reckey(typetxtnow, title, chtxt, btime)
353 recdb.rec_reckey(typetxtfinal, titlen, chtxtn, btimen, etimen, opt)
354 recdb.rec_reclog(titlen, chtxtn, btimen, etimen, opt, exp, longexp, category)
355 auto_rec.add_key(chtxt, titlen,exp+" "+longexp)
356 auto_rec.add_key("ALL", titlen,exp+" "+longexp)
357 #recdblist.printutf8(u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen)
358 recdblist.Commonlogex(u"通常", "Oikake (timerec.py)",u"追いかけ機能実行中",u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen,log_level=500)
359 except Exception, inst:
360 recdblist.Commonlogex("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
363 recdb.del_reckey(typetxtnow, title, chtxt, btime)
364 recdb.rec_reckey(typetxtfinal, title, chtxt, btime, etime, opt)
365 except Exception, inst:
366 recdblist.Commonlogex("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
367 def type_final(typetxt,chtxt,title,bt,et,opt):
368 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
369 etime = et.strftime("%Y-%m-%d %H:%M:%S")
373 if typetxt==recdblist.REC_FINAL_RESERVE:
374 typetxting=recdblist.REC_TS_RECORDING
375 typetxtdecque=recdblist.REC_TS_DECODE_QUE
376 tnow = datetime.datetime.now()
378 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
379 if dt < 6 * 60 and dt > 0:
381 recdb.del_reckey(typetxtnow, title, chtxt, btime)
382 testpath=[os.path.join(recpath,title+".ts.b25")]
383 testpath.append(os.path.join(recpath,title+".ts"))
384 testpath.append(os.path.join(recpath,title+".avi"))
385 testpath.append(os.path.join(recpath,title+".mp4"))
386 testpath.append(os.path.join(recpath,title+".log"))
389 if os.path.exists(ti):
391 if re.search("N", opt) or tcheck>0:
394 iff=u"("+configreader.getenv("iff")+u")_"
398 newtitle=newtitle+u"_"+iff+newtime.strftime("%Y-%m-%dT%H-%M-%S")
399 recdb.rec_reckey(typetxting, newtitle, chtxt, btime, etime, opt)
400 recdblist.Commonlogex(u"通常","timerec.py",u"録画開始 "+newtitle+" "+btime+" "+etime,"",log_level=500)
401 tv2avi.timetv2b25(recpath + "/" + newtitle + ".avi", chtxt, btime, etime, opt)
402 recdb.del_reckey(typetxting, newtitle, chtxt, btime)
403 if not re.search("R", opt):
404 tnow = datetime.datetime.now()
405 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
406 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
408 bt = tnow + datetime.timedelta(seconds=600)
409 et = et + dt + datetime.timedelta(seconds=600)
410 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
411 etime = et.strftime("%Y-%m-%d %H:%M:%S")
412 recdb.rec_reckey(typetxtdecque, newtitle, chtxt, btime, etime, opt)
416 shutil.copy(os.path.join(recpath,title+".ts.b25"), os.path.join(movepath,title+".ts.b25"))
420 os.chmod(os.path.join(movepath,title+".ts.b25"),0777)
423 recque.writeRecQue(movepath, chtxt, title, opt)
425 os.chmod(os.path.join(movepath,title+".recq"),0777)
428 except Exception, inst:
429 recdblist.Commonlogex("Error", "Move option(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
430 recdb.rec_reckey(recdblist.REC_MOVE_END, newtitle, chtxt, btime, etime, opt)
432 def type_keyword(typetxt,chtxt,title,bt,et,opt,deltatime):
433 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
434 etime = et.strftime("%Y-%m-%d %H:%M:%S")
437 if typetxt==recdblist.REC_KEYWORD:
438 typetxtres=recdblist.REC_RESERVE
439 tnow = datetime.datetime.now()
441 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
442 recdblist.printutf8(str(dt), verbose_level=800)
444 recdata = epgdb.searchtime2(title, btime, deltatime, chtxt)
453 bt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
454 et = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
455 btimet = bt.strftime("%Y-%m-%d %H:%M:%S")
456 etimet = et.strftime("%Y-%m-%d %H:%M:%S")
458 recdb.del_reckey(typetxtnow, title, chtxt, btime)
459 recdb.rec_reckey(typetxtres, titlet, chtxtt, btimet, etimet, opt)
460 recdb.rec_reclog(titlet, chtxtt, btimet, etimet, opt, exp,longexp,category)
461 auto_rec.add_key(chtxt, titlet,exp+" "+longexp)
462 auto_rec.add_key("ALL", titlet,exp+" "+longexp)
463 recdblist.Commonlogex(u"通常","timerec.py",u"key "+title+u" : "+titlet+u" "+btimet+u" "+etimet,"",log_level=500)
464 #except Exception, inst:
465 # recdblist.printutf8("Error happened in REC_KEYWORD DB")
466 # recdblist.printutf8(type(inst))
467 # recdblist.printutf8(inst)
469 recdblist.printutf8("nothing match")
470 def type_keyword_every_day(type,chtxt,title,bt,et,opt,deltatime,deltaday,counter):
471 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
472 etime = et.strftime("%Y-%m-%d %H:%M:%S")
473 tnow = datetime.datetime.now()
475 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
476 dd = datetime.timedelta(days=int(deltaday))
478 recdb.del_reckey(recdblist.REC_KEYWORD_EVERY_SOME_DAYS, title, chtxt, btime)
481 btxt = bt.strftime("%Y-%m-%d %H:%M:%S")
482 etxt = et.strftime("%Y-%m-%d %H:%M:%S")
483 recdb.everyreserv(title, chtxt, btxt, etxt, deltatime, opt, deltaday)
485 recdb.del_reckey(recdblist.REC_KEYWORD_EVERY_SOME_DAYS, title, chtxt, btime)
488 btxt = bt.strftime("%Y-%m-%d %H:%M:%S")
489 etxt = et.strftime("%Y-%m-%d %H:%M:%S")
491 recdb.everyreserv(title, chtxt, btxt, etxt, deltatime, opt, deltaday,counter-1)
493 recdb.everyreserv(title, chtxt, btxt, etxt, deltatime, opt, deltaday,-1)
494 recdata = epgdb.searchtime2(title, btime, deltatime, chtxt)
503 bt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
504 et = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
505 btimet = bt.strftime("%Y-%m-%d %H:%M:%S")
506 etimet = et.strftime("%Y-%m-%d %H:%M:%S")
508 recdb.keyreserv(titlet, chtxtt, btimet, etimet, deltatime, opt)
510 recdb.keyreserv(title, chtxt, btime, etime, deltatime, opt)
511 def type_decode_que(typetxt,chtxt,title,bt,et,opt):
512 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
513 etime = et.strftime("%Y-%m-%d %H:%M:%S")
514 tnow = datetime.datetime.now()
516 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
521 if typetxt== recdblist.REC_TS_DECODE_QUE:
522 typetxting=recdblist.REC_TS_DECODING
523 typetxtmiss=recdblist.REC_MISS_DECODE
524 typetxtencque=recdblist.REC_ENCODE_QUE
525 tnow = datetime.datetime.now()
527 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
529 if status.getB25Decoding() < 2:
530 pin = recpath + "/" + title
531 recdb.del_reckey(typetxtnow, title, chtxt, btime)
532 recdb.rec_reckey(typetxting, title, chtxt, btime, etime, opt)
533 tv2avi.b252ts(pin, chtxt, btime, etime, opt)
534 recdb.del_reckey(typetxting, title, chtxt, btime)
535 if not os.access(recpath + "/" + title + ".ts", os.F_OK):
536 recdb.del_reckey(typetxting, title, chtxt, btime)
537 recdb.rec_reckey(typetxtmiss, title, chtxt, btime, etime, opt)
539 auto_process.deltmpfile(recpath, title, ".ts")
540 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
541 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
543 if not re.search("D", opt):
544 tnow = datetime.datetime.now()
545 bt = tnow + datetime.timedelta(seconds=600)
547 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
548 etime = et.strftime("%Y-%m-%d %H:%M:%S")
549 recdb.rec_reckey(typetxtencque, title, chtxt, btime, etime, opt)
553 shutil.copy(os.path.join(recpath,title+".ts"), os.path.join(movepath,title+".ts"))
557 os.chmod(os.path.join(movepath,title+".ts"),0777)
560 recque.writeRecQue(movepath, chtxt, title, opt)
562 os.chmod(os.path.join(movepath,title+".recq"),0777)
566 if os.path.getsize(os.path.join(recpath,title+".ts"))==os.path.getsize(os.path.join(movepath,title+".ts")):
567 os.remove(os.path.join(recpath,title+".ts"))
568 except Exception, inst:
569 errtxt1="move ts error.\n"
570 errtxt2=str(type(inst))+"\n"
571 errtxt2=errtxt2+str(inst)
572 recdblist.Commonlogex("Error", "type_decode_que(timerec.py)", errtxt1,errtxt2+traceback.format_exc(),log_level=200)
573 recdb.rec_reckey(recdblist.REC_MOVE_END, title, chtxt, btime, etime, opt)
575 recdb.del_reckey(typetxtnow, title, chtxt, btime)
576 bt = bt + datetime.timedelta(seconds=600)
577 et = et + datetime.timedelta(seconds=600)
578 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
579 etime = et.strftime("%Y-%m-%d %H:%M:%S")
580 recdb.rec_reckey(typetxtnow, title, chtxt, btime, etime, opt)
583 def type_encode_que(typetxt,chtxt,title,bt,et,opt):
584 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
585 etime = et.strftime("%Y-%m-%d %H:%M:%S")
586 tnow = datetime.datetime.now()
588 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
592 if typetxt==recdblist.REC_ENCODE_QUE:
593 typetxting=recdblist.REC_ENCODE_LOCAL
594 typetxtfin=recdblist.REC_FIN_LOCAL
596 if status.getEncoding() < int(configreader.getenv("enc_max")):
597 recdb.del_reckey(typetxtnow, title, chtxt, btime)
598 recdb.rec_reckey(typetxting, title, chtxt, btime, etime, opt)
599 recdblist.printutf8(opt)
600 pin = recpath + "/" + title + ".ts"
601 if re.search("d", opt):
602 pin = recpath + "/" + title + ".m2v"
603 if not os.path.exists(pin) or os.path.getsize(pin)<100*1000:
604 paac2 = recpath + "/" + title + "_2.aac"
605 pmp32 = recpath + "/" + title + "_2.mp3"
606 if not os.path.exists(paac2) and not os.path.exists(pmp32):
607 tv2audio.ts2dualaudio_BonTsDemux(os.path.join(recpath, title+".ts"),recdblist.BONTSDEMUX_DELAY,opt)
609 elif re.search("5", opt):
610 pin = recpath + "/" + title + ".m2v"
611 if not os.path.exists(pin) or os.path.getsize(pin)<100*1000:
612 paac2 = recpath + "/" + title + "_2.aac"
613 pmp32 = recpath + "/" + title + "_2.mp3"
614 if not os.path.exists(paac2) and not os.path.exists(pmp32):
615 tv2audio.ts2pentaaudio_BonTsDemux(os.path.join(recpath, title+".ts"), recdblist.BONTSDEMUX_DELAY, opt)
619 if configreader.getenv("make_mp4")=="1":
623 if re.search("m", opt):
625 if re.search("4", opt):
627 recdblist.printutf8(pin)
628 if not re.search("0", opt):
630 pout = recpath + "/" + title + ".mp4"
631 tv2mp4.ts2mp4(pin, pout, opt)
633 pout = recpath + "/" + title + ".mkv"
634 tv2mkv.ts2mkv(pin, pout, opt)
635 if re.search("8", opt) or re.search("9", opt):
637 poutt = recpath + "/" + "m_"+title + ".mp4"
638 if re.search("d", opt) or re.search("5", opt):
639 if os.path.exists(os.path.join(recpath, "m_"+title+".m2v")):
640 shutil.move(os.path.join(recpath, title+".m2v"),os.path.join(recpath, "m_"+title+".m2v"))
641 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.aac")):
642 shutil.move(os.path.join(recpath, title+"_1.aac"),os.path.join(recpath, "m_"+title+"_1.aac"))
643 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.mp3")):
644 shutil.move(os.path.join(recpath, title+"_1.mp3"),os.path.join(recpath, "m_"+title+"_1.mp3"))
645 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.aac")):
646 shutil.move(os.path.join(recpath, title+"_2.aac"),os.path.join(recpath, "m_"+title+"_2.aac"))
647 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.mp3")):
648 shutil.move(os.path.join(recpath, title+"_2.mp3"),os.path.join(recpath, "m_"+title+"_2.mp3"))
649 shutil.move(os.path.join(recpath, title+".ts"),os.path.join(recpath, "m_"+title+".ts"))
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"))
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)