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")
260 for k,auto,opt in key:
261 recdatum = epgdb.searchtime_auto(k,nows, "144")
262 for recdata in recdatum:
268 btt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
269 ett = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
270 btimet = btt.strftime("%Y-%m-%d %H:%M:%S")
271 etimet = ett.strftime("%Y-%m-%d %H:%M:%S")
272 #if status.getSettings_auto_jbk()==1:
273 if auto==1 or status.getSettings_auto_jbk()==1:
276 topt=status.getSettings_auto_opt()
280 maxnum=epgdb.count_schedule_timeline(btimet, etimet)[1]
281 maxnum=int(configreader.getenv("bscs_max"))-maxnum
283 maxnum=epgdb.count_schedule_timeline(btimet, etimet)[0]
284 maxnum=int(configreader.getenv("te_max"))-maxnum
286 if recdb.checkduplicate(titlet, chtxtt, btimet, etimet)==0:
287 recdb.recreserv(titlet,chtxtt, btimet, etimet,topt)
288 except Exception, inst:
289 recdblist.Commonlogex("Error", "search_keyword_auto_jbk(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
292 recdb.add_auto_keyword(chtxtt, titlet, btimet, etimet)
293 except Exception, inst:
294 recdblist.Commonlogex("Error", "search_keyword(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
295 def type_reserve(typetxt,chtxt,title,bt,et,opt):
296 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
297 etime = et.strftime("%Y-%m-%d %H:%M:%S")
300 if typetxt==recdblist.REC_RESERVE:
301 typetxtfinal=recdblist.REC_FINAL_RESERVE
302 tnow = datetime.datetime.now()
304 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
305 if (dt < 58 * 60 and dt > 30 * 60):
306 bctypet = chdb.chtxtsearch(chtxt)['bctype']
307 chdatat = rec10d.rec10db.select_by_bctype_epg_ch(bctypet)
308 dt1 = datetime.datetime.strptime(chdatat[0][4], "%Y-%m-%d %H:%M:%S")-datetime.datetime.now()
309 dt1 = dt1.days * 24 * 60 * 60 + dt1.seconds
311 recdata = epgdb.searchtime2(title, btime, "5", chtxt)
319 bt = datetime.datetime.strptime(btimen, "%Y-%m-%d %H:%M:%S")
320 et = datetime.datetime.strptime(etimen, "%Y-%m-%d %H:%M:%S")
321 btimen = bt.strftime("%Y-%m-%d %H:%M:%S")
322 etimen = et.strftime("%Y-%m-%d %H:%M:%S")
325 recdb.del_reckey(typetxtnow, title, chtxt, btime)
326 recdb.rec_reckey(typetxtfinal, titlen, chtxtn, btimen, etimen, opt)
327 recdb.rec_reclog(titlen, chtxtn, btimen, etimen, opt, exp, longexp, category)
328 auto_rec.add_key(chtxt, titlen,exp+" "+longexp)
329 auto_rec.add_key("ALL", titlen,exp+" "+longexp)
330 recdblist.printutf8(u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen)
331 except Exception, inst:
332 recdblist.Commonlogex("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
334 recdblist.printutf8(u"追いかけ機能エラー:番組データが見付かりません。")
336 if rec10d.rec10db.select_by_bctype_epg_ch(bctypet)[0][5] != "0":
337 rec10d.rec10db.update_status_by_bctype_epg_ch(bctypet, "3")
339 elif (dt <= 30 * 60 and dt > 20 * 60):
340 recdata = epgdb.searchtime2(title, btime, "5", chtxt)
348 bt = datetime.datetime.strptime(btimen, "%Y-%m-%d %H:%M:%S")
349 et = datetime.datetime.strptime(etimen, "%Y-%m-%d %H:%M:%S")
350 btimen = bt.strftime("%Y-%m-%d %H:%M:%S")
351 etimen = et.strftime("%Y-%m-%d %H:%M:%S")
354 recdb.del_reckey(typetxtnow, title, chtxt, btime)
355 recdb.rec_reckey(typetxtfinal, titlen, chtxtn, btimen, etimen, opt)
356 recdb.rec_reclog(titlen, chtxtn, btimen, etimen, opt, exp, longexp, category)
357 auto_rec.add_key(chtxt, titlen,exp+" "+longexp)
358 auto_rec.add_key("ALL", titlen,exp+" "+longexp)
359 #recdblist.printutf8(u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen)
360 recdblist.Commonlogex(u"通常", "Oikake (timerec.py)",u"追いかけ機能実行中",u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen,log_level=500)
361 except Exception, inst:
362 recdblist.Commonlogex("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
365 recdb.del_reckey(typetxtnow, title, chtxt, btime)
366 recdb.rec_reckey(typetxtfinal, title, chtxt, btime, etime, opt)
367 except Exception, inst:
368 recdblist.Commonlogex("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
369 def type_final(typetxt,chtxt,title,bt,et,opt):
370 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
371 etime = et.strftime("%Y-%m-%d %H:%M:%S")
375 if typetxt==recdblist.REC_FINAL_RESERVE:
376 typetxting=recdblist.REC_TS_RECORDING
377 typetxtdecque=recdblist.REC_TS_DECODE_QUE
378 tnow = datetime.datetime.now()
380 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
381 if dt < 6 * 60 and dt > 0:
383 recdb.del_reckey(typetxtnow, title, chtxt, btime)
384 testpath=[os.path.join(recpath,title+".ts.b25")]
385 testpath.append(os.path.join(recpath,title+".ts"))
386 testpath.append(os.path.join(recpath,title+".avi"))
387 testpath.append(os.path.join(recpath,title+".mp4"))
388 testpath.append(os.path.join(recpath,title+".log"))
391 if os.path.exists(ti):
393 if re.search("N", opt) or tcheck>0:
396 iff=u"("+configreader.getenv("iff")+u")_"
400 newtitle=newtitle+u"_"+iff+newtime.strftime("%Y-%m-%dT%H-%M-%S")
401 recdb.rec_reckey(typetxting, newtitle, chtxt, btime, etime, opt)
402 recdblist.Commonlogex(u"通常","timerec.py",u"録画開始 "+newtitle+" "+btime+" "+etime,"",log_level=500)
403 tv2avi.timetv2b25(recpath + "/" + newtitle + ".avi", chtxt, btime, etime, opt)
404 recdb.del_reckey(typetxting, newtitle, chtxt, btime)
405 if not re.search("R", opt):
406 tnow = datetime.datetime.now()
407 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
408 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
410 bt = tnow + datetime.timedelta(seconds=600)
411 et = et + dt + datetime.timedelta(seconds=600)
412 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
413 etime = et.strftime("%Y-%m-%d %H:%M:%S")
414 recdb.rec_reckey(typetxtdecque, newtitle, chtxt, btime, etime, opt)
418 shutil.copy(os.path.join(recpath,title+".ts.b25"), os.path.join(movepath,title+".ts.b25"))
422 os.chmod(os.path.join(movepath,title+".ts.b25"),0777)
425 recque.writeRecQue(movepath, chtxt, title, opt)
427 os.chmod(os.path.join(movepath,title+".recq"),0777)
430 except Exception, inst:
431 recdblist.Commonlogex("Error", "Move option(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
432 recdb.rec_reckey(recdblist.REC_MOVE_END, newtitle, chtxt, btime, etime, opt)
434 def type_keyword(typetxt,chtxt,title,bt,et,opt,deltatime):
435 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
436 etime = et.strftime("%Y-%m-%d %H:%M:%S")
439 if typetxt==recdblist.REC_KEYWORD:
440 typetxtres=recdblist.REC_RESERVE
441 tnow = datetime.datetime.now()
443 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
444 recdblist.printutf8(str(dt), verbose_level=800)
446 recdata = epgdb.searchtime2(title, btime, deltatime, chtxt)
455 bt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
456 et = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
457 btimet = bt.strftime("%Y-%m-%d %H:%M:%S")
458 etimet = et.strftime("%Y-%m-%d %H:%M:%S")
460 recdb.del_reckey(typetxtnow, title, chtxt, btime)
461 recdb.rec_reckey(typetxtres, titlet, chtxtt, btimet, etimet, opt)
462 recdb.rec_reclog(titlet, chtxtt, btimet, etimet, opt, exp,longexp,category)
463 auto_rec.add_key(chtxt, titlet,exp+" "+longexp)
464 auto_rec.add_key("ALL", titlet,exp+" "+longexp)
465 recdblist.Commonlogex(u"通常","timerec.py",u"key "+title+u" : "+titlet+u" "+btimet+u" "+etimet,"",log_level=500)
466 #except Exception, inst:
467 # recdblist.printutf8("Error happened in REC_KEYWORD DB")
468 # recdblist.printutf8(type(inst))
469 # recdblist.printutf8(inst)
471 recdblist.printutf8("nothing match")
472 def type_keyword_every_day(type,chtxt,title,bt,et,opt,deltatime,deltaday,counter):
473 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
474 etime = et.strftime("%Y-%m-%d %H:%M:%S")
475 tnow = datetime.datetime.now()
477 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
478 dd = datetime.timedelta(days=int(deltaday))
480 recdb.del_reckey(recdblist.REC_KEYWORD_EVERY_SOME_DAYS, title, chtxt, btime)
483 btxt = bt.strftime("%Y-%m-%d %H:%M:%S")
484 etxt = et.strftime("%Y-%m-%d %H:%M:%S")
485 recdb.everyreserv(title, chtxt, btxt, etxt, deltatime, opt, deltaday)
487 recdb.del_reckey(recdblist.REC_KEYWORD_EVERY_SOME_DAYS, title, chtxt, btime)
490 btxt = bt.strftime("%Y-%m-%d %H:%M:%S")
491 etxt = et.strftime("%Y-%m-%d %H:%M:%S")
493 recdb.everyreserv(title, chtxt, btxt, etxt, deltatime, opt, deltaday,counter-1)
495 recdb.everyreserv(title, chtxt, btxt, etxt, deltatime, opt, deltaday,-1)
496 recdata = epgdb.searchtime2(title, btime, deltatime, chtxt)
505 bt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
506 et = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
507 btimet = bt.strftime("%Y-%m-%d %H:%M:%S")
508 etimet = et.strftime("%Y-%m-%d %H:%M:%S")
510 recdb.keyreserv(titlet, chtxtt, btimet, etimet, deltatime, opt)
512 recdb.keyreserv(title, chtxt, btime, etime, deltatime, opt)
513 def type_decode_que(typetxt,chtxt,title,bt,et,opt):
514 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
515 etime = et.strftime("%Y-%m-%d %H:%M:%S")
516 tnow = datetime.datetime.now()
518 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
523 if typetxt== recdblist.REC_TS_DECODE_QUE:
524 typetxting=recdblist.REC_TS_DECODING
525 typetxtmiss=recdblist.REC_MISS_DECODE
526 typetxtencque=recdblist.REC_ENCODE_QUE
527 tnow = datetime.datetime.now()
529 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
531 if status.getB25Decoding() < 2:
532 pin = recpath + "/" + title
533 recdb.del_reckey(typetxtnow, title, chtxt, btime)
534 recdb.rec_reckey(typetxting, title, chtxt, btime, etime, opt)
535 tv2avi.b252ts(pin, chtxt, btime, etime, opt)
536 recdb.del_reckey(typetxting, title, chtxt, btime)
537 if not os.access(recpath + "/" + title + ".ts", os.F_OK):
538 recdb.del_reckey(typetxting, title, chtxt, btime)
539 recdb.rec_reckey(typetxtmiss, title, chtxt, btime, etime, opt)
541 auto_process.deltmpfile(recpath, title, ".ts")
542 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
543 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
545 if not re.search("D", opt):
546 tnow = datetime.datetime.now()
547 bt = tnow + datetime.timedelta(seconds=600)
549 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
550 etime = et.strftime("%Y-%m-%d %H:%M:%S")
551 recdb.rec_reckey(typetxtencque, title, chtxt, btime, etime, opt)
555 shutil.copy(os.path.join(recpath,title+".ts"), os.path.join(movepath,title+".ts"))
559 os.chmod(os.path.join(movepath,title+".ts"),0777)
562 recque.writeRecQue(movepath, chtxt, title, opt)
564 os.chmod(os.path.join(movepath,title+".recq"),0777)
568 if os.path.getsize(os.path.join(recpath,title+".ts"))==os.path.getsize(os.path.join(movepath,title+".ts")):
569 os.remove(os.path.join(recpath,title+".ts"))
570 except Exception, inst:
571 errtxt1="move ts error.\n"
572 errtxt2=str(type(inst))+"\n"
573 errtxt2=errtxt2+str(inst)
574 recdblist.Commonlogex("Error", "type_decode_que(timerec.py)", errtxt1,errtxt2+traceback.format_exc(),log_level=200)
575 recdb.rec_reckey(recdblist.REC_MOVE_END, title, chtxt, btime, etime, opt)
577 recdb.del_reckey(typetxtnow, title, chtxt, btime)
578 bt = bt + datetime.timedelta(seconds=600)
579 et = et + datetime.timedelta(seconds=600)
580 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
581 etime = et.strftime("%Y-%m-%d %H:%M:%S")
582 recdb.rec_reckey(typetxtnow, title, chtxt, btime, etime, opt)
585 def type_encode_que(typetxt,chtxt,title,bt,et,opt):
586 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
587 etime = et.strftime("%Y-%m-%d %H:%M:%S")
588 tnow = datetime.datetime.now()
590 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
594 if typetxt==recdblist.REC_ENCODE_QUE:
595 typetxting=recdblist.REC_ENCODE_LOCAL
596 typetxtfin=recdblist.REC_FIN_LOCAL
598 if status.getEncoding() < int(configreader.getenv("enc_max")):
599 recdb.del_reckey(typetxtnow, title, chtxt, btime)
600 recdb.rec_reckey(typetxting, title, chtxt, btime, etime, opt)
601 recdblist.printutf8(opt)
602 pin = recpath + "/" + title + ".ts"
603 if re.search("d", opt):
604 pin = recpath + "/" + title + ".m2v"
605 if not os.path.exists(pin) or os.path.getsize(pin)<100*1000:
606 paac2 = recpath + "/" + title + "_2.aac"
607 pmp32 = recpath + "/" + title + "_2.mp3"
608 if not os.path.exists(paac2) and not os.path.exists(pmp32):
609 tv2audio.ts2dualaudio_BonTsDemux(os.path.join(recpath, title+".ts"),recdblist.BONTSDEMUX_DELAY,opt)
611 elif re.search("5", opt):
612 pin = recpath + "/" + title + ".m2v"
613 if not os.path.exists(pin) or os.path.getsize(pin)<100*1000:
614 paac2 = recpath + "/" + title + "_2.aac"
615 pmp32 = recpath + "/" + title + "_2.mp3"
616 if not os.path.exists(paac2) and not os.path.exists(pmp32):
617 tv2audio.ts2pentaaudio_BonTsDemux(os.path.join(recpath, title+".ts"), recdblist.BONTSDEMUX_DELAY, opt)
621 if configreader.getenv("make_mp4")=="1":
625 if re.search("m", opt):
627 if re.search("4", opt):
629 recdblist.printutf8(pin)
630 if not re.search("0", opt):
632 pout = recpath + "/" + title + ".mp4"
633 tv2mp4.ts2mp4(pin, pout, opt)
635 pout = recpath + "/" + title + ".mkv"
636 tv2mkv.ts2mkv(pin, pout, opt)
637 if re.search("8", opt) or re.search("9", opt):
639 poutt = recpath + "/" + "m_"+title + ".mp4"
640 if re.search("d", opt) or re.search("5", opt):
641 if os.path.exists(os.path.join(recpath, "m_"+title+".m2v")):
642 shutil.move(os.path.join(recpath, title+".m2v"),os.path.join(recpath, "m_"+title+".m2v"))
643 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.aac")):
644 shutil.move(os.path.join(recpath, title+"_1.aac"),os.path.join(recpath, "m_"+title+"_1.aac"))
645 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.mp3")):
646 shutil.move(os.path.join(recpath, title+"_1.mp3"),os.path.join(recpath, "m_"+title+"_1.mp3"))
647 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.aac")):
648 shutil.move(os.path.join(recpath, title+"_2.aac"),os.path.join(recpath, "m_"+title+"_2.aac"))
649 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.mp3")):
650 shutil.move(os.path.join(recpath, title+"_2.mp3"),os.path.join(recpath, "m_"+title+"_2.mp3"))
651 shutil.move(os.path.join(recpath, title+".ts"),os.path.join(recpath, "m_"+title+".ts"))
652 tv2mp4.ts2mp4(os.path.join(recpath, "m_"+title+".ts"), poutt, optt)
653 shutil.move(os.path.join(recpath, "m_"+title+".ts"),os.path.join(recpath, title+".ts"))
656 poutt = recpath + "/" + "m_"+title + ".mp4"
657 shutil.move(os.path.join(recpath, title+".ts"),os.path.join(recpath, "m_"+title+".ts"))
658 if re.search("d", opt) or re.search("5", opt):
659 if os.path.exists(os.path.join(recpath, "m_"+title+".m2v")):
660 shutil.move(os.path.join(recpath, title+".m2v"),os.path.join(recpath, "m_"+title+".m2v"))
661 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.aac")):
662 shutil.move(os.path.join(recpath, title+"_1.aac"),os.path.join(recpath, "m_"+title+"_1.aac"))
663 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.mp3")):
664 shutil.move(os.path.join(recpath, title+"_1.mp3"),os.path.join(recpath, "m_"+title+"_1.mp3"))
665 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.aac")):
666 shutil.move(os.path.join(recpath, title+"_2.aac"),os.path.join(recpath, "m_"+title+"_2.aac"))
667 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.mp3")):
668 shutil.move(os.path.join(recpath, title+"_2.mp3"),os.path.join(recpath, "m_"+title+"_2.mp3"))
669 tv2mp4.ts2mp4(os.path.join(recpath, "m_"+title+".ts"), poutt, optt)
670 shutil.move(os.path.join(recpath, "m_"+title+".ts"),os.path.join(recpath, title+".ts"))
671 recdb.del_reckey(typetxting, title, chtxt, btime)
673 if re.search("E", opt):
675 if os.path.exists(os.path.join(recpath,title+".mp4")):
677 shutil.copy(os.path.join(recpath,title+".mp4"), os.path.join(movepath,title+".mp4"))
681 os.chmod(os.path.join(movepath,title+".mp4"),0777)
684 recque.writeRecQue(movepath, chtxt, title, opt)
686 os.chmod(os.path.join(movepath,title+".recq"),0777)
689 elif os.path.exists(os.path.join(recpath,title+".mkv")):
691 shutil.copy(os.path.join(recpath,title+".mkv"), os.path.join(movepath,title+".mkv"))
695 os.chmod(os.path.join(movepath,title+".mkv"),0777)
698 recque.writeRecQue(movepath, chtxt, title, opt)
700 os.chmod(os.path.join(movepath,title+".recq"),0777)
703 except Exception, inst:
704 errtxt1="move mkv/mp4 error."
705 errtxt2=str(type(inst))+"\n"
706 errtxt2=errtxt2+str(inst)
707 recdblist.Commonlogex("Error", "type_encode_que(timerec.py)", errtxt1,errtxt2+traceback.format_exc(),log_level=200)
708 recdb.rec_reckey(recdblist.REC_MOVE_END, title, chtxt, btime, etime, opt)
709 recdb.rec_reckey(typetxtfin, title, chtxt, btime, etime, opt)
712 recdb.del_reckey(typetxtnow, title, chtxt, btime)
713 bt = bt + datetime.timedelta(seconds=600)
714 et = et + datetime.timedelta(seconds=600)
715 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
716 etime = et.strftime("%Y-%m-%d %H:%M:%S")
717 recdb.rec_reckey(typetxtnow, title, chtxt, btime, etime, opt)