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")
257 for k,auto,opt in key:
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 if auto==1 or status.getSettings_auto_jbk()==1:
273 topt=status.getSettings_auto_opt()
277 maxnum=epgdb.count_schedule_timeline(btimet, etimet)[1]
278 maxnum=int(configreader.getenv("bscs_max"))-maxnum
280 maxnum=epgdb.count_schedule_timeline(btimet, etimet)[0]
281 maxnum=int(configreader.getenv("te_max"))-maxnum
283 topt=status.getSettings_auto_opt()
284 recdb.recreserv(titlet,chtxtt, btimet, etimet,topt)
285 except Exception, inst:
286 recdblist.Commonlogex("Error", "search_keyword_auto_jbk(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
289 recdb.add_auto_keyword(chtxtt, titlet, btimet, etimet)
290 except Exception, inst:
291 recdblist.Commonlogex("Error", "search_keyword(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
292 def type_reserve(typetxt,chtxt,title,bt,et,opt):
293 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
294 etime = et.strftime("%Y-%m-%d %H:%M:%S")
297 if typetxt==recdblist.REC_RESERVE:
298 typetxtfinal=recdblist.REC_FINAL_RESERVE
299 tnow = datetime.datetime.now()
301 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
302 if (dt < 58 * 60 and dt > 30 * 60):
303 bctypet = chdb.chtxtsearch(chtxt)['bctype']
304 chdatat = rec10d.rec10db.select_by_bctype_epg_ch(bctypet)
305 dt1 = datetime.datetime.strptime(chdatat[0][4], "%Y-%m-%d %H:%M:%S")-datetime.datetime.now()
306 dt1 = dt1.days * 24 * 60 * 60 + dt1.seconds
308 recdata = epgdb.searchtime2(title, btime, "5", chtxt)
316 bt = datetime.datetime.strptime(btimen, "%Y-%m-%d %H:%M:%S")
317 et = datetime.datetime.strptime(etimen, "%Y-%m-%d %H:%M:%S")
318 btimen = bt.strftime("%Y-%m-%d %H:%M:%S")
319 etimen = et.strftime("%Y-%m-%d %H:%M:%S")
322 recdb.del_reckey(typetxtnow, title, chtxt, btime)
323 recdb.rec_reckey(typetxtfinal, titlen, chtxtn, btimen, etimen, opt)
324 recdb.rec_reclog(titlen, chtxtn, btimen, etimen, opt, exp, longexp, category)
325 auto_rec.add_key(chtxt, titlen,exp+" "+longexp)
326 auto_rec.add_key("ALL", titlen,exp+" "+longexp)
327 recdblist.printutf8(u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen)
328 except Exception, inst:
329 recdblist.Commonlogex("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
331 recdblist.printutf8(u"追いかけ機能エラー:番組データが見付かりません。")
333 if rec10d.rec10db.select_by_bctype_epg_ch(bctypet)[0][5] != "0":
334 rec10d.rec10db.update_status_by_bctype_epg_ch(bctypet, "3")
336 elif (dt <= 30 * 60 and dt > 20 * 60):
337 recdata = epgdb.searchtime2(title, btime, "5", chtxt)
345 bt = datetime.datetime.strptime(btimen, "%Y-%m-%d %H:%M:%S")
346 et = datetime.datetime.strptime(etimen, "%Y-%m-%d %H:%M:%S")
347 btimen = bt.strftime("%Y-%m-%d %H:%M:%S")
348 etimen = et.strftime("%Y-%m-%d %H:%M:%S")
351 recdb.del_reckey(typetxtnow, title, chtxt, btime)
352 recdb.rec_reckey(typetxtfinal, titlen, chtxtn, btimen, etimen, opt)
353 recdb.rec_reclog(titlen, chtxtn, btimen, etimen, opt, exp, longexp, category)
354 auto_rec.add_key(chtxt, titlen,exp+" "+longexp)
355 auto_rec.add_key("ALL", titlen,exp+" "+longexp)
356 #recdblist.printutf8(u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen)
357 recdblist.Commonlogex(u"通常", "Oikake (timerec.py)",u"追いかけ機能実行中",u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen,log_level=500)
358 except Exception, inst:
359 recdblist.Commonlogex("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
362 recdb.del_reckey(typetxtnow, title, chtxt, btime)
363 recdb.rec_reckey(typetxtfinal, title, chtxt, btime, etime, opt)
364 except Exception, inst:
365 recdblist.Commonlogex("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
366 def type_final(typetxt,chtxt,title,bt,et,opt):
367 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
368 etime = et.strftime("%Y-%m-%d %H:%M:%S")
372 if typetxt==recdblist.REC_FINAL_RESERVE:
373 typetxting=recdblist.REC_TS_RECORDING
374 typetxtdecque=recdblist.REC_TS_DECODE_QUE
375 tnow = datetime.datetime.now()
377 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
378 if dt < 6 * 60 and dt > 0:
380 recdb.del_reckey(typetxtnow, title, chtxt, btime)
381 testpath=[os.path.join(recpath,title+".ts.b25")]
382 testpath.append(os.path.join(recpath,title+".ts"))
383 testpath.append(os.path.join(recpath,title+".avi"))
384 testpath.append(os.path.join(recpath,title+".mp4"))
385 testpath.append(os.path.join(recpath,title+".log"))
388 if os.path.exists(ti):
390 if re.search("N", opt) or tcheck>0:
393 iff=u"("+configreader.getenv("iff")+u")_"
397 newtitle=newtitle+u"_"+iff+newtime.strftime("%Y-%m-%dT%H-%M-%S")
398 recdb.rec_reckey(typetxting, newtitle, chtxt, btime, etime, opt)
399 recdblist.Commonlogex(u"通常","timerec.py",u"録画開始 "+newtitle+" "+btime+" "+etime,"",log_level=500)
400 tv2avi.timetv2b25(recpath + "/" + newtitle + ".avi", chtxt, btime, etime, opt)
401 recdb.del_reckey(typetxting, newtitle, chtxt, btime)
402 if not re.search("R", opt):
403 tnow = datetime.datetime.now()
404 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
405 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
407 bt = tnow + datetime.timedelta(seconds=600)
408 et = et + dt + datetime.timedelta(seconds=600)
409 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
410 etime = et.strftime("%Y-%m-%d %H:%M:%S")
411 recdb.rec_reckey(typetxtdecque, newtitle, chtxt, btime, etime, opt)
415 shutil.copy(os.path.join(recpath,title+".ts.b25"), os.path.join(movepath,title+".ts.b25"))
419 os.chmod(os.path.join(movepath,title+".ts.b25"),0777)
422 recque.writeRecQue(movepath, chtxt, title, opt)
424 os.chmod(os.path.join(movepath,title+".recq"),0777)
427 except Exception, inst:
428 recdblist.Commonlogex("Error", "Move option(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
429 recdb.rec_reckey(recdblist.REC_MOVE_END, newtitle, chtxt, btime, etime, opt)
431 def type_keyword(typetxt,chtxt,title,bt,et,opt,deltatime):
432 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
433 etime = et.strftime("%Y-%m-%d %H:%M:%S")
436 if typetxt==recdblist.REC_KEYWORD:
437 typetxtres=recdblist.REC_RESERVE
438 tnow = datetime.datetime.now()
440 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
441 recdblist.printutf8(str(dt), verbose_level=800)
443 recdata = epgdb.searchtime2(title, btime, deltatime, chtxt)
452 bt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
453 et = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
454 btimet = bt.strftime("%Y-%m-%d %H:%M:%S")
455 etimet = et.strftime("%Y-%m-%d %H:%M:%S")
457 recdb.del_reckey(typetxtnow, title, chtxt, btime)
458 recdb.rec_reckey(typetxtres, titlet, chtxtt, btimet, etimet, opt)
459 recdb.rec_reclog(titlet, chtxtt, btimet, etimet, opt, exp,longexp,category)
460 auto_rec.add_key(chtxt, titlet,exp+" "+longexp)
461 auto_rec.add_key("ALL", titlet,exp+" "+longexp)
462 recdblist.Commonlogex(u"通常","timerec.py",u"key "+title+u" : "+titlet+u" "+btimet+u" "+etimet,"",log_level=500)
463 #except Exception, inst:
464 # recdblist.printutf8("Error happened in REC_KEYWORD DB")
465 # recdblist.printutf8(type(inst))
466 # recdblist.printutf8(inst)
468 recdblist.printutf8("nothing match")
469 def type_keyword_every_day(type,chtxt,title,bt,et,opt,deltatime,deltaday,counter):
470 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
471 etime = et.strftime("%Y-%m-%d %H:%M:%S")
472 tnow = datetime.datetime.now()
474 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
475 dd = datetime.timedelta(days=int(deltaday))
477 recdb.del_reckey(recdblist.REC_KEYWORD_EVERY_SOME_DAYS, title, chtxt, btime)
480 btxt = bt.strftime("%Y-%m-%d %H:%M:%S")
481 etxt = et.strftime("%Y-%m-%d %H:%M:%S")
482 recdb.everyreserv(title, chtxt, btxt, etxt, deltatime, opt, deltaday)
484 recdb.del_reckey(recdblist.REC_KEYWORD_EVERY_SOME_DAYS, title, chtxt, btime)
487 btxt = bt.strftime("%Y-%m-%d %H:%M:%S")
488 etxt = et.strftime("%Y-%m-%d %H:%M:%S")
490 recdb.everyreserv(title, chtxt, btxt, etxt, deltatime, opt, deltaday,counter-1)
492 recdb.everyreserv(title, chtxt, btxt, etxt, deltatime, opt, deltaday,-1)
493 recdata = epgdb.searchtime2(title, btime, deltatime, chtxt)
502 bt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
503 et = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
504 btimet = bt.strftime("%Y-%m-%d %H:%M:%S")
505 etimet = et.strftime("%Y-%m-%d %H:%M:%S")
507 recdb.keyreserv(titlet, chtxtt, btimet, etimet, deltatime, opt)
509 recdb.keyreserv(title, chtxt, btime, etime, deltatime, opt)
510 def type_decode_que(typetxt,chtxt,title,bt,et,opt):
511 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
512 etime = et.strftime("%Y-%m-%d %H:%M:%S")
513 tnow = datetime.datetime.now()
515 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
520 if typetxt== recdblist.REC_TS_DECODE_QUE:
521 typetxting=recdblist.REC_TS_DECODING
522 typetxtmiss=recdblist.REC_MISS_DECODE
523 typetxtencque=recdblist.REC_ENCODE_QUE
524 tnow = datetime.datetime.now()
526 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
528 if status.getB25Decoding() < 2:
529 pin = recpath + "/" + title
530 recdb.del_reckey(typetxtnow, title, chtxt, btime)
531 recdb.rec_reckey(typetxting, title, chtxt, btime, etime, opt)
532 tv2avi.b252ts(pin, chtxt, btime, etime, opt)
533 recdb.del_reckey(typetxting, title, chtxt, btime)
534 if not os.access(recpath + "/" + title + ".ts", os.F_OK):
535 recdb.del_reckey(typetxting, title, chtxt, btime)
536 recdb.rec_reckey(typetxtmiss, title, chtxt, btime, etime, opt)
538 auto_process.deltmpfile(recpath, title, ".ts")
539 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
540 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
542 if not re.search("D", opt):
543 tnow = datetime.datetime.now()
544 bt = tnow + datetime.timedelta(seconds=600)
546 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
547 etime = et.strftime("%Y-%m-%d %H:%M:%S")
548 recdb.rec_reckey(typetxtencque, title, chtxt, btime, etime, opt)
552 shutil.copy(os.path.join(recpath,title+".ts"), os.path.join(movepath,title+".ts"))
556 os.chmod(os.path.join(movepath,title+".ts"),0777)
559 recque.writeRecQue(movepath, chtxt, title, opt)
561 os.chmod(os.path.join(movepath,title+".recq"),0777)
565 if os.path.getsize(os.path.join(recpath,title+".ts"))==os.path.getsize(os.path.join(movepath,title+".ts")):
566 os.remove(os.path.join(recpath,title+".ts"))
567 except Exception, inst:
568 errtxt1="move ts error.\n"
569 errtxt2=str(type(inst))+"\n"
570 errtxt2=errtxt2+str(inst)
571 recdblist.Commonlogex("Error", "type_decode_que(timerec.py)", errtxt1,errtxt2+traceback.format_exc(),log_level=200)
572 recdb.rec_reckey(recdblist.REC_MOVE_END, title, chtxt, btime, etime, opt)
574 recdb.del_reckey(typetxtnow, title, chtxt, btime)
575 bt = bt + datetime.timedelta(seconds=600)
576 et = et + datetime.timedelta(seconds=600)
577 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
578 etime = et.strftime("%Y-%m-%d %H:%M:%S")
579 recdb.rec_reckey(typetxtnow, title, chtxt, btime, etime, opt)
582 def type_encode_que(typetxt,chtxt,title,bt,et,opt):
583 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
584 etime = et.strftime("%Y-%m-%d %H:%M:%S")
585 tnow = datetime.datetime.now()
587 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
591 if typetxt==recdblist.REC_ENCODE_QUE:
592 typetxting=recdblist.REC_ENCODE_LOCAL
593 typetxtfin=recdblist.REC_FIN_LOCAL
595 if status.getEncoding() < int(configreader.getenv("enc_max")):
596 recdb.del_reckey(typetxtnow, title, chtxt, btime)
597 recdb.rec_reckey(typetxting, title, chtxt, btime, etime, opt)
598 recdblist.printutf8(opt)
599 pin = recpath + "/" + title + ".ts"
600 if re.search("d", opt):
601 pin = recpath + "/" + title + ".m2v"
602 if not os.path.exists(pin) or os.path.getsize(pin)<100*1000:
603 paac2 = recpath + "/" + title + "_2.aac"
604 pmp32 = recpath + "/" + title + "_2.mp3"
605 if not os.path.exists(paac2) and not os.path.exists(pmp32):
606 tv2audio.ts2dualaudio_BonTsDemux(os.path.join(recpath, title+".ts"),recdblist.BONTSDEMUX_DELAY,opt)
608 elif re.search("5", opt):
609 pin = recpath + "/" + title + ".m2v"
610 if not os.path.exists(pin) or os.path.getsize(pin)<100*1000:
611 paac2 = recpath + "/" + title + "_2.aac"
612 pmp32 = recpath + "/" + title + "_2.mp3"
613 if not os.path.exists(paac2) and not os.path.exists(pmp32):
614 tv2audio.ts2pentaaudio_BonTsDemux(os.path.join(recpath, title+".ts"), recdblist.BONTSDEMUX_DELAY, opt)
618 if configreader.getenv("make_mp4")=="1":
622 if re.search("m", opt):
624 if re.search("4", opt):
626 recdblist.printutf8(pin)
627 if not re.search("0", opt):
629 pout = recpath + "/" + title + ".mp4"
630 tv2mp4.ts2mp4(pin, pout, opt)
632 pout = recpath + "/" + title + ".mkv"
633 tv2mkv.ts2mkv(pin, pout, opt)
634 if re.search("8", opt) or re.search("9", opt):
636 poutt = recpath + "/" + "m_"+title + ".mp4"
637 if re.search("d", opt) or re.search("5", opt):
638 if os.path.exists(os.path.join(recpath, "m_"+title+".m2v")):
639 shutil.move(os.path.join(recpath, title+".m2v"),os.path.join(recpath, "m_"+title+".m2v"))
640 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.aac")):
641 shutil.move(os.path.join(recpath, title+"_1.aac"),os.path.join(recpath, "m_"+title+"_1.aac"))
642 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.mp3")):
643 shutil.move(os.path.join(recpath, title+"_1.mp3"),os.path.join(recpath, "m_"+title+"_1.mp3"))
644 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.aac")):
645 shutil.move(os.path.join(recpath, title+"_2.aac"),os.path.join(recpath, "m_"+title+"_2.aac"))
646 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.mp3")):
647 shutil.move(os.path.join(recpath, title+"_2.mp3"),os.path.join(recpath, "m_"+title+"_2.mp3"))
648 shutil.move(os.path.join(recpath, title+".ts"),os.path.join(recpath, "m_"+title+".ts"))
649 tv2mp4.ts2mp4(os.path.join(recpath, "m_"+title+".ts"), poutt, optt)
650 shutil.move(os.path.join(recpath, "m_"+title+".ts"),os.path.join(recpath, title+".ts"))
653 poutt = recpath + "/" + "m_"+title + ".mp4"
654 shutil.move(os.path.join(recpath, title+".ts"),os.path.join(recpath, "m_"+title+".ts"))
655 if re.search("d", opt) or re.search("5", opt):
656 if os.path.exists(os.path.join(recpath, "m_"+title+".m2v")):
657 shutil.move(os.path.join(recpath, title+".m2v"),os.path.join(recpath, "m_"+title+".m2v"))
658 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.aac")):
659 shutil.move(os.path.join(recpath, title+"_1.aac"),os.path.join(recpath, "m_"+title+"_1.aac"))
660 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.mp3")):
661 shutil.move(os.path.join(recpath, title+"_1.mp3"),os.path.join(recpath, "m_"+title+"_1.mp3"))
662 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.aac")):
663 shutil.move(os.path.join(recpath, title+"_2.aac"),os.path.join(recpath, "m_"+title+"_2.aac"))
664 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.mp3")):
665 shutil.move(os.path.join(recpath, title+"_2.mp3"),os.path.join(recpath, "m_"+title+"_2.mp3"))
666 tv2mp4.ts2mp4(os.path.join(recpath, "m_"+title+".ts"), poutt, optt)
667 shutil.move(os.path.join(recpath, "m_"+title+".ts"),os.path.join(recpath, title+".ts"))
668 recdb.del_reckey(typetxting, title, chtxt, btime)
670 if re.search("E", opt):
672 if os.path.exists(os.path.join(recpath,title+".mp4")):
674 shutil.copy(os.path.join(recpath,title+".mp4"), os.path.join(movepath,title+".mp4"))
678 os.chmod(os.path.join(movepath,title+".mp4"),0777)
681 recque.writeRecQue(movepath, chtxt, title, opt)
683 os.chmod(os.path.join(movepath,title+".recq"),0777)
686 elif os.path.exists(os.path.join(recpath,title+".mkv")):
688 shutil.copy(os.path.join(recpath,title+".mkv"), os.path.join(movepath,title+".mkv"))
692 os.chmod(os.path.join(movepath,title+".mkv"),0777)
695 recque.writeRecQue(movepath, chtxt, title, opt)
697 os.chmod(os.path.join(movepath,title+".recq"),0777)
700 except Exception, inst:
701 errtxt1="move mkv/mp4 error."
702 errtxt2=str(type(inst))+"\n"
703 errtxt2=errtxt2+str(inst)
704 recdblist.Commonlogex("Error", "type_encode_que(timerec.py)", errtxt1,errtxt2+traceback.format_exc(),log_level=200)
705 recdb.rec_reckey(recdblist.REC_MOVE_END, title, chtxt, btime, etime, opt)
706 recdb.rec_reckey(typetxtfin, title, chtxt, btime, etime, opt)
709 recdb.del_reckey(typetxtnow, title, chtxt, btime)
710 bt = bt + datetime.timedelta(seconds=600)
711 et = et + datetime.timedelta(seconds=600)
712 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
713 etime = et.strftime("%Y-%m-%d %H:%M:%S")
714 recdb.rec_reckey(typetxtnow, title, chtxt, btime, etime, opt)