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 search_keyword(recdb.get_key())
63 recque.searchRecQue(recpath)
71 auto_process.auto_check(recpath)
73 auto_process.kill_dead_encode(recpath)
75 update = chdb.update()
84 if bctype.find('te') > -1:
85 recnum = status.getTERecording() + recdb.countRecNow_minutes_TE("10")
86 recdblist.printutf8(u"放送種別:"+bctype + u"||該当チューナー実行中件数:" + str(status.getTERecording()) + u":直近予約件数:" + str(recdb.countRecNow_minutes_TE("10")),verbose_level=800)
87 recnum = int(configreader.getenv("te_max")) -recnum
89 recnum = status.getBSCSRecording() + recdb.countRecNow_minutes_BSCS("10")
90 recdblist.printutf8(u"放送種別:"+bctype + u"||該当チューナー実行中件数:" + str(status.getBSCSRecording()) + u":直近予約件数:" + str(recdb.countRecNow_minutes_BSCS("10")),verbose_level=800)
91 recnum = int(configreader.getenv("bscs_max")) -recnum
93 recdblist.printutf8(str(update),verbose_level=750)
94 rec10d.rec10db.update_status_by_bctype_epg_ch(bctype, "0")
95 epgdb.updatebc(bctype)
96 update = chdb.update()
101 auto_process.update_all_timeline_epg()
108 auto_process.update_all_timeline_epg()
111 typetxt = task["type"]
113 chtxt = task['chtxt']
117 title = task['title']
121 btime = task['btime']
122 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
125 bt = datetime.datetime.strptime("2009-01-01 00:00:00", "%Y-%m-%d %H:%M:%S")
127 etime = task['etime']
128 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
131 et = datetime.datetime.strptime("2009-01-01 00:00:00", "%Y-%m-%d %H:%M:%S")
136 tnow = datetime.datetime.now()
138 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
139 if task["type"] == recdblist.REC_RESERVE:#"res,"+chtxt+","+title+","+btime+","+etime+","+opt
141 if pid != 0:#親プロセスの場合
143 else:#子プロセスの場合 アップデートを行って終了
144 type_reserve(task["type"],chtxt,title,bt,et,opt)
146 elif task["type"] == recdblist.REC_KEYWORD:#"key,"+chtxt+","+keyword+","+btime+","+deltatime+","+opt
147 deltatime = task['deltatime']
149 if pid != 0:#親プロセスの場合
151 else:#子プロセスの場合 アップデートを行って終了
152 type_keyword(task["type"],chtxt,title, bt, et, opt, deltatime)
154 elif task["type"] == recdblist.REC_KEYWORD_EVERY_SOME_DAYS:#"keyevery,"+chtxt+","+keyword+","+btime+","+deltatime+","+opt+","+deltaday
155 deltatime = task['deltatime']
156 deltaday = task['deltaday']
158 keyeverycounter=task['counter']
162 if pid != 0:#親プロセスの場合
164 else:#子プロセスの場合 アップデートを行って終了
165 type_keyword_every_day(task["type"],chtxt, title, bt, et, opt, deltatime, deltaday,keyeverycounter)
167 elif task["type"] == recdblist.REC_FINAL_RESERVE:#"rec,"+chtxt+","+title+","+btime+","+etime+","+opt
169 if pid != 0:#親プロセスの場合
171 else:#子プロセスの場合 アップデートを行って終了
172 type_final(task["type"],chtxt, title, bt, et, opt)
174 elif task["type"] == recdblist.REC_TS_DECODE_QUE:
177 if pid != 0:#親プロセスの場合
179 else:#子プロセスの場合 アップデートを行って終了
181 type_decode_que(task["type"],chtxt, title, bt, et, opt)
183 elif task["type"] == recdblist.REC_ENCODE_QUE:
184 encodenum=encodenum+1
186 if pid != 0:#親プロセスの場合
188 else:#子プロセスの場合 アップデートを行って終了
189 time.sleep(5*encodenum)
190 type_encode_que(task["type"],chtxt, title, bt, et, opt)
192 elif task["type"] == recdblist.REC_AVI_TO_MKV:
200 if configreader.getenv("make_mp4")==1:
204 if re.search("m", opt):
206 if re.search("4", opt):
208 recdb.del_reckey(recdblist.REC_AVI_TO_MKV, title, chtxt, btime)
209 recdb.rec_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
211 tv2mp4.raw2mp4(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mp4"),opt)
213 tv2mkv.raw2mkv(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mkv"),opt)
214 recdb.del_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime)
216 elif task["type"] == recdblist.REC_AVI_TO_MP4:
224 if configreader.getenv("make_mp4")==1:
228 if re.search("m", opt):
230 if re.search("4", opt):
232 recdb.del_reckey(recdblist.REC_AVI_TO_MP4, title, chtxt, btime)
233 recdb.rec_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
235 tv2mp4.ts2mp4(pin, pout, opt)
236 tv2mp4.raw2mp4(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mp4"),opt)
238 tv2mkv.raw2mkv(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mkv"),opt)
239 recdb.del_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime)
241 elif task["type"] == recdblist.REC_MKV_TO_MP4:
247 recdb.del_reckey(recdblist.REC_MKV_TO_MP4, title, chtxt, btime)
248 recdb.rec_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
249 tv2mp4.mkv2mp4(os.path.join(recpath,title+".mkv"),os.path.join(recpath,title+".mp4"))
250 recdb.del_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime)
253 def search_keyword(key):
254 tnow = datetime.datetime.now()
255 nows =tnow.strftime("%Y-%m-%d %H:%M:%S")
256 for k,auto,opt in key:
257 recdatum = epgdb.searchtime_auto(k,nows, "144")
258 for recdata in recdatum:
264 btt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
265 ett = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
266 btimet = btt.strftime("%Y-%m-%d %H:%M:%S")
267 etimet = ett.strftime("%Y-%m-%d %H:%M:%S")
268 #if status.getSettings_auto_jbk()==1:
269 if auto==1 or status.getSettings_auto_jbk()==1:
272 topt=status.getSettings_auto_opt()
276 maxnum=epgdb.count_schedule_timeline(btimet, etimet)[1]
277 maxnum=int(configreader.getenv("bscs_max"))-maxnum
279 maxnum=epgdb.count_schedule_timeline(btimet, etimet)[0]
280 maxnum=int(configreader.getenv("te_max"))-maxnum
282 if recdb.checkduplicate(titlet, chtxtt, btimet, etimet)==0:
283 recdb.recreserv(titlet,chtxtt, btimet, etimet,topt)
284 except Exception, inst:
285 recdblist.Commonlogex("Error", "search_keyword_auto_jbk(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
288 recdb.add_auto_keyword(chtxtt, titlet, btimet, etimet)
289 except Exception, inst:
290 recdblist.Commonlogex("Error", "search_keyword(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
291 def type_reserve(typetxt,chtxt,title,bt,et,opt):
292 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
293 etime = et.strftime("%Y-%m-%d %H:%M:%S")
296 if typetxt==recdblist.REC_RESERVE:
297 typetxtfinal=recdblist.REC_FINAL_RESERVE
298 tnow = datetime.datetime.now()
300 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
301 if (dt < 58 * 60 and dt > 30 * 60):
302 bctypet = chdb.chtxtsearch(chtxt)['bctype']
303 chdatat = rec10d.rec10db.select_by_bctype_epg_ch(bctypet)
304 dt1 = datetime.datetime.strptime(chdatat[0][4], "%Y-%m-%d %H:%M:%S")-datetime.datetime.now()
305 dt1 = dt1.days * 24 * 60 * 60 + dt1.seconds
307 recdata = epgdb.searchtime2(title, btime, "5", chtxt)
315 bt = datetime.datetime.strptime(btimen, "%Y-%m-%d %H:%M:%S")
316 et = datetime.datetime.strptime(etimen, "%Y-%m-%d %H:%M:%S")
317 btimen = bt.strftime("%Y-%m-%d %H:%M:%S")
318 etimen = et.strftime("%Y-%m-%d %H:%M:%S")
321 recdb.del_reckey(typetxtnow, title, chtxt, btime)
322 recdb.rec_reckey(typetxtfinal, titlen, chtxtn, btimen, etimen, opt)
323 recdb.rec_reclog(titlen, chtxtn, btimen, etimen, opt, exp, longexp, category)
324 auto_rec.add_key(chtxt, titlen,exp+" "+longexp)
325 auto_rec.add_key("ALL", titlen,exp+" "+longexp)
326 recdblist.printutf8(u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen)
327 except Exception, inst:
328 recdblist.Commonlogex("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
330 recdblist.printutf8(u"追いかけ機能エラー:番組データが見付かりません。")
332 if rec10d.rec10db.select_by_bctype_epg_ch(bctypet)[0][5] != "0":
333 rec10d.rec10db.update_status_by_bctype_epg_ch(bctypet, "3")
335 elif (dt <= 30 * 60 and dt > 20 * 60):
336 recdata = epgdb.searchtime2(title, btime, "5", chtxt)
344 bt = datetime.datetime.strptime(btimen, "%Y-%m-%d %H:%M:%S")
345 et = datetime.datetime.strptime(etimen, "%Y-%m-%d %H:%M:%S")
346 btimen = bt.strftime("%Y-%m-%d %H:%M:%S")
347 etimen = et.strftime("%Y-%m-%d %H:%M:%S")
350 recdb.del_reckey(typetxtnow, title, chtxt, btime)
351 recdb.rec_reckey(typetxtfinal, titlen, chtxtn, btimen, etimen, opt)
352 recdb.rec_reclog(titlen, chtxtn, btimen, etimen, opt, exp, longexp, category)
353 auto_rec.add_key(chtxt, titlen,exp+" "+longexp)
354 auto_rec.add_key("ALL", titlen,exp+" "+longexp)
355 #recdblist.printutf8(u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen)
356 recdblist.Commonlogex(u"通常", "Oikake (timerec.py)",u"追いかけ機能実行中",u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen,log_level=500)
357 except Exception, inst:
358 recdblist.Commonlogex("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
361 recdb.del_reckey(typetxtnow, title, chtxt, btime)
362 recdb.rec_reckey(typetxtfinal, title, chtxt, btime, etime, opt)
363 except Exception, inst:
364 recdblist.Commonlogex("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
365 def type_final(typetxt,chtxt,title,bt,et,opt):
366 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
367 etime = et.strftime("%Y-%m-%d %H:%M:%S")
371 if typetxt==recdblist.REC_FINAL_RESERVE:
372 typetxting=recdblist.REC_TS_RECORDING
373 typetxtdecque=recdblist.REC_TS_DECODE_QUE
374 tnow = datetime.datetime.now()
376 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
377 if dt < 6 * 60 and dt > 0:
379 recdb.del_reckey(typetxtnow, title, chtxt, btime)
380 testpath=[os.path.join(recpath,title+".ts.b25")]
381 testpath.append(os.path.join(recpath,title+".ts"))
382 testpath.append(os.path.join(recpath,title+".avi"))
383 testpath.append(os.path.join(recpath,title+".mp4"))
384 testpath.append(os.path.join(recpath,title+".log"))
387 if os.path.exists(ti):
389 if re.search("N", opt) or tcheck>0:
392 iff=u"("+configreader.getenv("iff")+u")_"
396 newtitle=newtitle+u"_"+iff+newtime.strftime("%Y-%m-%dT%H-%M-%S")
397 recdb.rec_reckey(typetxting, newtitle, chtxt, btime, etime, opt)
398 recdblist.Commonlogex(u"通常","timerec.py",u"録画開始 "+newtitle+" "+btime+" "+etime,"",log_level=500)
399 tv2avi.timetv2b25(recpath + "/" + newtitle + ".avi", chtxt, btime, etime, opt)
400 recdb.del_reckey(typetxting, newtitle, chtxt, btime)
401 if not re.search("R", opt):
402 tnow = datetime.datetime.now()
403 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
404 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
406 bt = tnow + datetime.timedelta(seconds=600)
407 et = et + dt + datetime.timedelta(seconds=600)
408 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
409 etime = et.strftime("%Y-%m-%d %H:%M:%S")
410 recdb.rec_reckey(typetxtdecque, newtitle, chtxt, btime, etime, opt)
414 shutil.copy(os.path.join(recpath,title+".ts.b25"), os.path.join(movepath,title+".ts.b25"))
418 os.chmod(os.path.join(movepath,title+".ts.b25"),0777)
421 recque.writeRecQue(movepath, chtxt, title, opt)
423 os.chmod(os.path.join(movepath,title+".recq"),0777)
426 except Exception, inst:
427 recdblist.Commonlogex("Error", "Move option(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
428 recdb.rec_reckey(recdblist.REC_MOVE_END, newtitle, chtxt, btime, etime, opt)
430 def type_keyword(typetxt,chtxt,title,bt,et,opt,deltatime):
431 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
432 etime = et.strftime("%Y-%m-%d %H:%M:%S")
435 if typetxt==recdblist.REC_KEYWORD:
436 typetxtres=recdblist.REC_RESERVE
437 tnow = datetime.datetime.now()
439 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
440 recdblist.printutf8(str(dt), verbose_level=800)
442 recdata = epgdb.searchtime2(title, btime, deltatime, chtxt)
451 bt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
452 et = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
453 btimet = bt.strftime("%Y-%m-%d %H:%M:%S")
454 etimet = et.strftime("%Y-%m-%d %H:%M:%S")
456 recdb.del_reckey(typetxtnow, title, chtxt, btime)
457 recdb.rec_reckey(typetxtres, titlet, chtxt, btimet, etimet, opt)
458 recdb.rec_reclog(titlet, chtxtt, btimet, etimet, opt, exp,longexp,category)
459 auto_rec.add_key(chtxt, titlet,exp+" "+longexp)
460 auto_rec.add_key("ALL", titlet,exp+" "+longexp)
461 recdblist.Commonlogex(u"通常","timerec.py",u"key "+title+u" : "+titlet+u" "+btimet+u" "+etimet,"",log_level=500)
462 #except Exception, inst:
463 # recdblist.printutf8("Error happened in REC_KEYWORD DB")
464 # recdblist.printutf8(type(inst))
465 # recdblist.printutf8(inst)
467 recdblist.printutf8("nothing match")
468 def type_keyword_every_day(type,chtxt,title,bt,et,opt,deltatime,deltaday,counter):
469 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
470 etime = et.strftime("%Y-%m-%d %H:%M:%S")
471 tnow = datetime.datetime.now()
473 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
474 dd = datetime.timedelta(days=int(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")
481 recdb.everyreserv(title, chtxt, btxt, etxt, deltatime, opt, deltaday)
483 recdb.del_reckey(recdblist.REC_KEYWORD_EVERY_SOME_DAYS, title, chtxt, btime)
486 btxt = bt.strftime("%Y-%m-%d %H:%M:%S")
487 etxt = et.strftime("%Y-%m-%d %H:%M:%S")
489 recdb.everyreserv(title, chtxt, btxt, etxt, deltatime, opt, deltaday,counter-1)
491 recdb.everyreserv(title, chtxt, btxt, etxt, deltatime, opt, deltaday,-1)
492 recdata = epgdb.searchtime2(title, btime, deltatime, chtxt)
501 bt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
502 et = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
503 btimet = bt.strftime("%Y-%m-%d %H:%M:%S")
504 etimet = et.strftime("%Y-%m-%d %H:%M:%S")
506 recdb.keyreserv(titlet, chtxt, btimet, etimet, deltatime, opt)
508 recdb.keyreserv(title, chtxt, btime, etime, deltatime, opt)
509 def type_decode_que(typetxt,chtxt,title,bt,et,opt):
510 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
511 etime = et.strftime("%Y-%m-%d %H:%M:%S")
512 tnow = datetime.datetime.now()
514 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
519 if typetxt== recdblist.REC_TS_DECODE_QUE:
520 typetxting=recdblist.REC_TS_DECODING
521 typetxtmiss=recdblist.REC_MISS_DECODE
522 typetxtencque=recdblist.REC_ENCODE_QUE
523 tnow = datetime.datetime.now()
525 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
527 if status.getB25Decoding() < 2:
528 pin = recpath + "/" + title
529 recdb.del_reckey(typetxtnow, title, chtxt, btime)
530 recdb.rec_reckey(typetxting, title, chtxt, btime, etime, opt)
531 tv2avi.b252ts(pin, chtxt, btime, etime, opt)
532 recdb.del_reckey(typetxting, title, chtxt, btime)
533 if not os.access(recpath + "/" + title + ".ts", os.F_OK):
534 recdb.del_reckey(typetxting, title, chtxt, btime)
535 recdb.rec_reckey(typetxtmiss, title, chtxt, btime, etime, opt)
537 auto_process.deltmpfile(recpath, title, ".ts")
538 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
539 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
541 if not re.search("D", opt):
542 tnow = datetime.datetime.now()
543 bt = tnow + datetime.timedelta(seconds=600)
545 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
546 etime = et.strftime("%Y-%m-%d %H:%M:%S")
547 recdb.rec_reckey(typetxtencque, title, chtxt, btime, etime, opt)
551 shutil.copy(os.path.join(recpath,title+".ts"), os.path.join(movepath,title+".ts"))
555 os.chmod(os.path.join(movepath,title+".ts"),0777)
558 recque.writeRecQue(movepath, chtxt, title, opt)
560 os.chmod(os.path.join(movepath,title+".recq"),0777)
564 if os.path.getsize(os.path.join(recpath,title+".ts"))==os.path.getsize(os.path.join(movepath,title+".ts")):
565 os.remove(os.path.join(recpath,title+".ts"))
566 except Exception, inst:
567 errtxt1="move ts error.\n"
568 errtxt2=str(type(inst))+"\n"
569 errtxt2=errtxt2+str(inst)
570 recdblist.Commonlogex("Error", "type_decode_que(timerec.py)", errtxt1,errtxt2+traceback.format_exc(),log_level=200)
571 recdb.rec_reckey(recdblist.REC_MOVE_END, title, chtxt, btime, etime, opt)
573 recdb.del_reckey(typetxtnow, title, chtxt, btime)
574 bt = bt + datetime.timedelta(seconds=600)
575 et = et + datetime.timedelta(seconds=600)
576 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
577 etime = et.strftime("%Y-%m-%d %H:%M:%S")
578 recdb.rec_reckey(typetxtnow, title, chtxt, btime, etime, opt)
581 def type_encode_que(typetxt,chtxt,title,bt,et,opt):
582 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
583 etime = et.strftime("%Y-%m-%d %H:%M:%S")
584 tnow = datetime.datetime.now()
586 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
590 if typetxt==recdblist.REC_ENCODE_QUE:
591 typetxting=recdblist.REC_ENCODE_LOCAL
592 typetxtfin=recdblist.REC_FIN_LOCAL
594 if status.getEncoding() < int(configreader.getenv("enc_max")):
595 recdb.del_reckey(typetxtnow, title, chtxt, btime)
596 recdb.rec_reckey(typetxting, title, chtxt, btime, etime, opt)
597 recdblist.printutf8(opt)
598 pin = recpath + "/" + title + ".ts"
599 if re.search("d", opt):
600 pin = recpath + "/" + title + ".m2v"
601 if not os.path.exists(pin) or os.path.getsize(pin)<100*1000:
602 paac2 = recpath + "/" + title + "_2.aac"
603 pmp32 = recpath + "/" + title + "_2.mp3"
604 if not os.path.exists(paac2) and not os.path.exists(pmp32):
605 tv2audio.ts2dualaudio_BonTsDemux(os.path.join(recpath, title+".ts"),recdblist.BONTSDEMUX_DELAY,opt)
607 elif re.search("5", opt):
608 pin = recpath + "/" + title + ".m2v"
609 if not os.path.exists(pin) or os.path.getsize(pin)<100*1000:
610 paac2 = recpath + "/" + title + "_2.aac"
611 pmp32 = recpath + "/" + title + "_2.mp3"
612 if not os.path.exists(paac2) and not os.path.exists(pmp32):
613 tv2audio.ts2pentaaudio_BonTsDemux(os.path.join(recpath, title+".ts"), recdblist.BONTSDEMUX_DELAY, opt)
617 if configreader.getenv("make_mp4")=="1":
621 if re.search("m", opt):
623 if re.search("4", opt):
625 recdblist.printutf8(pin)
626 if not re.search("0", opt):
628 pout = recpath + "/" + title + ".mp4"
629 tv2mp4.ts2mp4(pin, pout, opt)
631 pout = recpath + "/" + title + ".mkv"
632 tv2mkv.ts2mkv(pin, pout, opt)
633 if re.search("8", opt) or re.search("9", opt):
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 poutt = recpath + "/" + "m_"+title + ".mp4"
653 shutil.move(os.path.join(recpath, title+".ts"),os.path.join(recpath, "m_"+title+".ts"))
654 if re.search("d", opt) or re.search("5", opt):
655 if os.path.exists(os.path.join(recpath, "m_"+title+".m2v")):
656 shutil.move(os.path.join(recpath, title+".m2v"),os.path.join(recpath, "m_"+title+".m2v"))
657 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.aac")):
658 shutil.move(os.path.join(recpath, title+"_1.aac"),os.path.join(recpath, "m_"+title+"_1.aac"))
659 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.mp3")):
660 shutil.move(os.path.join(recpath, title+"_1.mp3"),os.path.join(recpath, "m_"+title+"_1.mp3"))
661 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.aac")):
662 shutil.move(os.path.join(recpath, title+"_2.aac"),os.path.join(recpath, "m_"+title+"_2.aac"))
663 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.mp3")):
664 shutil.move(os.path.join(recpath, title+"_2.mp3"),os.path.join(recpath, "m_"+title+"_2.mp3"))
665 tv2mp4.ts2mp4(os.path.join(recpath, "m_"+title+".ts"), poutt, optt)
666 shutil.move(os.path.join(recpath, "m_"+title+".ts"),os.path.join(recpath, title+".ts"))
667 recdb.del_reckey(typetxting, title, chtxt, btime)
669 if re.search("E", opt):
671 if os.path.exists(os.path.join(recpath,title+".mp4")):
673 shutil.copy(os.path.join(recpath,title+".mp4"), os.path.join(movepath,title+".mp4"))
677 os.chmod(os.path.join(movepath,title+".mp4"),0777)
680 recque.writeRecQue(movepath, chtxt, title, opt)
682 os.chmod(os.path.join(movepath,title+".recq"),0777)
685 elif os.path.exists(os.path.join(recpath,title+".mkv")):
687 shutil.copy(os.path.join(recpath,title+".mkv"), os.path.join(movepath,title+".mkv"))
691 os.chmod(os.path.join(movepath,title+".mkv"),0777)
694 recque.writeRecQue(movepath, chtxt, title, opt)
696 os.chmod(os.path.join(movepath,title+".recq"),0777)
699 except Exception, inst:
700 errtxt1="move mkv/mp4 error."
701 errtxt2=str(type(inst))+"\n"
702 errtxt2=errtxt2+str(inst)
703 recdblist.Commonlogex("Error", "type_encode_que(timerec.py)", errtxt1,errtxt2+traceback.format_exc(),log_level=200)
704 recdb.rec_reckey(recdblist.REC_MOVE_END, title, chtxt, btime, etime, opt)
705 recdb.rec_reckey(typetxtfin, title, chtxt, btime, etime, opt)
708 recdb.del_reckey(typetxtnow, title, chtxt, btime)
709 bt = bt + datetime.timedelta(seconds=600)
710 et = et + datetime.timedelta(seconds=600)
711 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
712 etime = et.strftime("%Y-%m-%d %H:%M:%S")
713 recdb.rec_reckey(typetxtnow, title, chtxt, btime, etime, opt)