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_chscaned_in_status()
45 except Exception, inst:
46 recdblist.addCommonlogEX("Error", "install_check(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
48 recdb.deleteOldProgramBeforeTheseHours("24")
49 recdb.delete_old_auto_bayes("1")
50 recdb.delete_old_auto_keyword("1")
51 tasks = recdb.getProgramsInTheseHours("3")
52 inum = recdb.countRecNow_minutes("10")
53 recdblist.printutf8(u"rec10処理開始"+ datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),verbose_level=800)
54 recdblist.printutf8(u"直近録画予約件数:" + str(inum) + u"BS/CS録画中件数:" + str(status.getBSCSRecording()) + u"TE録画中件数:" + str(status.getTERecording()) ,verbose_level=800)
57 dnow=datetime.datetime.now()
58 if dnow.minute % 10 < 5:
63 search_keyword(recdb.getAllJbkKeyword())
64 recque.searchRecQue(recpath)
72 auto_process.autoCheck(recpath)
74 auto_process.killDeadEncode(recpath)
76 update = chdb.update()
77 updatelogo = chdb.updateLogo()
86 if bctype.find('te') > -1:
87 recnum = status.getTERecording() + recdb.countRecNow_minutes_TE("10")
88 recdblist.printutf8(u"放送種別:"+bctype + u"||該当チューナー実行中件数:" + str(status.getTERecording()) + u":直近予約件数:" + str(recdb.countRecNow_minutes_TE("10")),verbose_level=800)
89 recnum = int(configreader.getConfEnv("te_max")) -recnum
91 recnum = status.getBSCSRecording() + recdb.countRecNow_minutes_BSCS("10")
92 recdblist.printutf8(u"放送種別:"+bctype + u"||該当チューナー実行中件数:" + str(status.getBSCSRecording()) + u":直近予約件数:" + str(recdb.countRecNow_minutes_BSCS("10")),verbose_level=800)
93 recnum = int(configreader.getConfEnv("bscs_max")) -recnum
95 recdblist.printutf8(str(update),verbose_level=750)
96 rec10d.rec10db.update_status_by_bctype_epg_ch(bctype, "0")
97 epgdb.updatebc(bctype)
98 update = chdb.update()
103 auto_process.update_all_timeline_epg()
105 elif len(updatelogo)>0:
111 for bctype in updatelogo:
113 if bctype.find('te') > -1:
114 recnum = status.getTERecording() + recdb.countRecNow_minutes_TE("1200")
115 recdblist.printutf8(u"ロゴ取得 : 放送種別-"+bctype + u"||該当チューナー実行中件数:" + str(status.getTERecording()) + u":直近予約件数:" + str(recdb.countRecNow_minutes_TE("10")),verbose_level=800)
116 recnum = int(configreader.getConfEnv("te_max")) -recnum
118 recnum = status.getBSCSRecording() + recdb.countRecNow_minutes_BSCS("1200")
119 recdblist.printutf8(u"ロゴ取得 : 放送種別-"+bctype + u"||該当チューナー実行中件数:" + str(status.getBSCSRecording()) + u":直近予約件数:" + str(recdb.countRecNow_minutes_BSCS("10")),verbose_level=800)
120 recnum = int(configreader.getConfEnv("bscs_max")) -recnum
122 recdblist.printutf8(str(updatelogo),verbose_level=750)
123 rec10d.rec10db.update_logostatus_by_bctype_epg_ch(bctype,"0")
124 epgdb.updateLogo_bc(bctype)
125 updatelogo = chdb.updateLogo()
136 auto_process.update_all_timeline_epg()
139 typetxt = task["type"]
141 chtxt = task['chtxt']
145 title = task['title']
149 btime = task['btime']
150 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
153 bt = datetime.datetime.strptime("2009-01-01 00:00:00", "%Y-%m-%d %H:%M:%S")
155 etime = task['etime']
156 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
159 et = datetime.datetime.strptime("2009-01-01 00:00:00", "%Y-%m-%d %H:%M:%S")
164 tnow = datetime.datetime.now()
166 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
167 if task["type"] == recdblist.REC_RESERVE:#"res,"+chtxt+","+title+","+btime+","+etime+","+opt
169 if pid != 0:#親プロセスの場合
171 else:#子プロセスの場合 アップデートを行って終了
172 type_reserve(task["type"],chtxt,title,bt,et,opt)
174 elif task["type"] == recdblist.REC_KEYWORD:#"key,"+chtxt+","+keyword+","+btime+","+deltatime+","+opt
175 deltatime = task['deltatime']
177 if pid != 0:#親プロセスの場合
179 else:#子プロセスの場合 アップデートを行って終了
180 type_keyword(task["type"],chtxt,title, bt, et, opt, deltatime)
182 elif task["type"] == recdblist.REC_KEYWORD_EVERY_SOME_DAYS:#"keyevery,"+chtxt+","+keyword+","+btime+","+deltatime+","+opt+","+deltaday
183 deltatime = task['deltatime']
184 deltaday = task['deltaday']
186 keyeverycounter=task['counter']
190 if pid != 0:#親プロセスの場合
192 else:#子プロセスの場合 アップデートを行って終了
193 type_keyword_every_day(task["type"],chtxt, title, bt, et, opt, deltatime, deltaday,keyeverycounter)
195 elif task["type"] == recdblist.REC_FINAL_RESERVE:#"rec,"+chtxt+","+title+","+btime+","+etime+","+opt
197 if pid != 0:#親プロセスの場合
199 else:#子プロセスの場合 アップデートを行って終了
200 type_final(task["type"],chtxt, title, bt, et, opt)
202 elif task["type"] == recdblist.REC_TS_DECODE_QUE:
205 if pid != 0:#親プロセスの場合
207 else:#子プロセスの場合 アップデートを行って終了
209 type_decode_que(task["type"],chtxt, title, bt, et, opt)
211 elif task["type"] == recdblist.REC_ENCODE_QUE:
212 encodenum=encodenum+1
214 if pid != 0:#親プロセスの場合
216 else:#子プロセスの場合 アップデートを行って終了
217 time.sleep(5*encodenum)
218 type_encode_que(task["type"],chtxt, title, bt, et, opt)
220 elif task["type"] == recdblist.REC_AVI_TO_MKV:
228 if configreader.getConfEnv("make_mp4")==1:
232 if re.search("m", opt):
234 if re.search("4", opt):
236 recdb.deleteReckey(recdblist.REC_AVI_TO_MKV, title, chtxt, btime)
237 recdb.reserveReckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
239 tv2mp4.raw2mp4(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mp4"),opt)
241 tv2mkv.raw2mkv(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mkv"),opt)
242 recdb.deleteReckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime)
244 elif task["type"] == recdblist.REC_AVI_TO_MP4:
252 if configreader.getConfEnv("make_mp4")==1:
256 if re.search("m", opt):
258 if re.search("4", opt):
260 recdb.deleteReckey(recdblist.REC_AVI_TO_MP4, title, chtxt, btime)
261 recdb.reserveReckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
263 tv2mp4.ts2mp4(pin, pout, opt)
264 tv2mp4.raw2mp4(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mp4"),opt)
266 tv2mkv.raw2mkv(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mkv"),opt)
267 recdb.deleteReckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime)
269 elif task["type"] == recdblist.REC_MKV_TO_MP4:
275 recdb.deleteReckey(recdblist.REC_MKV_TO_MP4, title, chtxt, btime)
276 recdb.reserveReckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
277 tv2mp4.mkv2mp4(os.path.join(recpath,title+".mkv"),os.path.join(recpath,title+".mp4"))
278 recdb.deleteReckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime)
281 def search_keyword(key):
282 tnow = datetime.datetime.now()
283 nows =tnow.strftime("%Y-%m-%d %H:%M:%S")
284 for k,auto,opt in key:
285 recdatum = epgdb.searchTimeAuto(k,nows, "144")
286 for recdata in recdatum:
292 btt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
293 ett = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
294 btimet = btt.strftime("%Y-%m-%d %H:%M:%S")
295 etimet = ett.strftime("%Y-%m-%d %H:%M:%S")
296 #if status.getSettings_auto_jbk()==1:
297 if auto==1 or status.getSettings_auto_jbk()==1:
300 topt=status.getSettings_auto_opt()
303 ch=chdb.searchCHFromChtxt(chtxtt)
305 maxnum=epgdb.countSchedule(btimet, etimet)[1]
306 maxnum=int(configreader.getConfEnv("bscs_max"))-maxnum
308 maxnum=epgdb.countSchedule(btimet, etimet)[0]
309 maxnum=int(configreader.getConfEnv("te_max"))-maxnum
311 if recdb.checkDuplicated(titlet, chtxtt, btimet, etimet)==0:
312 recdb.reserveReckey(recdblist.REC_RESERVE,titlet,chtxtt, btimet, etimet,topt)
313 except Exception, inst:
314 recdblist.addCommonlogEX("Error", "search_keyword_auto_jbk(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
316 recdb.reserveAutoKeyword(chtxtt, titlet, btimet, etimet)
317 except Exception, inst:
318 recdblist.addCommonlogEX("Error", "search_keyword(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
319 def type_reserve(typetxt,chtxt,title,bt,et,opt):
320 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
321 etime = et.strftime("%Y-%m-%d %H:%M:%S")
324 if typetxt==recdblist.REC_RESERVE:
325 typetxtfinal=recdblist.REC_FINAL_RESERVE
326 tnow = datetime.datetime.now()
328 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
329 if (dt < 58 * 60 and dt > 30 * 60):
330 bctypet = chdb.searchCHFromChtxt(chtxt)['bctype']
331 chdatat = rec10d.rec10db.select_by_bctype_epg_ch(bctypet)
332 dt1 = bt - datetime.datetime.strptime(chdatat[0][4], "%Y-%m-%d %H:%M:%S")
333 dt1 = dt1.days * 24 * 60 * 60 + dt1.seconds
335 recdata = epgdb.searchTime(title, btime, "5", chtxt)
343 bt = datetime.datetime.strptime(btimen, "%Y-%m-%d %H:%M:%S")
344 et = datetime.datetime.strptime(etimen, "%Y-%m-%d %H:%M:%S")
345 btimen = bt.strftime("%Y-%m-%d %H:%M:%S")
346 etimen = et.strftime("%Y-%m-%d %H:%M:%S")
349 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
350 recdb.reserveReckey(typetxtfinal, titlen, chtxtn, btimen, etimen, opt)
351 recdb.addRecLogProgram(titlen, chtxtn, btimen, etimen, opt, exp, longexp, category)
352 auto_rec.addKey(chtxt, titlen,exp+" "+longexp)
353 auto_rec.addKey("ALL", titlen,exp+" "+longexp)
354 recdblist.printutf8(u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen)
355 except Exception, inst:
356 recdblist.addCommonlogEX("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
358 recdblist.printutf8(u"追いかけ機能エラー:番組データが見付かりません。")
360 if rec10d.rec10db.select_by_bctype_epg_ch(bctypet)[0][5] != "0":
361 rec10d.rec10db.update_status_by_bctype_epg_ch(bctypet, "3")
363 elif (dt <= 30 * 60 and dt > 20 * 60):
364 recdata = epgdb.searchTime(title, btime, "5", chtxt)
372 bt = datetime.datetime.strptime(btimen, "%Y-%m-%d %H:%M:%S")
373 et = datetime.datetime.strptime(etimen, "%Y-%m-%d %H:%M:%S")
374 btimen = bt.strftime("%Y-%m-%d %H:%M:%S")
375 etimen = et.strftime("%Y-%m-%d %H:%M:%S")
378 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
379 recdb.reserveReckey(typetxtfinal, titlen, chtxtn, btimen, etimen, opt)
380 recdb.addRecLogProgram(titlen, chtxtn, btimen, etimen, opt, exp, longexp, category)
381 auto_rec.addKey(chtxt, titlen,exp+" "+longexp)
382 auto_rec.addKey("ALL", titlen,exp+" "+longexp)
383 #recdblist.printutf8(u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen)
384 recdblist.addCommonlogEX(u"通常", "Oikake (timerec.py)",u"追いかけ機能実行中",u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen,log_level=500)
385 except Exception, inst:
386 recdblist.addCommonlogEX("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
389 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
390 recdb.reserveReckey(typetxtfinal, title, chtxt, btime, etime, opt)
391 except Exception, inst:
392 recdblist.addCommonlogEX("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
393 def type_final(typetxt,chtxt,title,bt,et,opt):
394 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
395 etime = et.strftime("%Y-%m-%d %H:%M:%S")
399 if typetxt==recdblist.REC_FINAL_RESERVE:
400 typetxting=recdblist.REC_TS_RECORDING
401 typetxtdecque=recdblist.REC_TS_DECODE_QUE
402 tnow = datetime.datetime.now()
404 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
405 if dt < 6 * 60 and dt > 0:
407 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
408 testpath=[os.path.join(recpath,title+".ts.b25")]
409 testpath.append(os.path.join(recpath,title+".ts"))
410 testpath.append(os.path.join(recpath,title+".avi"))
411 testpath.append(os.path.join(recpath,title+".mp4"))
412 testpath.append(os.path.join(recpath,title+".log"))
415 if os.path.exists(ti):
417 if re.search("N", opt) or tcheck>0:
420 iff=u"("+configreader.getConfEnv("iff")+u")_"
424 newtitle=newtitle+u"_"+iff+newtime.strftime("%Y-%m-%dT%H-%M-%S")
425 recdb.reserveReckey(typetxting, newtitle, chtxt, btime, etime, opt)
426 recdblist.addCommonlogEX(u"通常","timerec.py",u"録画開始 "+newtitle+" "+btime+" "+etime,"",log_level=500)
427 tv2avi.timetv2b25(recpath + "/" + newtitle + ".avi", chtxt, btime, etime, opt)
428 recdb.deleteReckey(typetxting, newtitle, chtxt, btime)
429 if not re.search("R", opt):
430 tnow = datetime.datetime.now()
431 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
432 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
434 bt = tnow + datetime.timedelta(seconds=600)
435 et = et + dt + datetime.timedelta(seconds=600)
436 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
437 etime = et.strftime("%Y-%m-%d %H:%M:%S")
438 recdb.reserveReckey(typetxtdecque, newtitle, chtxt, btime, etime, opt)
442 shutil.copy(os.path.join(recpath,title+".ts.b25"), os.path.join(movepath,title+".ts.b25"))
446 os.chmod(os.path.join(movepath,title+".ts.b25"),0777)
449 recque.writeRecQue(movepath, chtxt, title, opt)
451 os.chmod(os.path.join(movepath,title+".recq"),0777)
454 except Exception, inst:
455 recdblist.addCommonlogEX("Error", "Move option(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
456 recdb.reserveReckey(recdblist.REC_MOVE_END, newtitle, chtxt, btime, etime, opt)
458 def type_keyword(typetxt,chtxt,title,bt,et,opt,deltatime):
459 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
460 etime = et.strftime("%Y-%m-%d %H:%M:%S")
463 if typetxt==recdblist.REC_KEYWORD:
464 typetxtres=recdblist.REC_RESERVE
465 tnow = datetime.datetime.now()
467 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
468 recdblist.printutf8(str(dt), verbose_level=800)
469 if dt <= 90 * 60 and dt > 70 * 60:
470 recdata = epgdb.searchTime(title, btime, deltatime, chtxt)
479 bt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
480 et = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
481 btimet = bt.strftime("%Y-%m-%d %H:%M:%S")
482 etimet = et.strftime("%Y-%m-%d %H:%M:%S")
484 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
485 recdb.reserveReckey(typetxtres, titlet, chtxt, btimet, etimet, opt)
486 recdb.addRecLogProgram(titlet, chtxtt, btimet, etimet, opt, exp,longexp,category)
487 auto_rec.addKey(chtxt, titlet,exp+" "+longexp)
488 auto_rec.addKey("ALL", titlet,exp+" "+longexp)
489 recdblist.addCommonlogEX(u"通常","timerec.py",u"key "+title+u" : "+titlet+u" "+btimet+u" "+etimet,"",log_level=500)
490 #except Exception, inst:
491 # recdblist.printutf8("Error happened in REC_KEYWORD DB")
492 # recdblist.printutf8(type(inst))
493 # recdblist.printutf8(inst)
495 recdblist.printutf8("nothing match")
497 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
498 recdb.reserveReckey(typetxtres, title, chtxt, btime, etime, opt)
499 recdblist.addCommonlogEX(u"エラー","timerec.py",u"nothing match","",log_level=200)
500 recdblist.addCommonlogEX(u"エラー","timerec.py",u"key "+title+u" : "+titlet+u" "+btimet+u" "+etimet,"",log_level=200)
501 def type_keyword_every_day(type,chtxt,title,bt,et,opt,deltatime,deltaday,counter):
502 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
503 etime = et.strftime("%Y-%m-%d %H:%M:%S")
504 tnow = datetime.datetime.now()
506 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
507 dd = datetime.timedelta(days=int(deltaday))
509 recdb.deleteReckey(recdblist.REC_KEYWORD_EVERY_SOME_DAYS, title, chtxt, btime)
512 btxt = bt.strftime("%Y-%m-%d %H:%M:%S")
513 etxt = et.strftime("%Y-%m-%d %H:%M:%S")
515 recdb.reserveEverydayKeyword(title, chtxt, btxt, etxt, deltatime, opt, deltaday,counter-1)
517 recdb.reserveEverydayKeyword(title, chtxt, btxt, etxt, deltatime, opt, deltaday,-1)
519 recdb.deleteReckey(recdblist.REC_KEYWORD_EVERY_SOME_DAYS, title, chtxt, btime)
522 btxt = bt.strftime("%Y-%m-%d %H:%M:%S")
523 etxt = et.strftime("%Y-%m-%d %H:%M:%S")
525 recdb.reserveEverydayKeyword(title, chtxt, btxt, etxt, deltatime, opt, deltaday,counter-1)
527 recdb.reserveEverydayKeyword(title, chtxt, btxt, etxt, deltatime, opt, deltaday,-1)
528 recdata = epgdb.searchTime(title, btime, deltatime, chtxt)
537 bt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
538 et = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
539 btimet = bt.strftime("%Y-%m-%d %H:%M:%S")
540 etimet = et.strftime("%Y-%m-%d %H:%M:%S")
542 recdb.reserveKeyword(titlet, chtxt, btimet, etimet, deltatime, opt)
544 recdb.reserveKeyword(title, chtxt, btime, etime, deltatime, opt)
545 def type_decode_que(typetxt,chtxt,title,bt,et,opt):
546 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
547 etime = et.strftime("%Y-%m-%d %H:%M:%S")
548 tnow = datetime.datetime.now()
550 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
555 if typetxt== recdblist.REC_TS_DECODE_QUE:
556 typetxting=recdblist.REC_TS_DECODING
557 typetxtmiss=recdblist.REC_MISS_DECODE
558 typetxtencque=recdblist.REC_ENCODE_QUE
559 tnow = datetime.datetime.now()
561 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
563 if status.getB25Decoding() < 2:
564 pin = recpath + "/" + title
565 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
566 recdb.reserveReckey(typetxting, title, chtxt, btime, etime, opt)
567 tv2avi.b252ts(pin, chtxt, btime, etime, opt)
568 recdb.deleteReckey(typetxting, title, chtxt, btime)
569 if not os.access(recpath + "/" + title + ".ts", os.F_OK):
570 recdb.deleteReckey(typetxting, title, chtxt, btime)
571 recdb.reserveReckey(typetxtmiss, title, chtxt, btime, etime, opt)
573 auto_process.deleteTmpFile(recpath, title, ".ts")
574 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
575 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
577 if not re.search("D", opt):
578 tnow = datetime.datetime.now()
579 bt = tnow + datetime.timedelta(seconds=600)
581 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
582 etime = et.strftime("%Y-%m-%d %H:%M:%S")
583 recdb.reserveReckey(typetxtencque, title, chtxt, btime, etime, opt)
587 shutil.copy(os.path.join(recpath,title+".ts"), os.path.join(movepath,title+".ts"))
591 os.chmod(os.path.join(movepath,title+".ts"),0777)
594 recque.writeRecQue(movepath, chtxt, title, opt)
596 os.chmod(os.path.join(movepath,title+".recq"),0777)
600 if os.path.getsize(os.path.join(recpath,title+".ts"))==os.path.getsize(os.path.join(movepath,title+".ts")):
601 os.remove(os.path.join(recpath,title+".ts"))
602 except Exception, inst:
603 errtxt1="move ts error.\n"
604 errtxt2=str(type(inst))+"\n"
605 errtxt2=errtxt2+str(inst)
606 recdblist.addCommonlogEX("Error", "type_decode_que(timerec.py)", errtxt1,errtxt2+traceback.format_exc(),log_level=200)
607 recdb.reserveReckey(recdblist.REC_MOVE_END, title, chtxt, btime, etime, opt)
609 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
610 bt = bt + datetime.timedelta(seconds=600)
611 et = et + datetime.timedelta(seconds=600)
612 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
613 etime = et.strftime("%Y-%m-%d %H:%M:%S")
614 recdb.reserveReckey(typetxtnow, title, chtxt, btime, etime, opt)
617 def type_encode_que(typetxt,chtxt,title,bt,et,opt):
618 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
619 etime = et.strftime("%Y-%m-%d %H:%M:%S")
620 tnow = datetime.datetime.now()
622 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
626 if typetxt==recdblist.REC_ENCODE_QUE:
627 typetxting=recdblist.REC_ENCODE_LOCAL
628 typetxtfin=recdblist.REC_FIN_LOCAL
630 if status.getEncoding() < int(configreader.getConfEnv("enc_max")):
631 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
632 recdb.reserveReckey(typetxting, title, chtxt, btime, etime, opt)
633 recdblist.printutf8(opt)
634 pin = recpath + "/" + title + ".ts"
635 if re.search("d", opt):
636 pin = recpath + "/" + title + ".m2v"
637 if not os.path.exists(pin) or os.path.getsize(pin)<100*1000:
638 paac2 = recpath + "/" + title + "_2.aac"
639 pmp32 = recpath + "/" + title + "_2.mp3"
640 if not os.path.exists(paac2) and not os.path.exists(pmp32):
641 tv2audio.ts2dualaudio_BonTsDemux(os.path.join(recpath, title+".ts"),recdblist.BONTSDEMUX_DELAY,opt)
643 elif re.search("5", 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.ts2pentaaudio_BonTsDemux(os.path.join(recpath, title+".ts"), recdblist.BONTSDEMUX_DELAY, opt)
653 if configreader.getConfEnv("make_mp4")=="1":
657 if re.search("m", opt):
659 if re.search("4", opt):
661 recdblist.printutf8(pin)
662 if not re.search("0", opt):
664 pout = recpath + "/" + title + ".mp4"
665 tv2mp4.ts2mp4(pin, pout, opt)
667 pout = recpath + "/" + title + ".mkv"
668 tv2mkv.ts2mkv(pin, pout, opt)
669 if re.search("1", opt) or re.search("2", opt):
670 optt=opt.replace("1","MW1")
671 optt=optt.replace("2","MW2")
672 poutt = recpath + "/" + "m_"+title + ".mp4"
673 if re.search("d", opt) or re.search("5", opt):
674 if os.path.exists(os.path.join(recpath, "m_"+title+".m2v")):
675 shutil.move(os.path.join(recpath, title+".m2v"),os.path.join(recpath, "m_"+title+".m2v"))
676 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.aac")):
677 shutil.move(os.path.join(recpath, title+"_1.aac"),os.path.join(recpath, "m_"+title+"_1.aac"))
678 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.mp3")):
679 shutil.move(os.path.join(recpath, title+"_1.mp3"),os.path.join(recpath, "m_"+title+"_1.mp3"))
680 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.aac")):
681 shutil.move(os.path.join(recpath, title+"_2.aac"),os.path.join(recpath, "m_"+title+"_2.aac"))
682 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.mp3")):
683 shutil.move(os.path.join(recpath, title+"_2.mp3"),os.path.join(recpath, "m_"+title+"_2.mp3"))
684 shutil.move(os.path.join(recpath, title+".ts"),os.path.join(recpath, "m_"+title+".ts"))
685 tv2mp4.ts2mp4(os.path.join(recpath, "m_"+title+".ts"), poutt, optt)
686 shutil.move(os.path.join(recpath, "m_"+title+".ts"),os.path.join(recpath, title+".ts"))
689 poutt = recpath + "/" + "m_"+title + ".mp4"
690 shutil.move(os.path.join(recpath, title+".ts"),os.path.join(recpath, "m_"+title+".ts"))
691 if re.search("d", opt) or re.search("5", opt):
692 if os.path.exists(os.path.join(recpath, "m_"+title+".m2v")):
693 shutil.move(os.path.join(recpath, title+".m2v"),os.path.join(recpath, "m_"+title+".m2v"))
694 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.aac")):
695 shutil.move(os.path.join(recpath, title+"_1.aac"),os.path.join(recpath, "m_"+title+"_1.aac"))
696 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.mp3")):
697 shutil.move(os.path.join(recpath, title+"_1.mp3"),os.path.join(recpath, "m_"+title+"_1.mp3"))
698 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.aac")):
699 shutil.move(os.path.join(recpath, title+"_2.aac"),os.path.join(recpath, "m_"+title+"_2.aac"))
700 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.mp3")):
701 shutil.move(os.path.join(recpath, title+"_2.mp3"),os.path.join(recpath, "m_"+title+"_2.mp3"))
702 tv2mp4.ts2mp4(os.path.join(recpath, "m_"+title+".ts"), poutt, optt)
703 shutil.move(os.path.join(recpath, "m_"+title+".ts"),os.path.join(recpath, title+".ts"))
704 recdb.deleteReckey(typetxting, title, chtxt, btime)
706 if re.search("E", opt):
708 if os.path.exists(os.path.join(recpath,title+".mp4")):
710 shutil.copy(os.path.join(recpath,title+".mp4"), os.path.join(movepath,title+".mp4"))
714 os.chmod(os.path.join(movepath,title+".mp4"),0777)
717 recque.writeRecQue(movepath, chtxt, title, opt)
719 os.chmod(os.path.join(movepath,title+".recq"),0777)
722 elif os.path.exists(os.path.join(recpath,title+".mkv")):
724 shutil.copy(os.path.join(recpath,title+".mkv"), os.path.join(movepath,title+".mkv"))
728 os.chmod(os.path.join(movepath,title+".mkv"),0777)
731 recque.writeRecQue(movepath, chtxt, title, opt)
733 os.chmod(os.path.join(movepath,title+".recq"),0777)
736 except Exception, inst:
737 errtxt1="move mkv/mp4 error."
738 errtxt2=str(type(inst))+"\n"
739 errtxt2=errtxt2+str(inst)
740 recdblist.addCommonlogEX("Error", "type_encode_que(timerec.py)", errtxt1,errtxt2+traceback.format_exc(),log_level=200)
741 recdb.reserveReckey(recdblist.REC_MOVE_END, title, chtxt, btime, etime, opt)
742 recdb.reserveReckey(typetxtfin, title, chtxt, btime, etime, opt)
745 recdb.deleteReckey(typetxtnow, title, chtxt, btime)
746 bt = bt + datetime.timedelta(seconds=600)
747 et = et + datetime.timedelta(seconds=600)
748 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
749 etime = et.strftime("%Y-%m-%d %H:%M:%S")
750 recdb.reserveReckey(typetxtnow, title, chtxt, btime, etime, opt)