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.printuft8ex("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(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")==1:
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 tv2mkv.raw2mkv(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mkv"),opt)
246 recdb.deleteReckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime)
248 elif task["type"] == recdblist.REC_AVI_TO_MP4:
256 if configreader.getConfEnv("make_mp4")==1:
260 if re.search("m", opt):
262 if re.search("4", opt):
264 recdb.deleteReckey(recdblist.REC_AVI_TO_MP4, title, chtxt, btime)
265 recdb.reserveReckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
267 tv2mp4.ts2mp4(pin, pout, opt)
268 tv2mp4.raw2mp4(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mp4"),opt)
270 tv2mkv.raw2mkv(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mkv"),opt)
271 recdb.deleteReckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime)
273 elif task["type"] == recdblist.REC_MKV_TO_MP4:
279 recdb.deleteReckey(recdblist.REC_MKV_TO_MP4, title, chtxt, btime)
280 recdb.reserveReckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
281 tv2mp4.mkv2mp4(os.path.join(recpath,title+".mkv"),os.path.join(recpath,title+".mp4"))
282 recdb.deleteReckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime)
285 def search_keyword(key):
286 tnow = datetime.datetime.now()
287 nows =tnow.strftime("%Y-%m-%d %H:%M:%S")
288 for k,auto,opt in key:
289 recdatum = epgdb.searchTimeAuto(k,nows, "144")
290 for recdata in recdatum:
296 btt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
297 ett = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
298 btimet = btt.strftime("%Y-%m-%d %H:%M:%S")
299 etimet = ett.strftime("%Y-%m-%d %H:%M:%S")
300 #if status.getSettings_auto_jbk()==1:
301 if auto==1 or status.getSettings_auto_jbk()==1:
304 topt=status.getSettings_auto_opt()
307 ch=chdb.searchCHFromChtxt(chtxtt)
309 maxnum=epgdb.countSchedule(btimet, etimet)[1]
310 maxnum=int(configreader.getConfEnv("bscs_max"))-maxnum
312 maxnum=epgdb.countSchedule(btimet, etimet)[0]
313 maxnum=int(configreader.getConfEnv("te_max"))-maxnum
315 if recdb.checkDuplicated(titlet, chtxtt, btimet, etimet)==0:
316 recdb.reserveReckey(recdblist.REC_RESERVE,titlet,chtxtt, btimet, etimet,topt)
317 except Exception, inst:
318 recdblist.addCommonlogEX("Error", "search_keyword_auto_jbk(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
320 recdb.reserveAutoKeyword(chtxtt, titlet, btimet, etimet)
321 except Exception, inst:
322 recdblist.addCommonlogEX("Error", "search_keyword(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
323 def type_reserve(typetxt,chtxt,title,bt,et,opt):
324 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
325 etime = et.strftime("%Y-%m-%d %H:%M:%S")
328 if typetxt==recdblist.REC_RESERVE:
329 typetxtfinal=recdblist.REC_FINAL_RESERVE
330 tnow = datetime.datetime.now()
332 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
333 if (dt < 58 * 60 and dt > 30 * 60):
334 bctypet = chdb.searchCHFromChtxt(chtxt)['bctype']
335 chdatat = rec10d.rec10db.select_by_bctype_epg_ch(bctypet)
336 dt1 = bt - datetime.datetime.strptime(chdatat[0][4], "%Y-%m-%d %H:%M:%S")
337 dt1 = dt1.days * 24 * 60 * 60 + dt1.seconds
339 recdata = epgdb.searchTime(title, btime, "5", chtxt)
347 bt = datetime.datetime.strptime(btimen, "%Y-%m-%d %H:%M:%S")
348 et = datetime.datetime.strptime(etimen, "%Y-%m-%d %H:%M:%S")
349 btimen = bt.strftime("%Y-%m-%d %H:%M:%S")
350 etimen = et.strftime("%Y-%m-%d %H:%M:%S")
353 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
354 recdb.reserveReckey(typetxtfinal, titlen, chtxtn, btimen, etimen, opt)
355 recdb.addRecLogProgram(titlen, chtxtn, btimen, etimen, opt, exp, longexp, category)
356 auto_rec.addKey(chtxt, titlen,exp+" "+longexp)
357 auto_rec.addKey("ALL", titlen,exp+" "+longexp)
358 recdblist.printutf8(u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen)
359 except Exception, inst:
360 recdblist.addCommonlogEX("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
362 recdblist.printutf8(u"追いかけ機能エラー:番組データが見付かりません。")
364 if rec10d.rec10db.select_by_bctype_epg_ch(bctypet)[0][5] != "0":
365 rec10d.rec10db.update_status_by_bctype_epg_ch(bctypet, "3")
367 elif (dt <= 30 * 60 and dt > 20 * 60):
368 recdata = epgdb.searchTime(title, btime, "5", chtxt)
376 bt = datetime.datetime.strptime(btimen, "%Y-%m-%d %H:%M:%S")
377 et = datetime.datetime.strptime(etimen, "%Y-%m-%d %H:%M:%S")
378 btimen = bt.strftime("%Y-%m-%d %H:%M:%S")
379 etimen = et.strftime("%Y-%m-%d %H:%M:%S")
382 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
383 recdb.reserveReckey(typetxtfinal, titlen, chtxtn, btimen, etimen, opt)
384 recdb.addRecLogProgram(titlen, chtxtn, btimen, etimen, opt, exp, longexp, category)
385 auto_rec.addKey(chtxt, titlen,exp+" "+longexp)
386 auto_rec.addKey("ALL", titlen,exp+" "+longexp)
387 #recdblist.printutf8(u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen)
388 recdblist.addCommonlogEX(u"通常", "Oikake (timerec.py)",u"追いかけ機能実行中",u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen,log_level=500)
389 except Exception, inst:
390 recdblist.addCommonlogEX("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
393 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
394 recdb.reserveReckey(typetxtfinal, title, chtxt, btime, etime, opt)
395 except Exception, inst:
396 recdblist.addCommonlogEX("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
397 def type_final(typetxt,chtxt,title,bt,et,opt):
398 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
399 etime = et.strftime("%Y-%m-%d %H:%M:%S")
403 if typetxt==recdblist.REC_FINAL_RESERVE:
404 typetxting=recdblist.REC_TS_RECORDING
405 typetxtdecque=recdblist.REC_TS_DECODE_QUE
406 tnow = datetime.datetime.now()
408 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
409 if dt < 6 * 60 and dt > 0:
411 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
412 testpath=[os.path.join(recpath,title+".ts.b25")]
413 testpath.append(os.path.join(recpath,title+".ts"))
414 testpath.append(os.path.join(recpath,title+".avi"))
415 testpath.append(os.path.join(recpath,title+".mp4"))
416 testpath.append(os.path.join(recpath,title+".log"))
419 if os.path.exists(ti):
421 if re.search("N", opt) or tcheck>0:
424 iff=u"("+configreader.getConfEnv("iff")+u")_"
428 newtitle=newtitle+u"_"+iff+newtime.strftime("%Y-%m-%dT%H-%M-%S")
429 recdb.reserveReckey(typetxting, newtitle, chtxt, btime, etime, opt)
430 recdblist.addCommonlogEX(u"通常","timerec.py",u"録画開始 "+newtitle+" "+btime+" "+etime,"",log_level=500)
431 tv2avi.timetv2b25(recpath + "/" + newtitle + ".avi", chtxt, btime, etime, opt)
432 recdb.deleteReckey(typetxting, newtitle, chtxt, btime)
433 if not re.search("R", opt):
434 tnow = datetime.datetime.now()
435 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
436 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
438 bt = tnow + datetime.timedelta(seconds=600)
439 et = et + dt + datetime.timedelta(seconds=600)
440 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
441 etime = et.strftime("%Y-%m-%d %H:%M:%S")
442 recdb.reserveReckey(typetxtdecque, newtitle, chtxt, btime, etime, opt)
446 shutil.copy(os.path.join(recpath,title+".ts.b25"), os.path.join(movepath,title+".ts.b25"))
450 os.chmod(os.path.join(movepath,title+".ts.b25"),0777)
453 recque.writeRecQue(movepath, chtxt, title, opt)
455 os.chmod(os.path.join(movepath,title+".recq"),0777)
458 except Exception, inst:
459 recdblist.addCommonlogEX("Error", "Move option(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
460 recdb.reserveReckey(recdblist.REC_MOVE_END, newtitle, chtxt, btime, etime, opt)
462 def type_keyword(typetxt,chtxt,title,bt,et,opt,deltatime):
463 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
464 etime = et.strftime("%Y-%m-%d %H:%M:%S")
467 if typetxt==recdblist.REC_KEYWORD:
468 typetxtres=recdblist.REC_RESERVE
469 tnow = datetime.datetime.now()
471 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
472 recdblist.printutf8(str(dt), verbose_level=800)
473 if dt <= 90 * 60 and dt > 70 * 60:
474 recdata = epgdb.searchTime(title, btime, deltatime, chtxt)
483 bt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
484 et = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
485 btimet = bt.strftime("%Y-%m-%d %H:%M:%S")
486 etimet = et.strftime("%Y-%m-%d %H:%M:%S")
488 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
489 recdb.reserveReckey(typetxtres, titlet, chtxt, btimet, etimet, opt)
490 recdb.addRecLogProgram(titlet, chtxtt, btimet, etimet, opt, exp,longexp,category)
491 auto_rec.addKey(chtxt, titlet,exp+" "+longexp)
492 auto_rec.addKey("ALL", titlet,exp+" "+longexp)
493 recdblist.addCommonlogEX(u"通常","timerec.py",u"key "+title+u" : "+titlet+u" "+btimet+u" "+etimet,"",log_level=500)
494 #except Exception, inst:
495 # recdblist.printutf8("Error happened in REC_KEYWORD DB")
496 # recdblist.printutf8(type(inst))
497 # recdblist.printutf8(inst)
499 recdblist.printutf8("nothing match")
501 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
502 recdb.reserveReckey(typetxtres, title, chtxt, btime, etime, opt)
503 recdblist.addCommonlogEX(u"エラー","timerec.py",u"nothing match","",log_level=200)
504 recdblist.addCommonlogEX(u"エラー","timerec.py",u"key "+title+u" : "+titlet+u" "+btimet+u" "+etimet,"",log_level=200)
505 def type_keyword_every_day(type,chtxt,title,bt,et,opt,deltatime,deltaday,counter):
506 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
507 etime = et.strftime("%Y-%m-%d %H:%M:%S")
508 tnow = datetime.datetime.now()
510 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
511 dd = datetime.timedelta(days=int(deltaday))
513 recdb.deleteReckey(recdblist.REC_KEYWORD_EVERY_SOME_DAYS, title, chtxt, btime)
516 btxt = bt.strftime("%Y-%m-%d %H:%M:%S")
517 etxt = et.strftime("%Y-%m-%d %H:%M:%S")
519 recdb.reserveEverydayKeyword(title, chtxt, btxt, etxt, deltatime, opt, deltaday,counter-1)
521 recdb.reserveEverydayKeyword(title, chtxt, btxt, etxt, deltatime, opt, deltaday,-1)
523 recdb.deleteReckey(recdblist.REC_KEYWORD_EVERY_SOME_DAYS, title, chtxt, btime)
526 btxt = bt.strftime("%Y-%m-%d %H:%M:%S")
527 etxt = et.strftime("%Y-%m-%d %H:%M:%S")
529 recdb.reserveEverydayKeyword(title, chtxt, btxt, etxt, deltatime, opt, deltaday,counter-1)
531 recdb.reserveEverydayKeyword(title, chtxt, btxt, etxt, deltatime, opt, deltaday,-1)
532 recdata = epgdb.searchTime(title, btime, deltatime, chtxt)
541 bt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
542 et = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
543 btimet = bt.strftime("%Y-%m-%d %H:%M:%S")
544 etimet = et.strftime("%Y-%m-%d %H:%M:%S")
546 recdb.reserveKeyword(titlet, chtxt, btimet, etimet, deltatime, opt)
548 recdb.reserveKeyword(title, chtxt, btime, etime, deltatime, opt)
549 def type_decode_que(typetxt,chtxt,title,bt,et,opt):
550 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
551 etime = et.strftime("%Y-%m-%d %H:%M:%S")
552 tnow = datetime.datetime.now()
554 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
559 if typetxt== recdblist.REC_TS_DECODE_QUE:
560 typetxting=recdblist.REC_TS_DECODING
561 typetxtmiss=recdblist.REC_MISS_DECODE
562 typetxtencque=recdblist.REC_ENCODE_QUE
563 tnow = datetime.datetime.now()
565 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
567 if status.getB25Decoding() < 2:
568 pin = recpath + "/" + title
569 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
570 recdb.reserveReckey(typetxting, title, chtxt, btime, etime, opt)
571 tv2avi.b252ts(pin, chtxt, btime, etime, opt)
572 recdb.deleteReckey(typetxting, title, chtxt, btime)
573 if not os.access(recpath + "/" + title + ".ts", os.F_OK):
574 recdb.deleteReckey(typetxting, title, chtxt, btime)
575 recdb.reserveReckey(typetxtmiss, title, chtxt, btime, etime, opt)
577 auto_process.deleteTmpFile(recpath, title, ".ts")
578 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
579 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
581 if not re.search("D", opt):
582 tnow = datetime.datetime.now()
583 bt = tnow + datetime.timedelta(seconds=600)
585 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
586 etime = et.strftime("%Y-%m-%d %H:%M:%S")
587 recdb.reserveReckey(typetxtencque, title, chtxt, btime, etime, opt)
591 shutil.copy(os.path.join(recpath,title+".ts"), os.path.join(movepath,title+".ts"))
595 os.chmod(os.path.join(movepath,title+".ts"),0777)
598 recque.writeRecQue(movepath, chtxt, title, opt)
600 os.chmod(os.path.join(movepath,title+".recq"),0777)
604 if os.path.getsize(os.path.join(recpath,title+".ts"))==os.path.getsize(os.path.join(movepath,title+".ts")):
605 os.remove(os.path.join(recpath,title+".ts"))
606 except Exception, inst:
607 errtxt1="move ts error.\n"
608 errtxt2=str(type(inst))+"\n"
609 errtxt2=errtxt2+str(inst)
610 recdblist.addCommonlogEX("Error", "type_decode_que(timerec.py)", errtxt1,errtxt2+traceback.format_exc(),log_level=200)
611 recdb.reserveReckey(recdblist.REC_MOVE_END, title, chtxt, btime, etime, opt)
613 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
614 bt = bt + datetime.timedelta(seconds=600)
615 et = et + datetime.timedelta(seconds=600)
616 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
617 etime = et.strftime("%Y-%m-%d %H:%M:%S")
618 recdb.reserveReckey(typetxtnow, title, chtxt, btime, etime, opt)
621 def type_encode_que(typetxt,chtxt,title,bt,et,opt):
622 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
623 etime = et.strftime("%Y-%m-%d %H:%M:%S")
624 tnow = datetime.datetime.now()
626 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
630 if typetxt==recdblist.REC_ENCODE_QUE:
631 typetxting=recdblist.REC_ENCODE_LOCAL
632 typetxtfin=recdblist.REC_FIN_LOCAL
634 if status.getEncoding() < int(configreader.getConfEnv("enc_max")):
635 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
636 recdb.reserveReckey(typetxting, title, chtxt, btime, etime, opt)
637 recdblist.printutf8(opt)
638 pin = recpath + "/" + title + ".ts"
639 if re.search("d", opt):
640 pin = recpath + "/" + title + ".m2v"
641 if not os.path.exists(pin) or os.path.getsize(pin)<100*1000:
642 paac2 = recpath + "/" + title + "_2.aac"
643 pmp32 = recpath + "/" + title + "_2.mp3"
644 if not os.path.exists(paac2) and not os.path.exists(pmp32):
645 tv2audio.ts2dualaudio_BonTsDemux(os.path.join(recpath, title+".ts"),recdblist.BONTSDEMUX_DELAY,opt)
647 elif re.search("5", opt):
648 pin = recpath + "/" + title + ".m2v"
649 if not os.path.exists(pin) or os.path.getsize(pin)<100*1000:
650 paac2 = recpath + "/" + title + "_2.aac"
651 pmp32 = recpath + "/" + title + "_2.mp3"
652 if not os.path.exists(paac2) and not os.path.exists(pmp32):
653 tv2audio.ts2pentaaudio_BonTsDemux(os.path.join(recpath, title+".ts"), recdblist.BONTSDEMUX_DELAY, opt)
657 if configreader.getConfEnv("make_mp4")=="1":
661 if re.search("m", opt):
663 if re.search("4", opt):
665 recdblist.printutf8(pin)
666 if not re.search("0", opt):
668 pout = recpath + "/" + title + ".mp4"
669 tv2mp4.ts2mp4(pin, pout, opt)
671 pout = recpath + "/" + title + ".mkv"
672 tv2mkv.ts2mkv(pin, pout, opt)
673 if re.search("1", opt) or re.search("2", opt):
674 optt=opt.replace("1","MW1")
675 optt=optt.replace("2","MW2")
676 poutt = recpath + "/" + "m_"+title + ".mp4"
677 if re.search("d", opt) or re.search("5", opt):
678 if os.path.exists(os.path.join(recpath, "m_"+title+".m2v")):
679 shutil.move(os.path.join(recpath, title+".m2v"),os.path.join(recpath, "m_"+title+".m2v"))
680 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.aac")):
681 shutil.move(os.path.join(recpath, title+"_1.aac"),os.path.join(recpath, "m_"+title+"_1.aac"))
682 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.mp3")):
683 shutil.move(os.path.join(recpath, title+"_1.mp3"),os.path.join(recpath, "m_"+title+"_1.mp3"))
684 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.aac")):
685 shutil.move(os.path.join(recpath, title+"_2.aac"),os.path.join(recpath, "m_"+title+"_2.aac"))
686 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.mp3")):
687 shutil.move(os.path.join(recpath, title+"_2.mp3"),os.path.join(recpath, "m_"+title+"_2.mp3"))
688 shutil.move(os.path.join(recpath, title+".ts"),os.path.join(recpath, "m_"+title+".ts"))
689 tv2mp4.ts2mp4(os.path.join(recpath, "m_"+title+".ts"), poutt, optt)
690 shutil.move(os.path.join(recpath, "m_"+title+".ts"),os.path.join(recpath, title+".ts"))
693 poutt = recpath + "/" + "m_"+title + ".mp4"
694 shutil.move(os.path.join(recpath, title+".ts"),os.path.join(recpath, "m_"+title+".ts"))
695 if re.search("d", opt) or re.search("5", opt):
696 if os.path.exists(os.path.join(recpath, "m_"+title+".m2v")):
697 shutil.move(os.path.join(recpath, title+".m2v"),os.path.join(recpath, "m_"+title+".m2v"))
698 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.aac")):
699 shutil.move(os.path.join(recpath, title+"_1.aac"),os.path.join(recpath, "m_"+title+"_1.aac"))
700 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.mp3")):
701 shutil.move(os.path.join(recpath, title+"_1.mp3"),os.path.join(recpath, "m_"+title+"_1.mp3"))
702 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.aac")):
703 shutil.move(os.path.join(recpath, title+"_2.aac"),os.path.join(recpath, "m_"+title+"_2.aac"))
704 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.mp3")):
705 shutil.move(os.path.join(recpath, title+"_2.mp3"),os.path.join(recpath, "m_"+title+"_2.mp3"))
706 tv2mp4.ts2mp4(os.path.join(recpath, "m_"+title+".ts"), poutt, optt)
707 shutil.move(os.path.join(recpath, "m_"+title+".ts"),os.path.join(recpath, title+".ts"))
708 recdb.deleteReckey(typetxting, title, chtxt, btime)
710 if re.search("E", opt):
712 if os.path.exists(os.path.join(recpath,title+".mp4")):
714 shutil.copy(os.path.join(recpath,title+".mp4"), os.path.join(movepath,title+".mp4"))
718 os.chmod(os.path.join(movepath,title+".mp4"),0777)
721 recque.writeRecQue(movepath, chtxt, title, opt)
723 os.chmod(os.path.join(movepath,title+".recq"),0777)
726 elif os.path.exists(os.path.join(recpath,title+".mkv")):
728 shutil.copy(os.path.join(recpath,title+".mkv"), os.path.join(movepath,title+".mkv"))
732 os.chmod(os.path.join(movepath,title+".mkv"),0777)
735 recque.writeRecQue(movepath, chtxt, title, opt)
737 os.chmod(os.path.join(movepath,title+".recq"),0777)
740 except Exception, inst:
741 errtxt1="move mkv/mp4 error."
742 errtxt2=str(type(inst))+"\n"
743 errtxt2=errtxt2+str(inst)
744 recdblist.addCommonlogEX("Error", "type_encode_que(timerec.py)", errtxt1,errtxt2+traceback.format_exc(),log_level=200)
745 recdb.reserveReckey(recdblist.REC_MOVE_END, title, chtxt, btime, etime, opt)
746 recdb.reserveReckey(typetxtfin, title, chtxt, btime, etime, opt)
749 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
750 bt = bt + datetime.timedelta(seconds=600)
751 et = et + datetime.timedelta(seconds=600)
752 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
753 etime = et.strftime("%Y-%m-%d %H:%M:%S")
754 recdb.reserveReckey(typetxtnow, title, chtxt, btime, etime, opt)