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:
306 topt=status.getSettings_auto_opt()
309 ch=chdb.searchCHFromChtxt(chtxtt)
311 maxnum=epgdb.countSchedule(btimet, etimet)[1]
312 maxnum=int(configreader.getConfEnv("bscs_max"))-maxnum
314 maxnum=epgdb.countSchedule(btimet, etimet)[0]
315 maxnum=int(configreader.getConfEnv("te_max"))-maxnum
317 if recdb.checkDuplicated(titlet, chtxtt, btimet, etimet)==0:
318 recdb.reserveReckey(recdblist.REC_RESERVE,titlet,chtxtt, btimet, etimet,topt)
319 except Exception, inst:
320 recdblist.addCommonlogEX("Error", "search_keyword_auto_jbk(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
322 recdb.reserveAutoKeyword(chtxtt, titlet, btimet, etimet)
323 except Exception, inst:
324 recdblist.addCommonlogEX("Error", "search_keyword(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
325 def type_reserve(typetxt,chtxt,title,bt,et,opt):
326 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
327 etime = et.strftime("%Y-%m-%d %H:%M:%S")
330 if typetxt==recdblist.REC_RESERVE:
331 typetxtfinal=recdblist.REC_FINAL_RESERVE
332 tnow = datetime.datetime.now()
334 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
335 if (dt < 58 * 60 and dt > 30 * 60):
336 bctypet = chdb.searchCHFromChtxt(chtxt)['bctype']
337 chdatat = rec10d.rec10db.select_by_bctype_epg_ch(bctypet)
338 dt1 = bt - datetime.datetime.strptime(chdatat[0][4], "%Y-%m-%d %H:%M:%S")
339 dt1 = dt1.days * 24 * 60 * 60 + dt1.seconds
341 recdata = epgdb.searchTime(title, btime, "5", chtxt)
349 bt = datetime.datetime.strptime(btimen, "%Y-%m-%d %H:%M:%S")
350 et = datetime.datetime.strptime(etimen, "%Y-%m-%d %H:%M:%S")
351 btimen = bt.strftime("%Y-%m-%d %H:%M:%S")
352 etimen = et.strftime("%Y-%m-%d %H:%M:%S")
355 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
356 recdb.reserveReckey(typetxtfinal, titlen, chtxtn, btimen, etimen, opt)
357 recdb.addRecLogProgram(titlen, chtxtn, btimen, etimen, opt, exp, longexp, category)
358 auto_rec.addKey(chtxt, titlen,exp+" "+longexp)
359 auto_rec.addKey("ALL", titlen,exp+" "+longexp)
360 recdblist.printutf8(u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen)
361 except Exception, inst:
362 recdblist.addCommonlogEX("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
364 recdblist.printutf8(u"追いかけ機能エラー:番組データが見付かりません。")
366 if rec10d.rec10db.select_by_bctype_epg_ch(bctypet)[0][5] != "0":
367 rec10d.rec10db.update_status_by_bctype_epg_ch(bctypet, "3")
369 elif (dt <= 30 * 60 and dt > 20 * 60):
370 recdata = epgdb.searchTime(title, btime, "5", chtxt)
378 bt = datetime.datetime.strptime(btimen, "%Y-%m-%d %H:%M:%S")
379 et = datetime.datetime.strptime(etimen, "%Y-%m-%d %H:%M:%S")
380 btimen = bt.strftime("%Y-%m-%d %H:%M:%S")
381 etimen = et.strftime("%Y-%m-%d %H:%M:%S")
384 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
385 recdb.reserveReckey(typetxtfinal, titlen, chtxtn, btimen, etimen, opt)
386 recdb.addRecLogProgram(titlen, chtxtn, btimen, etimen, opt, exp, longexp, category)
387 auto_rec.addKey(chtxt, titlen,exp+" "+longexp)
388 auto_rec.addKey("ALL", titlen,exp+" "+longexp)
389 #recdblist.printutf8(u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen)
390 recdblist.addCommonlogEX(u"通常", "Oikake (timerec.py)",u"追いかけ機能実行中",u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen,log_level=500)
391 except Exception, inst:
392 recdblist.addCommonlogEX("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
395 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
396 recdb.reserveReckey(typetxtfinal, title, chtxt, btime, etime, opt)
397 except Exception, inst:
398 recdblist.addCommonlogEX("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
399 def type_final(typetxt,chtxt,title,bt,et,opt):
400 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
401 etime = et.strftime("%Y-%m-%d %H:%M:%S")
405 if typetxt==recdblist.REC_FINAL_RESERVE:
406 typetxting=recdblist.REC_TS_RECORDING
407 typetxtdecque=recdblist.REC_TS_DECODE_QUE
408 tnow = datetime.datetime.now()
410 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
411 if dt < 6 * 60 and dt > 0:
413 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
414 testpath=[os.path.join(recpath,title+".ts.b25")]
415 testpath.append(os.path.join(recpath,title+".ts"))
416 testpath.append(os.path.join(recpath,title+".avi"))
417 testpath.append(os.path.join(recpath,title+".mp4"))
418 testpath.append(os.path.join(recpath,title+".log"))
421 if os.path.exists(ti):
423 if re.search("N", opt) or tcheck>0:
426 iff=u"("+configreader.getConfEnv("iff")+u")_"
430 newtitle=newtitle+u"_"+iff+newtime.strftime("%Y-%m-%dT%H-%M-%S")
431 recdb.reserveReckey(typetxting, newtitle, chtxt, btime, etime, opt)
432 recdblist.addCommonlogEX(u"通常","timerec.py",u"録画開始 "+newtitle+" "+btime+" "+etime,"",log_level=500)
433 tv2avi.timetv2b25(recpath + "/" + newtitle + ".avi", chtxt, btime, etime, opt)
434 recdb.deleteReckey(typetxting, newtitle, chtxt, btime)
435 if not re.search("R", opt):
436 tnow = datetime.datetime.now()
437 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
438 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
440 bt = tnow + datetime.timedelta(seconds=600)
441 et = et + dt + datetime.timedelta(seconds=600)
442 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
443 etime = et.strftime("%Y-%m-%d %H:%M:%S")
444 recdb.reserveReckey(typetxtdecque, newtitle, chtxt, btime, etime, opt)
448 shutil.copy(os.path.join(recpath,title+".ts.b25"), os.path.join(movepath,title+".ts.b25"))
452 os.chmod(os.path.join(movepath,title+".ts.b25"),0777)
455 recque.writeRecQue(movepath, chtxt, title, opt)
457 os.chmod(os.path.join(movepath,title+".recq"),0777)
460 except Exception, inst:
461 recdblist.addCommonlogEX("Error", "Move option(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
462 recdb.reserveReckey(recdblist.REC_MOVE_END, newtitle, chtxt, btime, etime, opt)
464 def type_keyword(typetxt,chtxt,title,bt,et,opt,deltatime):
465 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
466 etime = et.strftime("%Y-%m-%d %H:%M:%S")
469 if typetxt==recdblist.REC_KEYWORD:
470 typetxtres=recdblist.REC_RESERVE
471 tnow = datetime.datetime.now()
473 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
474 recdblist.printutf8(str(dt), verbose_level=800)
475 if dt <= 90 * 60 and dt > 70 * 60:
476 recdata = epgdb.searchTime(title, btime, deltatime, chtxt)
485 bt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
486 et = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
487 btimet = bt.strftime("%Y-%m-%d %H:%M:%S")
488 etimet = et.strftime("%Y-%m-%d %H:%M:%S")
490 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
491 recdb.reserveReckey(typetxtres, titlet, chtxt, btimet, etimet, opt)
492 recdb.addRecLogProgram(titlet, chtxtt, btimet, etimet, opt, exp,longexp,category)
493 auto_rec.addKey(chtxt, titlet,exp+" "+longexp)
494 auto_rec.addKey("ALL", titlet,exp+" "+longexp)
495 recdblist.addCommonlogEX(u"通常","timerec.py",u"key "+title+u" : "+titlet+u" "+btimet+u" "+etimet,"",log_level=500)
496 #except Exception, inst:
497 # recdblist.printutf8("Error happened in REC_KEYWORD DB")
498 # recdblist.printutf8(type(inst))
499 # recdblist.printutf8(inst)
501 recdblist.printutf8("nothing match")
503 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
504 recdb.reserveReckey(typetxtres, title, chtxt, btime, etime, opt)
505 recdblist.addCommonlogEX(u"エラー","timerec.py",u"nothing match","",log_level=200)
506 recdblist.addCommonlogEX(u"エラー","timerec.py",u"key "+title+u" "+btime+u" "+etime,"",log_level=200)
507 def type_keyword_every_day(type,chtxt,title,bt,et,opt,deltatime,deltaday,counter):
508 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
509 etime = et.strftime("%Y-%m-%d %H:%M:%S")
510 tnow = datetime.datetime.now()
512 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
513 dd = datetime.timedelta(days=int(deltaday))
515 recdb.deleteReckey(recdblist.REC_KEYWORD_EVERY_SOME_DAYS, title, chtxt, btime)
518 btxt = bt.strftime("%Y-%m-%d %H:%M:%S")
519 etxt = et.strftime("%Y-%m-%d %H:%M:%S")
521 recdb.reserveEverydayKeyword(title, chtxt, btxt, etxt, deltatime, opt, deltaday,counter-1)
523 recdb.reserveEverydayKeyword(title, chtxt, btxt, etxt, deltatime, opt, deltaday,-1)
525 recdb.deleteReckey(recdblist.REC_KEYWORD_EVERY_SOME_DAYS, title, chtxt, btime)
528 btxt = bt.strftime("%Y-%m-%d %H:%M:%S")
529 etxt = et.strftime("%Y-%m-%d %H:%M:%S")
531 recdb.reserveEverydayKeyword(title, chtxt, btxt, etxt, deltatime, opt, deltaday,counter-1)
533 recdb.reserveEverydayKeyword(title, chtxt, btxt, etxt, deltatime, opt, deltaday,-1)
534 recdata = epgdb.searchTime(title, btime, deltatime, chtxt)
543 bt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
544 et = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
545 btimet = bt.strftime("%Y-%m-%d %H:%M:%S")
546 etimet = et.strftime("%Y-%m-%d %H:%M:%S")
548 recdb.reserveKeyword(titlet, chtxt, btimet, etimet, deltatime, opt)
550 recdb.reserveKeyword(title, chtxt, btime, etime, deltatime, opt)
551 def type_decode_que(typetxt,chtxt,title,bt,et,opt):
552 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
553 etime = et.strftime("%Y-%m-%d %H:%M:%S")
554 tnow = datetime.datetime.now()
556 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
561 if typetxt== recdblist.REC_TS_DECODE_QUE:
562 typetxting=recdblist.REC_TS_DECODING
563 typetxtmiss=recdblist.REC_MISS_DECODE
564 typetxtencque=recdblist.REC_ENCODE_QUE
565 tnow = datetime.datetime.now()
567 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
569 if status.getB25Decoding() < 2:
570 pin = recpath + "/" + title
571 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
572 recdb.reserveReckey(typetxting, title, chtxt, btime, etime, opt)
573 tv2avi.b252ts(pin, chtxt, btime, etime, opt)
574 recdb.deleteReckey(typetxting, title, chtxt, btime)
575 if not os.access(recpath + "/" + title + ".ts", os.F_OK):
576 recdb.deleteReckey(typetxting, title, chtxt, btime)
577 recdb.reserveReckey(typetxtmiss, title, chtxt, btime, etime, opt)
579 auto_process.deleteTmpFile(recpath, title, ".ts")
580 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
581 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
583 if not re.search("D", opt):
584 tnow = datetime.datetime.now()
585 bt = tnow + datetime.timedelta(seconds=600)
587 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
588 etime = et.strftime("%Y-%m-%d %H:%M:%S")
589 recdb.reserveReckey(typetxtencque, title, chtxt, btime, etime, opt)
593 shutil.copy(os.path.join(recpath,title+".ts"), os.path.join(movepath,title+".ts"))
597 os.chmod(os.path.join(movepath,title+".ts"),0777)
600 recque.writeRecQue(movepath, chtxt, title, opt)
602 os.chmod(os.path.join(movepath,title+".recq"),0777)
606 if os.path.getsize(os.path.join(recpath,title+".ts"))==os.path.getsize(os.path.join(movepath,title+".ts")):
607 os.remove(os.path.join(recpath,title+".ts"))
608 except Exception, inst:
609 errtxt1="move ts error.\n"
610 errtxt2=str(type(inst))+"\n"
611 errtxt2=errtxt2+str(inst)
612 recdblist.addCommonlogEX("Error", "type_decode_que(timerec.py)", errtxt1,errtxt2+traceback.format_exc(),log_level=200)
613 recdb.reserveReckey(recdblist.REC_MOVE_END, title, chtxt, btime, etime, opt)
615 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
616 bt = bt + datetime.timedelta(seconds=600)
617 et = et + datetime.timedelta(seconds=600)
618 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
619 etime = et.strftime("%Y-%m-%d %H:%M:%S")
620 recdb.reserveReckey(typetxtnow, title, chtxt, btime, etime, opt)
623 def type_encode_que(typetxt,chtxt,title,bt,et,opt):
624 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
625 etime = et.strftime("%Y-%m-%d %H:%M:%S")
626 tnow = datetime.datetime.now()
628 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
632 if typetxt==recdblist.REC_ENCODE_QUE:
633 typetxting=recdblist.REC_ENCODE_LOCAL
634 typetxtfin=recdblist.REC_FIN_LOCAL
636 if status.getEncoding() < int(configreader.getConfEnv("enc_max")):
637 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
638 recdb.reserveReckey(typetxting, title, chtxt, btime, etime, opt)
639 recdblist.printutf8(opt)
640 pin = recpath + "/" + title + ".ts"
641 if re.search("d", opt):
642 pin = recpath + "/" + title + ".m2v"
643 if not os.path.exists(pin) or os.path.getsize(pin)<100*1000:
644 paac2 = recpath + "/" + title + "_2.aac"
645 pmp32 = recpath + "/" + title + "_2.mp3"
646 if not os.path.exists(paac2) and not os.path.exists(pmp32):
647 tv2audio.ts2dualaudio_BonTsDemux(os.path.join(recpath, title+".ts"),recdblist.BONTSDEMUX_DELAY,opt)
649 elif re.search("5", opt):
650 pin = recpath + "/" + title + ".m2v"
651 if not os.path.exists(pin) or os.path.getsize(pin)<100*1000:
652 paac2 = recpath + "/" + title + "_2.aac"
653 pmp32 = recpath + "/" + title + "_2.mp3"
654 if not os.path.exists(paac2) and not os.path.exists(pmp32):
655 tv2audio.ts2pentaaudio_BonTsDemux(os.path.join(recpath, title+".ts"), recdblist.BONTSDEMUX_DELAY, opt)
657 elif re.search("b", opt):
658 pin = recpath + "/" + title + ".m2v"
659 if not os.path.exists(pin) or os.path.getsize(pin)<100*1000:
660 paac2 = recpath + "/" + title + ".aac"
661 pmp32 = recpath + "/" + title + ".mp3"
662 if not os.path.exists(paac2) and not os.path.exists(pmp32):
663 tv2audio.ts2single_fp_BonTsDemux(os.path.join(recpath, title+".ts"),opt)
667 if configreader.getConfEnv("make_mp4")=="1":
671 if re.search("m", opt):
673 if re.search("4", opt):
675 recdblist.printutf8(pin)
676 if not re.search("0", opt):
678 pout = recpath + "/" + title + ".mp4"
679 tv2mp4.ts2mp4(pin, pout, opt)
681 pout = recpath + "/" + title + ".mkv"
682 tv2mkv.ts2mkv(pin, pout, opt)
683 if re.search("1", opt) or re.search("2", opt):
684 optt=opt.replace("1","MW1")
685 optt=optt.replace("2","MW2")
686 poutt = recpath + "/" + "m_"+title + ".mp4"
687 if re.search("d", opt) or re.search("5", opt):
688 if os.path.exists(os.path.join(recpath, "m_"+title+".m2v")):
689 shutil.move(os.path.join(recpath, title+".m2v"),os.path.join(recpath, "m_"+title+".m2v"))
690 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.aac")):
691 shutil.move(os.path.join(recpath, title+"_1.aac"),os.path.join(recpath, "m_"+title+"_1.aac"))
692 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.mp3")):
693 shutil.move(os.path.join(recpath, title+"_1.mp3"),os.path.join(recpath, "m_"+title+"_1.mp3"))
694 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.aac")):
695 shutil.move(os.path.join(recpath, title+"_2.aac"),os.path.join(recpath, "m_"+title+"_2.aac"))
696 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.mp3")):
697 shutil.move(os.path.join(recpath, title+"_2.mp3"),os.path.join(recpath, "m_"+title+"_2.mp3"))
698 shutil.move(os.path.join(recpath, title+".ts"),os.path.join(recpath, "m_"+title+".ts"))
699 tv2mp4.ts2mp4(os.path.join(recpath, "m_"+title+".ts"), poutt, optt)
700 shutil.move(os.path.join(recpath, "m_"+title+".ts"),os.path.join(recpath, title+".ts"))
703 poutt = recpath + "/" + "m_"+title + ".mp4"
704 shutil.move(os.path.join(recpath, title+".ts"),os.path.join(recpath, "m_"+title+".ts"))
705 if re.search("d", opt) or re.search("5", opt):
706 if os.path.exists(os.path.join(recpath, "m_"+title+".m2v")):
707 shutil.move(os.path.join(recpath, title+".m2v"),os.path.join(recpath, "m_"+title+".m2v"))
708 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.aac")):
709 shutil.move(os.path.join(recpath, title+"_1.aac"),os.path.join(recpath, "m_"+title+"_1.aac"))
710 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.mp3")):
711 shutil.move(os.path.join(recpath, title+"_1.mp3"),os.path.join(recpath, "m_"+title+"_1.mp3"))
712 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.aac")):
713 shutil.move(os.path.join(recpath, title+"_2.aac"),os.path.join(recpath, "m_"+title+"_2.aac"))
714 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.mp3")):
715 shutil.move(os.path.join(recpath, title+"_2.mp3"),os.path.join(recpath, "m_"+title+"_2.mp3"))
716 tv2mp4.ts2mp4(os.path.join(recpath, "m_"+title+".ts"), poutt, optt)
717 shutil.move(os.path.join(recpath, "m_"+title+".ts"),os.path.join(recpath, title+".ts"))
718 recdb.deleteReckey(typetxting, title, chtxt, btime)
720 if re.search("E", opt):
722 if os.path.exists(os.path.join(recpath,title+".mp4")):
724 shutil.copy(os.path.join(recpath,title+".mp4"), os.path.join(movepath,title+".mp4"))
728 os.chmod(os.path.join(movepath,title+".mp4"),0777)
731 recque.writeRecQue(movepath, chtxt, title, opt)
733 os.chmod(os.path.join(movepath,title+".recq"),0777)
736 elif os.path.exists(os.path.join(recpath,title+".mkv")):
738 shutil.copy(os.path.join(recpath,title+".mkv"), os.path.join(movepath,title+".mkv"))
742 os.chmod(os.path.join(movepath,title+".mkv"),0777)
745 recque.writeRecQue(movepath, chtxt, title, opt)
747 os.chmod(os.path.join(movepath,title+".recq"),0777)
750 except Exception, inst:
751 errtxt1="move mkv/mp4 error."
752 errtxt2=str(type(inst))+"\n"
753 errtxt2=errtxt2+str(inst)
754 recdblist.addCommonlogEX("Error", "type_encode_que(timerec.py)", errtxt1,errtxt2+traceback.format_exc(),log_level=200)
755 recdb.reserveReckey(recdblist.REC_MOVE_END, title, chtxt, btime, etime, opt)
756 recdb.reserveReckey(typetxtfin, title, chtxt, btime, etime, opt)
759 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
760 bt = bt + datetime.timedelta(seconds=600)
761 et = et + datetime.timedelta(seconds=600)
762 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
763 etime = et.strftime("%Y-%m-%d %H:%M:%S")
764 recdb.reserveReckey(typetxtnow, title, chtxt, btime, etime, opt)