3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009-2012 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()
308 topt=status.getSettings_auto_opt()
311 ch=chdb.searchCHFromChtxt(chtxtt)
313 maxnum=epgdb.countSchedule(btimet, etimet)[1]
314 maxnum=int(configreader.getConfEnv("bscs_max"))-maxnum
316 maxnum=epgdb.countSchedule(btimet, etimet)[0]
317 maxnum=int(configreader.getConfEnv("te_max"))-maxnum
319 if recdb.checkDuplicated(titlet, chtxtt, btimet, etimet)==0:
320 recdb.reserveReckey(recdblist.REC_RESERVE,titlet,chtxtt, btimet, etimet,topt)
321 except Exception, inst:
322 recdblist.addCommonlogEX("Error", "search_keyword_auto_jbk(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
324 recdb.reserveAutoKeyword(chtxtt, titlet, btimet, etimet)
325 except Exception, inst:
326 recdblist.addCommonlogEX("Error", "search_keyword(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
327 def type_reserve(typetxt,chtxt,title,bt,et,opt):
328 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
329 etime = et.strftime("%Y-%m-%d %H:%M:%S")
332 if typetxt==recdblist.REC_RESERVE:
333 typetxtfinal=recdblist.REC_FINAL_RESERVE
334 tnow = datetime.datetime.now()
336 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
337 if (dt < 58 * 60 and dt > 30 * 60):
338 bctypet = chdb.searchCHFromChtxt(chtxt)['bctype']
339 chdatat = rec10d.rec10db.select_by_bctype_epg_ch(bctypet)
340 dt1 = bt - datetime.datetime.strptime(chdatat[0][5], "%Y-%m-%d %H:%M:%S")
341 dt1 = dt1.days * 24 * 60 * 60 + dt1.seconds
343 recdata = epgdb.searchTime(title, btime, "5", chtxt)
351 bt = datetime.datetime.strptime(btimen, "%Y-%m-%d %H:%M:%S")
352 et = datetime.datetime.strptime(etimen, "%Y-%m-%d %H:%M:%S")
353 btimen = bt.strftime("%Y-%m-%d %H:%M:%S")
354 etimen = et.strftime("%Y-%m-%d %H:%M:%S")
357 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
358 recdb.reserveReckey(typetxtfinal, titlen, chtxtn, btimen, etimen, opt)
359 recdb.addRecLogProgram(titlen, chtxtn, btimen, etimen, opt, exp, longexp, category)
360 auto_rec.addKey(chtxt, titlen,exp+" "+longexp)
361 auto_rec.addKey("ALL", titlen,exp+" "+longexp)
362 recdblist.printutf8(u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen)
363 except Exception, inst:
364 recdblist.addCommonlogEX("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
366 recdblist.printutf8(u"追いかけ機能エラー:番組データが見付かりません。")
368 if rec10d.rec10db.select_by_bctype_epg_ch(bctypet)[0][6] != "0":
369 rec10d.rec10db.update_status_by_bctype_epg_ch(bctypet, "3")
371 elif (dt <= 30 * 60 and dt > 20 * 60):
372 recdata = epgdb.searchTime(title, btime, "5", chtxt)
380 bt = datetime.datetime.strptime(btimen, "%Y-%m-%d %H:%M:%S")
381 et = datetime.datetime.strptime(etimen, "%Y-%m-%d %H:%M:%S")
382 btimen = bt.strftime("%Y-%m-%d %H:%M:%S")
383 etimen = et.strftime("%Y-%m-%d %H:%M:%S")
386 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
387 recdb.reserveReckey(typetxtfinal, titlen, chtxtn, btimen, etimen, opt)
388 recdb.addRecLogProgram(titlen, chtxtn, btimen, etimen, opt, exp, longexp, category)
389 auto_rec.addKey(chtxt, titlen,exp+" "+longexp)
390 auto_rec.addKey("ALL", titlen,exp+" "+longexp)
391 #recdblist.printutf8(u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen)
392 recdblist.addCommonlogEX(u"通常", "Oikake (timerec.py)",u"追いかけ機能実行中",u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen,log_level=500)
393 except Exception, inst:
394 recdblist.addCommonlogEX("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
397 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
398 recdb.reserveReckey(typetxtfinal, title, chtxt, btime, etime, opt)
399 except Exception, inst:
400 recdblist.addCommonlogEX("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
401 def type_final(typetxt,chtxt,title,bt,et,opt):
402 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
403 etime = et.strftime("%Y-%m-%d %H:%M:%S")
407 if typetxt==recdblist.REC_FINAL_RESERVE:
408 typetxting=recdblist.REC_TS_RECORDING
409 typetxtdecque=recdblist.REC_TS_DECODE_QUE
410 tnow = datetime.datetime.now()
412 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
413 if dt < 6 * 60 and dt > 0:
415 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
416 testpath=[os.path.join(recpath,title+".ts.b25")]
417 testpath.append(os.path.join(recpath,title+".ts"))
418 testpath.append(os.path.join(recpath,title+".avi"))
419 testpath.append(os.path.join(recpath,title+".mp4"))
420 testpath.append(os.path.join(recpath,title+".log"))
423 if os.path.exists(ti):
425 if re.search("N", opt) or tcheck>0:
428 iff=u"("+configreader.getConfEnv("iff")+u")_"
432 newtitle=newtitle+u"_"+iff+newtime.strftime("%Y-%m-%dT%H-%M-%S")
433 recdb.reserveReckey(typetxting, newtitle, chtxt, btime, etime, opt)
434 recdblist.addCommonlogEX(u"通常","timerec.py",u"録画開始 "+newtitle+" "+btime+" "+etime,"",log_level=500)
435 tv2avi.timetv2b25(recpath + "/" + newtitle + ".avi", chtxt, btime, etime, opt)
436 recdb.deleteReckey(typetxting, newtitle, chtxt, btime)
437 if not re.search("R", opt):
438 tnow = datetime.datetime.now()
439 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
440 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
442 bt = tnow + datetime.timedelta(seconds=600)
443 et = et + dt + datetime.timedelta(seconds=600)
444 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
445 etime = et.strftime("%Y-%m-%d %H:%M:%S")
446 recdb.reserveReckey(typetxtdecque, newtitle, chtxt, btime, etime, opt)
450 shutil.copy(os.path.join(recpath,title+".ts.b25"), os.path.join(movepath,title+".ts.b25"))
454 os.chmod(os.path.join(movepath,title+".ts.b25"),0777)
457 recque.writeRecQue(movepath, chtxt, title, opt)
459 os.chmod(os.path.join(movepath,title+".recq"),0777)
462 except Exception, inst:
463 recdblist.addCommonlogEX("Error", "Move option(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
464 recdb.reserveReckey(recdblist.REC_MOVE_END, newtitle, chtxt, btime, etime, opt)
466 def type_keyword(typetxt,chtxt,title,bt,et,opt,deltatime):
467 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
468 etime = et.strftime("%Y-%m-%d %H:%M:%S")
471 if typetxt==recdblist.REC_KEYWORD:
472 typetxtres=recdblist.REC_RESERVE
473 tnow = datetime.datetime.now()
475 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
476 recdblist.printutf8(str(dt), verbose_level=800)
477 if dt <= 90 * 60 and dt > 70 * 60:
478 recdata = epgdb.searchTime(title, btime, deltatime, chtxt)
487 bt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
488 et = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
489 btimet = bt.strftime("%Y-%m-%d %H:%M:%S")
490 etimet = et.strftime("%Y-%m-%d %H:%M:%S")
492 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
493 recdb.reserveReckey(typetxtres, titlet, chtxt, btimet, etimet, opt)
494 recdb.addRecLogProgram(titlet, chtxtt, btimet, etimet, opt, exp,longexp,category)
495 auto_rec.addKey(chtxt, titlet,exp+" "+longexp)
496 auto_rec.addKey("ALL", titlet,exp+" "+longexp)
497 recdblist.addCommonlogEX(u"通常","timerec.py",u"key "+title+u" : "+titlet+u" "+btimet+u" "+etimet,"",log_level=500)
498 #except Exception, inst:
499 # recdblist.printutf8("Error happened in REC_KEYWORD DB")
500 # recdblist.printutf8(type(inst))
501 # recdblist.printutf8(inst)
503 recdblist.printutf8("nothing match")
505 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
506 recdb.reserveReckey(typetxtres, title, chtxt, btime, etime, opt)
507 recdblist.addCommonlogEX(u"エラー","timerec.py",u"nothing match","",log_level=200)
508 recdblist.addCommonlogEX(u"エラー","timerec.py",u"key "+title+u" "+btime+u" "+etime,"",log_level=200)
509 def type_keyword_every_day(type,chtxt,title,bt,et,opt,deltatime,deltaday,counter):
510 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
511 etime = et.strftime("%Y-%m-%d %H:%M:%S")
512 tnow = datetime.datetime.now()
514 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
515 dd = datetime.timedelta(days=int(deltaday))
517 recdb.deleteReckey(recdblist.REC_KEYWORD_EVERY_SOME_DAYS, title, chtxt, btime)
520 btxt = bt.strftime("%Y-%m-%d %H:%M:%S")
521 etxt = et.strftime("%Y-%m-%d %H:%M:%S")
523 recdb.reserveEverydayKeyword(title, chtxt, btxt, etxt, deltatime, opt, deltaday,counter-1)
525 recdb.reserveEverydayKeyword(title, chtxt, btxt, etxt, deltatime, opt, deltaday,-1)
527 recdb.deleteReckey(recdblist.REC_KEYWORD_EVERY_SOME_DAYS, title, chtxt, btime)
530 btxt = bt.strftime("%Y-%m-%d %H:%M:%S")
531 etxt = et.strftime("%Y-%m-%d %H:%M:%S")
533 recdb.reserveEverydayKeyword(title, chtxt, btxt, etxt, deltatime, opt, deltaday,counter-1)
535 recdb.reserveEverydayKeyword(title, chtxt, btxt, etxt, deltatime, opt, deltaday,-1)
536 recdata = epgdb.searchTime(title, btime, deltatime, chtxt)
545 bt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
546 et = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
547 btimet = bt.strftime("%Y-%m-%d %H:%M:%S")
548 etimet = et.strftime("%Y-%m-%d %H:%M:%S")
550 recdb.reserveKeyword(titlet, chtxt, btimet, etimet, deltatime, opt)
552 recdb.reserveKeyword(title, chtxt, btime, etime, deltatime, opt)
553 def type_decode_que(typetxt,chtxt,title,bt,et,opt):
554 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
555 etime = et.strftime("%Y-%m-%d %H:%M:%S")
556 tnow = datetime.datetime.now()
558 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
563 if typetxt== recdblist.REC_TS_DECODE_QUE:
564 typetxting=recdblist.REC_TS_DECODING
565 typetxtmiss=recdblist.REC_MISS_DECODE
566 typetxtencque=recdblist.REC_ENCODE_QUE
567 tnow = datetime.datetime.now()
569 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
571 if status.getB25Decoding() < 2:
572 pin = recpath + "/" + title
573 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
574 recdb.reserveReckey(typetxting, title, chtxt, btime, etime, opt)
575 tv2avi.b252ts(pin, chtxt, btime, etime, opt)
576 recdb.deleteReckey(typetxting, title, chtxt, btime)
577 if not os.access(recpath + "/" + title + ".ts", os.F_OK):
578 recdb.deleteReckey(typetxting, title, chtxt, btime)
579 recdb.reserveReckey(typetxtmiss, title, chtxt, btime, etime, opt)
581 auto_process.deleteTmpFile(recpath, title, ".ts")
582 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
583 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
585 if not re.search("D", opt):
586 tnow = datetime.datetime.now()
587 bt = tnow + datetime.timedelta(seconds=600)
589 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
590 etime = et.strftime("%Y-%m-%d %H:%M:%S")
591 recdb.reserveReckey(typetxtencque, title, chtxt, btime, etime, opt)
595 shutil.copy(os.path.join(recpath,title+".ts"), os.path.join(movepath,title+".ts"))
599 os.chmod(os.path.join(movepath,title+".ts"),0777)
602 recque.writeRecQue(movepath, chtxt, title, opt)
604 os.chmod(os.path.join(movepath,title+".recq"),0777)
608 if os.path.getsize(os.path.join(recpath,title+".ts"))==os.path.getsize(os.path.join(movepath,title+".ts")):
609 os.remove(os.path.join(recpath,title+".ts"))
610 except Exception, inst:
611 errtxt1="move ts error.\n"
612 errtxt2=str(type(inst))+"\n"
613 errtxt2=errtxt2+str(inst)
614 recdblist.addCommonlogEX("Error", "type_decode_que(timerec.py)", errtxt1,errtxt2+traceback.format_exc(),log_level=200)
615 recdb.reserveReckey(recdblist.REC_MOVE_END, title, chtxt, btime, etime, opt)
617 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
618 bt = bt + datetime.timedelta(seconds=600)
619 et = et + datetime.timedelta(seconds=600)
620 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
621 etime = et.strftime("%Y-%m-%d %H:%M:%S")
622 recdb.reserveReckey(typetxtnow, title, chtxt, btime, etime, opt)
625 def type_encode_que(typetxt,chtxt,title,bt,et,opt):
626 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
627 etime = et.strftime("%Y-%m-%d %H:%M:%S")
628 tnow = datetime.datetime.now()
630 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
634 if typetxt==recdblist.REC_ENCODE_QUE:
635 typetxting=recdblist.REC_ENCODE_LOCAL
636 typetxtfin=recdblist.REC_FIN_LOCAL
638 if status.getEncoding() < int(configreader.getConfEnv("enc_max")):
639 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
640 recdb.reserveReckey(typetxting, title, chtxt, btime, etime, opt)
641 recdblist.printutf8(opt)
642 pin = recpath + "/" + title + ".ts"
643 if re.search("d", opt):
644 pin = recpath + "/" + title + ".m2v"
645 if not os.path.exists(pin) or os.path.getsize(pin)<100*1000:
646 paac2 = recpath + "/" + title + "_2.aac"
647 pmp32 = recpath + "/" + title + "_2.mp3"
648 if not os.path.exists(paac2) and not os.path.exists(pmp32):
649 tv2audio.ts2dualaudio_BonTsDemux(os.path.join(recpath, title+".ts"),recdblist.BONTSDEMUX_DELAY,opt)
651 elif re.search("5", opt):
652 pin = recpath + "/" + title + ".m2v"
653 if not os.path.exists(pin) or os.path.getsize(pin)<100*1000:
654 paac2 = recpath + "/" + title + "_2.aac"
655 pmp32 = recpath + "/" + title + "_2.mp3"
656 if not os.path.exists(paac2) and not os.path.exists(pmp32):
657 tv2audio.ts2pentaaudio_BonTsDemux(os.path.join(recpath, title+".ts"), recdblist.BONTSDEMUX_DELAY, opt)
659 elif re.search("b", opt):
660 pin = recpath + "/" + title + ".m2v"
661 if not os.path.exists(pin) or os.path.getsize(pin)<100*1000:
662 paac2 = recpath + "/" + title + ".aac"
663 pmp32 = recpath + "/" + title + ".mp3"
664 if not os.path.exists(paac2) and not os.path.exists(pmp32):
665 tv2audio.ts2single_fp_BonTsDemux(os.path.join(recpath, title+".ts"),opt)
669 if configreader.getConfEnv("make_mp4")=="1":
673 if re.search("m", opt):
675 if re.search("4", opt):
677 recdblist.printutf8(pin)
678 if not re.search("0", opt):
680 pout = recpath + "/" + title + ".mp4"
681 tv2mp4.ts2mp4(pin, pout, opt)
683 pout = recpath + "/" + title + ".mkv"
684 tv2mkv.ts2mkv(pin, pout, opt)
685 if re.search("1", opt) or re.search("2", opt):
686 optt=opt.replace("1","MW1")
687 optt=optt.replace("2","MW2")
688 poutt = recpath + "/" + "m_"+title + ".mp4"
689 if re.search("d", opt) or re.search("5", opt):
690 if os.path.exists(os.path.join(recpath, "m_"+title+".m2v")):
691 shutil.move(os.path.join(recpath, title+".m2v"),os.path.join(recpath, "m_"+title+".m2v"))
692 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.aac")):
693 shutil.move(os.path.join(recpath, title+"_1.aac"),os.path.join(recpath, "m_"+title+"_1.aac"))
694 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.mp3")):
695 shutil.move(os.path.join(recpath, title+"_1.mp3"),os.path.join(recpath, "m_"+title+"_1.mp3"))
696 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.aac")):
697 shutil.move(os.path.join(recpath, title+"_2.aac"),os.path.join(recpath, "m_"+title+"_2.aac"))
698 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.mp3")):
699 shutil.move(os.path.join(recpath, title+"_2.mp3"),os.path.join(recpath, "m_"+title+"_2.mp3"))
700 shutil.move(os.path.join(recpath, title+".ts"),os.path.join(recpath, "m_"+title+".ts"))
701 tv2mp4.ts2mp4(os.path.join(recpath, "m_"+title+".ts"), poutt, optt)
702 shutil.move(os.path.join(recpath, "m_"+title+".ts"),os.path.join(recpath, title+".ts"))
705 poutt = recpath + "/" + "m_"+title + ".mp4"
706 shutil.move(os.path.join(recpath, title+".ts"),os.path.join(recpath, "m_"+title+".ts"))
707 if re.search("d", opt) or re.search("5", opt):
708 if os.path.exists(os.path.join(recpath, "m_"+title+".m2v")):
709 shutil.move(os.path.join(recpath, title+".m2v"),os.path.join(recpath, "m_"+title+".m2v"))
710 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.aac")):
711 shutil.move(os.path.join(recpath, title+"_1.aac"),os.path.join(recpath, "m_"+title+"_1.aac"))
712 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.mp3")):
713 shutil.move(os.path.join(recpath, title+"_1.mp3"),os.path.join(recpath, "m_"+title+"_1.mp3"))
714 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.aac")):
715 shutil.move(os.path.join(recpath, title+"_2.aac"),os.path.join(recpath, "m_"+title+"_2.aac"))
716 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.mp3")):
717 shutil.move(os.path.join(recpath, title+"_2.mp3"),os.path.join(recpath, "m_"+title+"_2.mp3"))
718 tv2mp4.ts2mp4(os.path.join(recpath, "m_"+title+".ts"), poutt, optt)
719 shutil.move(os.path.join(recpath, "m_"+title+".ts"),os.path.join(recpath, title+".ts"))
720 recdb.deleteReckey(typetxting, title, chtxt, btime)
722 if re.search("E", opt):
724 if os.path.exists(os.path.join(recpath,title+".mp4")):
726 shutil.copy(os.path.join(recpath,title+".mp4"), os.path.join(movepath,title+".mp4"))
730 os.chmod(os.path.join(movepath,title+".mp4"),0777)
733 recque.writeRecQue(movepath, chtxt, title, opt)
735 os.chmod(os.path.join(movepath,title+".recq"),0777)
738 elif os.path.exists(os.path.join(recpath,title+".mkv")):
740 shutil.copy(os.path.join(recpath,title+".mkv"), os.path.join(movepath,title+".mkv"))
744 os.chmod(os.path.join(movepath,title+".mkv"),0777)
747 recque.writeRecQue(movepath, chtxt, title, opt)
749 os.chmod(os.path.join(movepath,title+".recq"),0777)
752 except Exception, inst:
753 errtxt1="move mkv/mp4 error."
754 errtxt2=str(type(inst))+"\n"
755 errtxt2=errtxt2+str(inst)
756 recdblist.addCommonlogEX("Error", "type_encode_que(timerec.py)", errtxt1,errtxt2+traceback.format_exc(),log_level=200)
757 recdb.reserveReckey(recdblist.REC_MOVE_END, title, chtxt, btime, etime, opt)
758 recdb.reserveReckey(typetxtfin, title, chtxt, btime, etime, opt)
761 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
762 bt = bt + datetime.timedelta(seconds=600)
763 et = et + datetime.timedelta(seconds=600)
764 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
765 etime = et.strftime("%Y-%m-%d %H:%M:%S")
766 recdb.reserveReckey(typetxtnow, title, chtxt, btime, etime, opt)