3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009-2011 Yukikaze
29 recpath = configreader.getConfPath('recpath')
30 movepath = configreader.getConfPath('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_installed_in_status(100)
45 elif rec10d.rec10db.select_installed_in_status()==2:
46 recdblist.printutf8ex("Exit because CH scanning.", 200, 200)
48 except Exception, inst:
49 recdblist.addCommonlogEX("Error", "install_check(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
51 recdb.deleteOldProgramBeforeTheseHours("24")
52 recdb.delete_old_auto_bayes("1")
53 recdb.delete_old_auto_keyword("1")
54 tasks = recdb.getProgramsInTheseHours("3")
55 inum = recdb.countRecNow_minutes("10")
56 recdblist.printutf8(u"rec10処理開始"+ datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),verbose_level=800)
57 recdblist.printutf8(u"直近録画予約件数:" + str(inum) + u"BS/CS録画中件数:" + str(status.getBSCSRecording()) + u"TE録画中件数:" + str(status.getTERecording()) ,verbose_level=800)
60 dnow=datetime.datetime.now()
61 if dnow.minute % 10 < 5:
66 search_keyword(recdb.getAllJbkKeyword())
67 recque.searchRecQue(recpath)
75 auto_process.autoCheck(recpath)
77 auto_process.killDeadEncode(recpath)
79 update = chdb.update()
80 updatelogo = chdb.updateLogo()
90 if bctype.find('te') > -1:
91 recnum = status.getTERecording() + recdb.countRecNow_minutes_TE("10")
92 recdblist.printutf8(u"放送種別:"+bctype + u"||該当チューナー実行中件数:" + str(status.getTERecording()) + u":直近予約件数:" + str(recdb.countRecNow_minutes_TE("10")),verbose_level=800)
93 recnum = int(configreader.getConfEnv("te_max")) -recnum
95 recnum = status.getBSCSRecording() + recdb.countRecNow_minutes_BSCS("10")
96 recdblist.printutf8(u"放送種別:"+bctype + u"||該当チューナー実行中件数:" + str(status.getBSCSRecording()) + u":直近予約件数:" + str(recdb.countRecNow_minutes_BSCS("10")),verbose_level=800)
97 recnum = int(configreader.getConfEnv("bscs_max")) -recnum
99 recdblist.printutf8(str(update),verbose_level=750)
100 rec10d.rec10db.update_status_by_bctype_epg_ch(bctype, "0")
101 epgdb.updatebc(bctype)
102 update = chdb.update()
107 auto_process.update_all_timeline_epg()
109 elif len(updatelogo)>0:
115 for bctype in updatelogo:
117 if bctype.find('te') > -1:
118 recnum = status.getTERecording() + recdb.countRecNow_minutes_TE("1200")
119 recdblist.printutf8(u"ロゴ未取得 : 放送種別-"+bctype + u"||該当チューナー実行中件数:" + str(status.getTERecording()) + u":直近予約件数:" + str(recdb.countRecNow_minutes_TE("10")),verbose_level=800)
120 recnum = int(configreader.getConfEnv("te_max")) -recnum
122 recnum = status.getBSCSRecording() + recdb.countRecNow_minutes_BSCS("1200")
123 recdblist.printutf8(u"ロゴ未取得 : 放送種別-"+bctype + u"||該当チューナー実行中件数:" + str(status.getBSCSRecording()) + u":直近予約件数:" + str(recdb.countRecNow_minutes_BSCS("10")),verbose_level=800)
124 recnum = int(configreader.getConfEnv("bscs_max")) -recnum
126 recdblist.printutf8(u"ロゴ取得"+str(updatelogo),verbose_level=750)
127 rec10d.rec10db.update_logostatus_by_bctype_epg_ch(bctype,"0")
128 epgdb.updateLogo_bc(bctype)
129 updatelogo = chdb.updateLogo()
140 auto_process.update_all_timeline_epg()
143 typetxt = task["type"]
145 chtxt = task['chtxt']
149 title = task['title']
153 btime = task['btime']
154 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
157 bt = datetime.datetime.strptime("2009-01-01 00:00:00", "%Y-%m-%d %H:%M:%S")
159 etime = task['etime']
160 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
163 et = datetime.datetime.strptime("2009-01-01 00:00:00", "%Y-%m-%d %H:%M:%S")
168 tnow = datetime.datetime.now()
170 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
171 if task["type"] == recdblist.REC_RESERVE:#"res,"+chtxt+","+title+","+btime+","+etime+","+opt
173 if pid != 0:#親プロセスの場合
175 else:#子プロセスの場合 アップデートを行って終了
176 type_reserve(task["type"],chtxt,title,bt,et,opt)
178 elif task["type"] == recdblist.REC_KEYWORD:#"key,"+chtxt+","+keyword+","+btime+","+deltatime+","+opt
179 deltatime = task['deltatime']
181 if pid != 0:#親プロセスの場合
183 else:#子プロセスの場合 アップデートを行って終了
184 type_keyword(task["type"],chtxt,title, bt, et, opt, deltatime)
186 elif task["type"] == recdblist.REC_KEYWORD_EVERY_SOME_DAYS:#"keyevery,"+chtxt+","+keyword+","+btime+","+deltatime+","+opt+","+deltaday
187 deltatime = task['deltatime']
188 deltaday = task['deltaday']
190 keyeverycounter=task['counter']
194 if pid != 0:#親プロセスの場合
196 else:#子プロセスの場合 アップデートを行って終了
197 type_keyword_every_day(task["type"],chtxt, title, bt, et, opt, deltatime, deltaday,keyeverycounter)
199 elif task["type"] == recdblist.REC_FINAL_RESERVE:#"rec,"+chtxt+","+title+","+btime+","+etime+","+opt
201 if pid != 0:#親プロセスの場合
203 else:#子プロセスの場合 アップデートを行って終了
204 type_final(task["type"],chtxt, title, bt, et, opt)
206 elif task["type"] == recdblist.REC_TS_DECODE_QUE:
209 if pid != 0:#親プロセスの場合
211 else:#子プロセスの場合 アップデートを行って終了
213 type_decode_que(task["type"],chtxt, title, bt, et, opt)
215 elif task["type"] == recdblist.REC_ENCODE_QUE:
216 encodenum=encodenum+1
218 if pid != 0:#親プロセスの場合
220 else:#子プロセスの場合 アップデートを行って終了
221 time.sleep(5*encodenum)
222 type_encode_que(task["type"],chtxt, title, bt, et, opt)
224 elif task["type"] == recdblist.REC_AVI_TO_MKV:
232 if configreader.getConfEnv("make_mp4")==0:
236 if re.search("m", opt):
238 if re.search("4", opt):
240 recdb.deleteReckey(recdblist.REC_AVI_TO_MKV, title, chtxt, btime)
241 recdb.reserveReckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
243 tv2mp4.raw2mp4(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mp4"),opt)
245 tv2mp4.raw2mp4(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mp4"),opt)
246 tv2mkv.mp42mkv(os.path.join(recpath,title+".mp4"), os.path.join(recpath,title+".mkv"))
247 os.remove(os.path.join(recpath,title+".mp4"))
248 recdb.deleteReckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime)
250 elif task["type"] == recdblist.REC_AVI_TO_MP4:
258 if configreader.getConfEnv("make_mp4")==1:
262 if re.search("m", opt):
264 if re.search("4", opt):
266 recdb.deleteReckey(recdblist.REC_AVI_TO_MP4, title, chtxt, btime)
267 recdb.reserveReckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
269 tv2mp4.ts2mp4(pin, pout, opt)
270 tv2mp4.raw2mp4(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mp4"),opt)
272 tv2mkv.raw2mkv(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mkv"),opt)
273 recdb.deleteReckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime)
275 elif task["type"] == recdblist.REC_MKV_TO_MP4:
281 recdb.deleteReckey(recdblist.REC_MKV_TO_MP4, title, chtxt, btime)
282 recdb.reserveReckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
283 tv2mp4.mkv2mp4(os.path.join(recpath,title+".mkv"),os.path.join(recpath,title+".mp4"))
284 recdb.deleteReckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime)
287 def search_keyword(key):
288 tnow = datetime.datetime.now()
289 nows =tnow.strftime("%Y-%m-%d %H:%M:%S")
290 for k,auto,opt in key:
291 recdatum = epgdb.searchTimeAuto(k,nows, "144")
292 for recdata in recdatum:
298 btt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
299 ett = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
300 btimet = btt.strftime("%Y-%m-%d %H:%M:%S")
301 etimet = ett.strftime("%Y-%m-%d %H:%M:%S")
302 #if status.getSettings_auto_jbk()==1:
303 if auto==1 or status.getSettings_auto_jbk()==1:
307 topt=status.getSettings_auto_opt()
310 ch=chdb.searchCHFromChtxt(chtxtt)
312 maxnum=epgdb.countSchedule(btimet, etimet)[1]
313 maxnum=int(configreader.getConfEnv("bscs_max"))-maxnum
315 maxnum=epgdb.countSchedule(btimet, etimet)[0]
316 maxnum=int(configreader.getConfEnv("te_max"))-maxnum
318 if recdb.checkDuplicated(titlet, chtxtt, btimet, etimet)==0:
319 recdb.reserveReckey(recdblist.REC_RESERVE,titlet,chtxtt, btimet, etimet,topt)
320 except Exception, inst:
321 recdblist.addCommonlogEX("Error", "search_keyword_auto_jbk(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
323 recdb.reserveAutoKeyword(chtxtt, titlet, btimet, etimet)
324 except Exception, inst:
325 recdblist.addCommonlogEX("Error", "search_keyword(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
326 def type_reserve(typetxt,chtxt,title,bt,et,opt):
327 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
328 etime = et.strftime("%Y-%m-%d %H:%M:%S")
331 if typetxt==recdblist.REC_RESERVE:
332 typetxtfinal=recdblist.REC_FINAL_RESERVE
333 tnow = datetime.datetime.now()
335 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
336 if (dt < 58 * 60 and dt > 30 * 60):
337 bctypet = chdb.searchCHFromChtxt(chtxt)['bctype']
338 chdatat = rec10d.rec10db.select_by_bctype_epg_ch(bctypet)
339 dt1 = bt - datetime.datetime.strptime(chdatat[0][4], "%Y-%m-%d %H:%M:%S")
340 dt1 = dt1.days * 24 * 60 * 60 + dt1.seconds
342 recdata = epgdb.searchTime(title, btime, "5", chtxt)
350 bt = datetime.datetime.strptime(btimen, "%Y-%m-%d %H:%M:%S")
351 et = datetime.datetime.strptime(etimen, "%Y-%m-%d %H:%M:%S")
352 btimen = bt.strftime("%Y-%m-%d %H:%M:%S")
353 etimen = et.strftime("%Y-%m-%d %H:%M:%S")
356 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
357 recdb.reserveReckey(typetxtfinal, titlen, chtxtn, btimen, etimen, opt)
358 recdb.addRecLogProgram(titlen, chtxtn, btimen, etimen, opt, exp, longexp, category)
359 auto_rec.addKey(chtxt, titlen,exp+" "+longexp)
360 auto_rec.addKey("ALL", titlen,exp+" "+longexp)
361 recdblist.printutf8(u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen)
362 except Exception, inst:
363 recdblist.addCommonlogEX("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
365 recdblist.printutf8(u"追いかけ機能エラー:番組データが見付かりません。")
367 if rec10d.rec10db.select_by_bctype_epg_ch(bctypet)[0][5] != "0":
368 rec10d.rec10db.update_status_by_bctype_epg_ch(bctypet, "3")
370 elif (dt <= 30 * 60 and dt > 20 * 60):
371 recdata = epgdb.searchTime(title, btime, "5", chtxt)
379 bt = datetime.datetime.strptime(btimen, "%Y-%m-%d %H:%M:%S")
380 et = datetime.datetime.strptime(etimen, "%Y-%m-%d %H:%M:%S")
381 btimen = bt.strftime("%Y-%m-%d %H:%M:%S")
382 etimen = et.strftime("%Y-%m-%d %H:%M:%S")
385 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
386 recdb.reserveReckey(typetxtfinal, titlen, chtxtn, btimen, etimen, opt)
387 recdb.addRecLogProgram(titlen, chtxtn, btimen, etimen, opt, exp, longexp, category)
388 auto_rec.addKey(chtxt, titlen,exp+" "+longexp)
389 auto_rec.addKey("ALL", titlen,exp+" "+longexp)
390 #recdblist.printutf8(u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen)
391 recdblist.addCommonlogEX(u"通常", "Oikake (timerec.py)",u"追いかけ機能実行中",u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen,log_level=500)
392 except Exception, inst:
393 recdblist.addCommonlogEX("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
396 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
397 recdb.reserveReckey(typetxtfinal, title, chtxt, btime, etime, opt)
398 except Exception, inst:
399 recdblist.addCommonlogEX("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
400 def type_final(typetxt,chtxt,title,bt,et,opt):
401 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
402 etime = et.strftime("%Y-%m-%d %H:%M:%S")
406 if typetxt==recdblist.REC_FINAL_RESERVE:
407 typetxting=recdblist.REC_TS_RECORDING
408 typetxtdecque=recdblist.REC_TS_DECODE_QUE
409 tnow = datetime.datetime.now()
411 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
412 if dt < 6 * 60 and dt > 0:
414 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
415 testpath=[os.path.join(recpath,title+".ts.b25")]
416 testpath.append(os.path.join(recpath,title+".ts"))
417 testpath.append(os.path.join(recpath,title+".avi"))
418 testpath.append(os.path.join(recpath,title+".mp4"))
419 testpath.append(os.path.join(recpath,title+".log"))
422 if os.path.exists(ti):
424 if re.search("N", opt) or tcheck>0:
427 iff=u"("+configreader.getConfEnv("iff")+u")_"
431 newtitle=newtitle+u"_"+iff+newtime.strftime("%Y-%m-%dT%H-%M-%S")
432 recdb.reserveReckey(typetxting, newtitle, chtxt, btime, etime, opt)
433 recdblist.addCommonlogEX(u"通常","timerec.py",u"録画開始 "+newtitle+" "+btime+" "+etime,"",log_level=500)
434 tv2avi.timetv2b25(recpath + "/" + newtitle + ".avi", chtxt, btime, etime, opt)
435 recdb.deleteReckey(typetxting, newtitle, chtxt, btime)
436 if not re.search("R", opt):
437 tnow = datetime.datetime.now()
438 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
439 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
441 bt = tnow + datetime.timedelta(seconds=600)
442 et = et + dt + datetime.timedelta(seconds=600)
443 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
444 etime = et.strftime("%Y-%m-%d %H:%M:%S")
445 recdb.reserveReckey(typetxtdecque, newtitle, chtxt, btime, etime, opt)
449 shutil.copy(os.path.join(recpath,title+".ts.b25"), os.path.join(movepath,title+".ts.b25"))
453 os.chmod(os.path.join(movepath,title+".ts.b25"),0777)
456 recque.writeRecQue(movepath, chtxt, title, opt)
458 os.chmod(os.path.join(movepath,title+".recq"),0777)
461 except Exception, inst:
462 recdblist.addCommonlogEX("Error", "Move option(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
463 recdb.reserveReckey(recdblist.REC_MOVE_END, newtitle, chtxt, btime, etime, opt)
465 def type_keyword(typetxt,chtxt,title,bt,et,opt,deltatime):
466 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
467 etime = et.strftime("%Y-%m-%d %H:%M:%S")
470 if typetxt==recdblist.REC_KEYWORD:
471 typetxtres=recdblist.REC_RESERVE
472 tnow = datetime.datetime.now()
474 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
475 recdblist.printutf8(str(dt), verbose_level=800)
476 if dt <= 90 * 60 and dt > 70 * 60:
477 recdata = epgdb.searchTime(title, btime, deltatime, chtxt)
486 bt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
487 et = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
488 btimet = bt.strftime("%Y-%m-%d %H:%M:%S")
489 etimet = et.strftime("%Y-%m-%d %H:%M:%S")
491 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
492 recdb.reserveReckey(typetxtres, titlet, chtxt, btimet, etimet, opt)
493 recdb.addRecLogProgram(titlet, chtxtt, btimet, etimet, opt, exp,longexp,category)
494 auto_rec.addKey(chtxt, titlet,exp+" "+longexp)
495 auto_rec.addKey("ALL", titlet,exp+" "+longexp)
496 recdblist.addCommonlogEX(u"通常","timerec.py",u"key "+title+u" : "+titlet+u" "+btimet+u" "+etimet,"",log_level=500)
497 #except Exception, inst:
498 # recdblist.printutf8("Error happened in REC_KEYWORD DB")
499 # recdblist.printutf8(type(inst))
500 # recdblist.printutf8(inst)
502 recdblist.printutf8("nothing match")
504 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
505 recdb.reserveReckey(typetxtres, title, chtxt, btime, etime, opt)
506 recdblist.addCommonlogEX(u"エラー","timerec.py",u"nothing match","",log_level=200)
507 recdblist.addCommonlogEX(u"エラー","timerec.py",u"key "+title+u" "+btime+u" "+etime,"",log_level=200)
508 def type_keyword_every_day(type,chtxt,title,bt,et,opt,deltatime,deltaday,counter):
509 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
510 etime = et.strftime("%Y-%m-%d %H:%M:%S")
511 tnow = datetime.datetime.now()
513 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
514 dd = datetime.timedelta(days=int(deltaday))
516 recdb.deleteReckey(recdblist.REC_KEYWORD_EVERY_SOME_DAYS, title, chtxt, btime)
519 btxt = bt.strftime("%Y-%m-%d %H:%M:%S")
520 etxt = et.strftime("%Y-%m-%d %H:%M:%S")
522 recdb.reserveEverydayKeyword(title, chtxt, btxt, etxt, deltatime, opt, deltaday,counter-1)
524 recdb.reserveEverydayKeyword(title, chtxt, btxt, etxt, deltatime, opt, deltaday,-1)
526 recdb.deleteReckey(recdblist.REC_KEYWORD_EVERY_SOME_DAYS, title, chtxt, btime)
529 btxt = bt.strftime("%Y-%m-%d %H:%M:%S")
530 etxt = et.strftime("%Y-%m-%d %H:%M:%S")
532 recdb.reserveEverydayKeyword(title, chtxt, btxt, etxt, deltatime, opt, deltaday,counter-1)
534 recdb.reserveEverydayKeyword(title, chtxt, btxt, etxt, deltatime, opt, deltaday,-1)
535 recdata = epgdb.searchTime(title, btime, deltatime, chtxt)
544 bt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
545 et = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
546 btimet = bt.strftime("%Y-%m-%d %H:%M:%S")
547 etimet = et.strftime("%Y-%m-%d %H:%M:%S")
549 recdb.reserveKeyword(titlet, chtxt, btimet, etimet, deltatime, opt)
551 recdb.reserveKeyword(title, chtxt, btime, etime, deltatime, opt)
552 def type_decode_que(typetxt,chtxt,title,bt,et,opt):
553 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
554 etime = et.strftime("%Y-%m-%d %H:%M:%S")
555 tnow = datetime.datetime.now()
557 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
562 if typetxt== recdblist.REC_TS_DECODE_QUE:
563 typetxting=recdblist.REC_TS_DECODING
564 typetxtmiss=recdblist.REC_MISS_DECODE
565 typetxtencque=recdblist.REC_ENCODE_QUE
566 tnow = datetime.datetime.now()
568 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
570 if status.getB25Decoding() < 2:
571 pin = recpath + "/" + title
572 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
573 recdb.reserveReckey(typetxting, title, chtxt, btime, etime, opt)
574 tv2avi.b252ts(pin, chtxt, btime, etime, opt)
575 recdb.deleteReckey(typetxting, title, chtxt, btime)
576 if not os.access(recpath + "/" + title + ".ts", os.F_OK):
577 recdb.deleteReckey(typetxting, title, chtxt, btime)
578 recdb.reserveReckey(typetxtmiss, title, chtxt, btime, etime, opt)
580 auto_process.deleteTmpFile(recpath, title, ".ts")
581 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
582 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
584 if not re.search("D", opt):
585 tnow = datetime.datetime.now()
586 bt = tnow + datetime.timedelta(seconds=600)
588 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
589 etime = et.strftime("%Y-%m-%d %H:%M:%S")
590 recdb.reserveReckey(typetxtencque, title, chtxt, btime, etime, opt)
594 shutil.copy(os.path.join(recpath,title+".ts"), os.path.join(movepath,title+".ts"))
598 os.chmod(os.path.join(movepath,title+".ts"),0777)
601 recque.writeRecQue(movepath, chtxt, title, opt)
603 os.chmod(os.path.join(movepath,title+".recq"),0777)
607 if os.path.getsize(os.path.join(recpath,title+".ts"))==os.path.getsize(os.path.join(movepath,title+".ts")):
608 os.remove(os.path.join(recpath,title+".ts"))
609 except Exception, inst:
610 errtxt1="move ts error.\n"
611 errtxt2=str(type(inst))+"\n"
612 errtxt2=errtxt2+str(inst)
613 recdblist.addCommonlogEX("Error", "type_decode_que(timerec.py)", errtxt1,errtxt2+traceback.format_exc(),log_level=200)
614 recdb.reserveReckey(recdblist.REC_MOVE_END, title, chtxt, btime, etime, opt)
616 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
617 bt = bt + datetime.timedelta(seconds=600)
618 et = et + datetime.timedelta(seconds=600)
619 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
620 etime = et.strftime("%Y-%m-%d %H:%M:%S")
621 recdb.reserveReckey(typetxtnow, title, chtxt, btime, etime, opt)
624 def type_encode_que(typetxt,chtxt,title,bt,et,opt):
625 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
626 etime = et.strftime("%Y-%m-%d %H:%M:%S")
627 tnow = datetime.datetime.now()
629 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
633 if typetxt==recdblist.REC_ENCODE_QUE:
634 typetxting=recdblist.REC_ENCODE_LOCAL
635 typetxtfin=recdblist.REC_FIN_LOCAL
637 if status.getEncoding() < int(configreader.getConfEnv("enc_max")):
638 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
639 recdb.reserveReckey(typetxting, title, chtxt, btime, etime, opt)
640 recdblist.printutf8(opt)
641 pin = recpath + "/" + title + ".ts"
642 if re.search("d", opt):
643 pin = recpath + "/" + title + ".m2v"
644 if not os.path.exists(pin) or os.path.getsize(pin)<100*1000:
645 paac2 = recpath + "/" + title + "_2.aac"
646 pmp32 = recpath + "/" + title + "_2.mp3"
647 if not os.path.exists(paac2) and not os.path.exists(pmp32):
648 tv2audio.ts2dualaudio_BonTsDemux(os.path.join(recpath, title+".ts"),recdblist.BONTSDEMUX_DELAY,opt)
650 elif re.search("5", opt):
651 pin = recpath + "/" + title + ".m2v"
652 if not os.path.exists(pin) or os.path.getsize(pin)<100*1000:
653 paac2 = recpath + "/" + title + "_2.aac"
654 pmp32 = recpath + "/" + title + "_2.mp3"
655 if not os.path.exists(paac2) and not os.path.exists(pmp32):
656 tv2audio.ts2pentaaudio_BonTsDemux(os.path.join(recpath, title+".ts"), recdblist.BONTSDEMUX_DELAY, opt)
658 elif re.search("b", opt):
659 pin = recpath + "/" + title + ".m2v"
660 if not os.path.exists(pin) or os.path.getsize(pin)<100*1000:
661 paac2 = recpath + "/" + title + ".aac"
662 pmp32 = recpath + "/" + title + ".mp3"
663 if not os.path.exists(paac2) and not os.path.exists(pmp32):
664 tv2audio.ts2single_fp_BonTsDemux(os.path.join(recpath, title+".ts"),opt)
668 if configreader.getConfEnv("make_mp4")=="1":
672 if re.search("m", opt):
674 if re.search("4", opt):
676 recdblist.printutf8(pin)
677 if not re.search("0", opt):
679 pout = recpath + "/" + title + ".mp4"
680 tv2mp4.ts2mp4(pin, pout, opt)
682 pout = recpath + "/" + title + ".mkv"
683 tv2mkv.ts2mkv(pin, pout, opt)
684 if re.search("1", opt) or re.search("2", opt):
685 optt=opt.replace("1","MW1")
686 optt=optt.replace("2","MW2")
687 poutt = recpath + "/" + "m_"+title + ".mp4"
688 if re.search("d", opt) or re.search("5", opt):
689 if os.path.exists(os.path.join(recpath, "m_"+title+".m2v")):
690 shutil.move(os.path.join(recpath, title+".m2v"),os.path.join(recpath, "m_"+title+".m2v"))
691 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.aac")):
692 shutil.move(os.path.join(recpath, title+"_1.aac"),os.path.join(recpath, "m_"+title+"_1.aac"))
693 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.mp3")):
694 shutil.move(os.path.join(recpath, title+"_1.mp3"),os.path.join(recpath, "m_"+title+"_1.mp3"))
695 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.aac")):
696 shutil.move(os.path.join(recpath, title+"_2.aac"),os.path.join(recpath, "m_"+title+"_2.aac"))
697 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.mp3")):
698 shutil.move(os.path.join(recpath, title+"_2.mp3"),os.path.join(recpath, "m_"+title+"_2.mp3"))
699 shutil.move(os.path.join(recpath, title+".ts"),os.path.join(recpath, "m_"+title+".ts"))
700 tv2mp4.ts2mp4(os.path.join(recpath, "m_"+title+".ts"), poutt, optt)
701 shutil.move(os.path.join(recpath, "m_"+title+".ts"),os.path.join(recpath, title+".ts"))
704 poutt = recpath + "/" + "m_"+title + ".mp4"
705 shutil.move(os.path.join(recpath, title+".ts"),os.path.join(recpath, "m_"+title+".ts"))
706 if re.search("d", opt) or re.search("5", opt):
707 if os.path.exists(os.path.join(recpath, "m_"+title+".m2v")):
708 shutil.move(os.path.join(recpath, title+".m2v"),os.path.join(recpath, "m_"+title+".m2v"))
709 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.aac")):
710 shutil.move(os.path.join(recpath, title+"_1.aac"),os.path.join(recpath, "m_"+title+"_1.aac"))
711 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.mp3")):
712 shutil.move(os.path.join(recpath, title+"_1.mp3"),os.path.join(recpath, "m_"+title+"_1.mp3"))
713 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.aac")):
714 shutil.move(os.path.join(recpath, title+"_2.aac"),os.path.join(recpath, "m_"+title+"_2.aac"))
715 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.mp3")):
716 shutil.move(os.path.join(recpath, title+"_2.mp3"),os.path.join(recpath, "m_"+title+"_2.mp3"))
717 tv2mp4.ts2mp4(os.path.join(recpath, "m_"+title+".ts"), poutt, optt)
718 shutil.move(os.path.join(recpath, "m_"+title+".ts"),os.path.join(recpath, title+".ts"))
719 recdb.deleteReckey(typetxting, title, chtxt, btime)
721 if re.search("E", opt):
723 if os.path.exists(os.path.join(recpath,title+".mp4")):
725 shutil.copy(os.path.join(recpath,title+".mp4"), os.path.join(movepath,title+".mp4"))
729 os.chmod(os.path.join(movepath,title+".mp4"),0777)
732 recque.writeRecQue(movepath, chtxt, title, opt)
734 os.chmod(os.path.join(movepath,title+".recq"),0777)
737 elif os.path.exists(os.path.join(recpath,title+".mkv")):
739 shutil.copy(os.path.join(recpath,title+".mkv"), os.path.join(movepath,title+".mkv"))
743 os.chmod(os.path.join(movepath,title+".mkv"),0777)
746 recque.writeRecQue(movepath, chtxt, title, opt)
748 os.chmod(os.path.join(movepath,title+".recq"),0777)
751 except Exception, inst:
752 errtxt1="move mkv/mp4 error."
753 errtxt2=str(type(inst))+"\n"
754 errtxt2=errtxt2+str(inst)
755 recdblist.addCommonlogEX("Error", "type_encode_que(timerec.py)", errtxt1,errtxt2+traceback.format_exc(),log_level=200)
756 recdb.reserveReckey(recdblist.REC_MOVE_END, title, chtxt, btime, etime, opt)
757 recdb.reserveReckey(typetxtfin, title, chtxt, btime, etime, opt)
760 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
761 bt = bt + datetime.timedelta(seconds=600)
762 et = et + datetime.timedelta(seconds=600)
763 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
764 etime = et.strftime("%Y-%m-%d %H:%M:%S")
765 recdb.reserveReckey(typetxtnow, title, chtxt, btime, etime, opt)