3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009-2010 Yukikaze
29 recpath = configreader.getpath('recpath')
30 movepath = configreader.getpath('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:
42 recdb.delete_old("24")
43 recdb.delete_old_auto_bayes("1")
44 recdb.delete_old_auto_keyword("1")
45 tasks = recdb.getnow("3")
46 inum = recdb.countRecNow_minutes("10")
47 recdblist.printutf8(u"rec10処理開始"+ datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),verbose_level=800)
48 recdblist.printutf8(u"直近録画予約件数:" + str(inum) + u"BS/CS録画中件数:" + str(status.getBSCSRecording()) + u"TE録画中件数:" + str(status.getTERecording()) ,verbose_level=800)
51 dnow=datetime.datetime.now()
57 for k in recdb.get_key():
59 recque.searchRecQue(recpath)
67 auto_process.auto_check(recpath)
69 auto_process.kill_dead_encode(recpath)
71 update = chdb.update()
80 if bctype.find('te') > -1:
81 recnum = status.getTERecording() + recdb.countRecNow_minutes_TE("10")
82 recdblist.printutf8(u"放送種別:"+bctype + u"||該当チューナー実行中件数:" + str(status.getTERecording()) + u":直近予約件数:" + str(recdb.countRecNow_minutes_TE("10")),verbose_level=800)
83 recnum = int(configreader.getenv("te_max")) -recnum
85 recnum = status.getBSCSRecording() + recdb.countRecNow_minutes_BSCS("10")
86 recdblist.printutf8(u"放送種別:"+bctype + u"||該当チューナー実行中件数:" + str(status.getBSCSRecording()) + u":直近予約件数:" + str(recdb.countRecNow_minutes_BSCS("10")),verbose_level=800)
87 recnum = int(configreader.getenv("bscs_max")) -recnum
89 recdblist.printutf8(str(update),verbose_level=750)
90 rec10d.rec10db.update_status_by_bctype_epg_ch(bctype, "0")
91 epgdb.updatebc(bctype)
92 update = chdb.update()
97 auto_process.update_all_timeline_epg()
104 auto_process.update_all_timeline_epg()
107 typetxt = task["type"]
109 chtxt = task['chtxt']
113 title = task['title']
117 btime = task['btime']
118 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
121 bt = datetime.datetime.strptime("2009-01-01 00:00:00", "%Y-%m-%d %H:%M:%S")
123 etime = task['etime']
124 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
127 et = datetime.datetime.strptime("2009-01-01 00:00:00", "%Y-%m-%d %H:%M:%S")
132 tnow = datetime.datetime.now()
134 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
135 if task["type"] == recdblist.REC_RESERVE:#"res,"+chtxt+","+title+","+btime+","+etime+","+opt
137 if pid != 0:#親プロセスの場合
139 else:#子プロセスの場合 アップデートを行って終了
140 type_reserve(task["type"],chtxt,title,bt,et,opt)
142 elif task["type"] == recdblist.REC_KEYWORD:#"key,"+chtxt+","+keyword+","+btime+","+deltatime+","+opt
143 deltatime = task['deltatime']
145 if pid != 0:#親プロセスの場合
147 else:#子プロセスの場合 アップデートを行って終了
148 type_keyword(task["type"],chtxt,title, bt, et, opt, deltatime)
150 elif task["type"] == recdblist.REC_KEYWORD_EVERY_SOME_DAYS:#"keyevery,"+chtxt+","+keyword+","+btime+","+deltatime+","+opt+","+deltaday
151 deltatime = task['deltatime']
152 deltaday = task['deltaday']
154 keyeverycounter=task['counter']
158 if pid != 0:#親プロセスの場合
160 else:#子プロセスの場合 アップデートを行って終了
161 type_keyword_every_day(task["type"],chtxt, title, bt, et, opt, deltatime, deltaday,keyeverycounter)
163 elif task["type"] == recdblist.REC_FINAL_RESERVE:#"rec,"+chtxt+","+title+","+btime+","+etime+","+opt
165 if pid != 0:#親プロセスの場合
167 else:#子プロセスの場合 アップデートを行って終了
168 type_final(task["type"],chtxt, title, bt, et, opt)
170 elif task["type"] == recdblist.REC_TS_DECODE_QUE:
173 if pid != 0:#親プロセスの場合
175 else:#子プロセスの場合 アップデートを行って終了
177 type_decode_que(task["type"],chtxt, title, bt, et, opt)
179 elif task["type"] == recdblist.REC_ENCODE_QUE:
180 encodenum=encodenum+1
182 if pid != 0:#親プロセスの場合
184 else:#子プロセスの場合 アップデートを行って終了
185 time.sleep(5*encodenum)
186 type_encode_que(task["type"],chtxt, title, bt, et, opt)
188 elif task["type"] == recdblist.REC_AVI_TO_MKV:
196 if configreader.getenv("make_mp4")==1:
200 if re.search("m", opt):
202 if re.search("4", opt):
204 recdb.del_reckey(recdblist.REC_AVI_TO_MKV, title, chtxt, btime)
205 recdb.rec_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
207 tv2mp4.raw2mp4(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mp4"),opt)
209 tv2mkv.raw2mkv(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mkv"),opt)
210 recdb.del_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime)
212 elif task["type"] == recdblist.REC_AVI_TO_MP4:
220 if configreader.getenv("make_mp4")==1:
224 if re.search("m", opt):
226 if re.search("4", opt):
228 recdb.del_reckey(recdblist.REC_AVI_TO_MP4, title, chtxt, btime)
229 recdb.rec_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
231 tv2mp4.ts2mp4(pin, pout, opt)
232 tv2mp4.raw2mp4(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mp4"),opt)
234 tv2mkv.raw2mkv(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mkv"),opt)
235 recdb.del_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime)
237 elif task["type"] == recdblist.REC_MKV_TO_MP4:
243 recdb.del_reckey(recdblist.REC_MKV_TO_MP4, title, chtxt, btime)
244 recdb.rec_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
245 tv2mp4.mkv2mp4(os.path.join(recpath,title+".mkv"),os.path.join(recpath,title+".mp4"))
246 recdb.del_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime)
249 def search_keyword(key):
250 tnow = datetime.datetime.now()
251 nows =tnow.strftime("%Y-%m-%d %H:%M:%S")
253 recdatum = epgdb.searchtime_auto(k,nows, "144")
254 for recdata in recdatum:
260 btt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
261 ett = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
262 btimet = btt.strftime("%Y-%m-%d %H:%M:%S")
263 etimet = ett.strftime("%Y-%m-%d %H:%M:%S")
264 if status.getSettings_auto_jbk()==1:
265 topt=status.getSettings_auto_opt()
269 maxnum=epgdb.count_schedule_timeline(btimet, etimet)[1]
270 maxnum=int(configreader.getenv("bscs_max"))-maxnum
272 maxnum=epgdb.count_schedule_timeline(btimet, etimet)[0]
273 maxnum=int(configreader.getenv("te_max"))-maxnum
275 topt=status.getSettings_auto_opt()
276 recdb.recreserv(titlet,chtxtt, btimet, etimet,topt)
277 except Exception, inst:
278 recdblist.Commonlogex("Error", "search_keyword_auto_jbk(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
281 recdb.add_auto_keyword(chtxtt, titlet, btimet, etimet)
282 except Exception, inst:
283 recdblist.Commonlogex("Error", "search_keyword(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
284 def type_reserve(typetxt,chtxt,title,bt,et,opt):
285 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
286 etime = et.strftime("%Y-%m-%d %H:%M:%S")
289 if typetxt==recdblist.REC_RESERVE:
290 typetxtfinal=recdblist.REC_FINAL_RESERVE
291 tnow = datetime.datetime.now()
293 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
294 if (dt < 58 * 60 and dt > 30 * 60):
295 bctypet = chdb.chtxtsearch(chtxt)['bctype']
296 chdatat = rec10d.rec10db.select_by_bctype_epg_ch(bctypet)
297 dt1 = datetime.datetime.strptime(chdatat[0][5], "%Y-%m-%d %H:%M:%S")-datetime.datetime.now()
298 dt1 = dt1.days * 24 * 60 * 60 + dt1.seconds
300 recdata = epgdb.searchtime2(title, btime, "5", chtxt)
308 bt = datetime.datetime.strptime(btimen, "%Y-%m-%d %H:%M:%S")
309 et = datetime.datetime.strptime(etimen, "%Y-%m-%d %H:%M:%S")
310 btimen = bt.strftime("%Y-%m-%d %H:%M:%S")
311 etimen = et.strftime("%Y-%m-%d %H:%M:%S")
314 recdb.del_reckey(typetxtnow, title, chtxt, btime)
315 recdb.rec_reckey(typetxtfinal, titlen, chtxtn, btimen, etimen, opt)
316 recdb.rec_reclog(titlen, chtxtn, btimen, etimen, opt, exp, longexp, category)
317 auto_rec.add_key(chtxt, titlen,exp+" "+longexp)
318 auto_rec.add_key("ALL", titlen,exp+" "+longexp)
319 recdblist.printutf8(u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen)
320 except Exception, inst:
321 recdblist.Commonlogex("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
323 recdblist.printutf8(u"追いかけ機能エラー:番組データが見付かりません。")
325 if rec10d.rec10db.select_by_bctype_epg_ch(bctypet)[0][6] != "0":
326 rec10d.rec10db.update_status_by_bctype_epg_ch(bctypet, "3")
328 elif (dt <= 30 * 60 and dt > 20 * 60):
329 recdata = epgdb.searchtime2(title, btime, "5", chtxt)
337 bt = datetime.datetime.strptime(btimen, "%Y-%m-%d %H:%M:%S")
338 et = datetime.datetime.strptime(etimen, "%Y-%m-%d %H:%M:%S")
339 btimen = bt.strftime("%Y-%m-%d %H:%M:%S")
340 etimen = et.strftime("%Y-%m-%d %H:%M:%S")
343 recdb.del_reckey(typetxtnow, title, chtxt, btime)
344 recdb.rec_reckey(typetxtfinal, titlen, chtxtn, btimen, etimen, opt)
345 recdb.rec_reclog(titlen, chtxtn, btimen, etimen, opt, exp, longexp, category)
346 auto_rec.add_key(chtxt, titlen,exp+" "+longexp)
347 auto_rec.add_key("ALL", titlen,exp+" "+longexp)
348 #recdblist.printutf8(u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen)
349 recdblist.Commonlogex(u"通常", "Oikake (timerec.py)",u"追いかけ機能実行中",u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen,log_level=500)
350 except Exception, inst:
351 recdblist.Commonlogex("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
354 recdb.del_reckey(typetxtnow, title, chtxt, btime)
355 recdb.rec_reckey(typetxtfinal, title, chtxt, btime, etime, opt)
356 except Exception, inst:
357 recdblist.Commonlogex("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
358 def type_final(typetxt,chtxt,title,bt,et,opt):
359 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
360 etime = et.strftime("%Y-%m-%d %H:%M:%S")
364 if typetxt==recdblist.REC_FINAL_RESERVE:
365 typetxting=recdblist.REC_TS_RECORDING
366 typetxtdecque=recdblist.REC_TS_DECODE_QUE
367 tnow = datetime.datetime.now()
369 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
370 if dt < 6 * 60 and dt > 0:
372 recdb.del_reckey(typetxtnow, title, chtxt, btime)
373 testpath=[os.path.join(recpath,title+".ts.b25")]
374 testpath.append(os.path.join(recpath,title+".ts"))
375 testpath.append(os.path.join(recpath,title+".avi"))
376 testpath.append(os.path.join(recpath,title+".mp4"))
377 testpath.append(os.path.join(recpath,title+".log"))
380 if os.path.exists(ti):
382 if re.search("N", opt) or tcheck>0:
385 iff=u"("+configreader.getenv("iff")+u")_"
389 newtitle=newtitle+u"_"+iff+newtime.strftime("%Y-%m-%dT%H-%M-%S")
390 recdb.rec_reckey(typetxting, newtitle, chtxt, btime, etime, opt)
391 recdblist.Commonlogex(u"通常","timerec.py",u"録画開始 "+newtitle+" "+btime+" "+etime,"",log_level=500)
392 tv2avi.timetv2b25(recpath + "/" + newtitle + ".avi", chtxt, btime, etime, opt)
393 recdb.del_reckey(typetxting, newtitle, chtxt, btime)
394 if not re.search("R", opt):
395 tnow = datetime.datetime.now()
396 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
397 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
399 bt = tnow + datetime.timedelta(seconds=600)
400 et = et + dt + datetime.timedelta(seconds=600)
401 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
402 etime = et.strftime("%Y-%m-%d %H:%M:%S")
403 recdb.rec_reckey(typetxtdecque, newtitle, chtxt, btime, etime, opt)
406 shutil.copy(os.path.join(recpath,title+".ts.b25"), os.path.join(movepath,title+".ts.b25"))
407 os.chmod(os.path.join(movepath,title+".ts.b25"),0777)
408 recque.writeRecQue(movepath, chtxt, title, opt)
409 os.chmod(os.path.join(movepath,title+".recq"),0777)
412 recdb.rec_reckey(recdblist.REC_MOVE_END, newtitle, chtxt, btime, etime, opt)
414 def type_keyword(typetxt,chtxt,title,bt,et,opt,deltatime):
415 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
416 etime = et.strftime("%Y-%m-%d %H:%M:%S")
419 if typetxt==recdblist.REC_KEYWORD:
420 typetxtres=recdblist.REC_RESERVE
421 tnow = datetime.datetime.now()
423 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
424 recdblist.printutf8(str(dt), verbose_level=800)
426 recdata = epgdb.searchtime2(title, btime, deltatime, chtxt)
435 bt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
436 et = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
437 btimet = bt.strftime("%Y-%m-%d %H:%M:%S")
438 etimet = et.strftime("%Y-%m-%d %H:%M:%S")
440 recdb.del_reckey(typetxtnow, title, chtxt, btime)
441 recdb.rec_reckey(typetxtres, titlet, chtxtt, btimet, etimet, opt)
442 recdb.rec_reclog(titlet, chtxtt, btimet, etimet, opt, exp,longexp,category)
443 auto_rec.add_key(chtxt, titlet,exp+" "+longexp)
444 auto_rec.add_key("ALL", titlet,exp+" "+longexp)
445 recdblist.Commonlogex(u"通常","timerec.py",u"key "+title+u" : "+titlet+u" "+btimet+u" "+etimet,"",log_level=500)
446 #except Exception, inst:
447 # recdblist.printutf8("Error happened in REC_KEYWORD DB")
448 # recdblist.printutf8(type(inst))
449 # recdblist.printutf8(inst)
451 recdblist.printutf8("nothing match")
452 def type_keyword_every_day(type,chtxt,title,bt,et,opt,deltatime,deltaday,counter):
453 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
454 etime = et.strftime("%Y-%m-%d %H:%M:%S")
455 tnow = datetime.datetime.now()
457 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
458 dd = datetime.timedelta(days=int(deltaday))
460 recdb.del_reckey(recdblist.REC_KEYWORD_EVERY_SOME_DAYS, title, chtxt, btime)
463 btxt = bt.strftime("%Y-%m-%d %H:%M:%S")
464 etxt = et.strftime("%Y-%m-%d %H:%M:%S")
465 recdb.everyreserv(title, chtxt, btxt, etxt, deltatime, opt, deltaday)
467 recdb.del_reckey(recdblist.REC_KEYWORD_EVERY_SOME_DAYS, title, chtxt, btime)
470 btxt = bt.strftime("%Y-%m-%d %H:%M:%S")
471 etxt = et.strftime("%Y-%m-%d %H:%M:%S")
473 recdb.everyreserv(title, chtxt, btxt, etxt, deltatime, opt, deltaday,counter-1)
475 recdb.everyreserv(title, chtxt, btxt, etxt, deltatime, opt, deltaday,-1)
476 recdata = epgdb.searchtime2(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.keyreserv(titlet, chtxtt, btimet, etimet, deltatime, opt)
492 recdb.keyreserv(title, chtxt, btime, etime, deltatime, opt)
493 def type_decode_que(typetxt,chtxt,title,bt,et,opt):
494 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
495 etime = et.strftime("%Y-%m-%d %H:%M:%S")
496 tnow = datetime.datetime.now()
498 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
503 if typetxt== recdblist.REC_TS_DECODE_QUE:
504 typetxting=recdblist.REC_TS_DECODING
505 typetxtmiss=recdblist.REC_MISS_DECODE
506 typetxtencque=recdblist.REC_ENCODE_QUE
507 tnow = datetime.datetime.now()
509 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
511 if status.getB25Decoding() < 2:
512 pin = recpath + "/" + title
513 recdb.del_reckey(typetxtnow, title, chtxt, btime)
514 recdb.rec_reckey(typetxting, title, chtxt, btime, etime, opt)
515 tv2avi.b252ts(pin, chtxt, btime, etime, opt)
516 recdb.del_reckey(typetxting, title, chtxt, btime)
517 if not os.access(recpath + "/" + title + ".ts", os.F_OK):
518 recdb.del_reckey(typetxting, title, chtxt, btime)
519 recdb.rec_reckey(typetxtmiss, title, chtxt, btime, etime, opt)
521 auto_process.deltmpfile(recpath, title, ".ts")
522 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
523 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
525 if not re.search("D", opt):
526 tnow = datetime.datetime.now()
527 bt = tnow + datetime.timedelta(seconds=600)
529 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
530 etime = et.strftime("%Y-%m-%d %H:%M:%S")
531 recdb.rec_reckey(typetxtencque, title, chtxt, btime, etime, opt)
534 shutil.copy(os.path.join(recpath,title+".ts"), os.path.join(movepath,title+".ts"))
535 os.chmod(os.path.join(movepath,title+".ts"),0777)
536 recque.writeRecQue(movepath, chtxt, title, opt)
537 os.chmod(os.path.join(movepath,title+".recq"),0777)
539 if os.path.getsize(os.path.join(recpath,title+".ts"))==os.path.getsize(os.path.join(movepath,title+".ts")):
540 os.remove(os.path.join(recpath,title+".ts"))
541 except Exception, inst:
542 errtxt1="move ts error.\n"
543 errtxt2=str(type(inst))+"\n"
544 errtxt2=errtxt2+str(inst)
545 recdblist.Commonlogex("Error", "type_decode_que(timerec.py)", errtxt1,errtxt2+traceback.format_exc(),log_level=200)
546 recdb.rec_reckey(recdblist.REC_MOVE_END, title, chtxt, btime, etime, opt)
548 recdb.del_reckey(typetxtnow, title, chtxt, btime)
549 bt = bt + datetime.timedelta(seconds=600)
550 et = et + datetime.timedelta(seconds=600)
551 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
552 etime = et.strftime("%Y-%m-%d %H:%M:%S")
553 recdb.rec_reckey(typetxtnow, title, chtxt, btime, etime, opt)
556 def type_encode_que(typetxt,chtxt,title,bt,et,opt):
557 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
558 etime = et.strftime("%Y-%m-%d %H:%M:%S")
559 tnow = datetime.datetime.now()
561 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
565 if typetxt==recdblist.REC_ENCODE_QUE:
566 typetxting=recdblist.REC_ENCODE_LOCAL
567 typetxtfin=recdblist.REC_FIN_LOCAL
569 if status.getEncoding() < int(configreader.getenv("enc_max")):
570 recdb.del_reckey(typetxtnow, title, chtxt, btime)
571 recdb.rec_reckey(typetxting, title, chtxt, btime, etime, opt)
572 recdblist.printutf8(opt)
573 pin = recpath + "/" + title + ".ts"
574 if re.search("d", opt):
575 pin = recpath + "/" + title + ".m2v"
576 if not os.path.exists(pin) or os.path.getsize(pin)<100*1000:
577 paac2 = recpath + "/" + title + "_2.aac"
578 pmp32 = recpath + "/" + title + "_2.mp3"
579 if not os.path.exists(paac2) and not os.path.exists(pmp32):
580 tv2audio.ts2dualaudio_BonTsDemux(os.path.join(recpath, title+".ts"),recdblist.BONTSDEMUX_DELAY,opt)
582 elif re.search("5", opt):
583 pin = recpath + "/" + title + ".m2v"
584 if not os.path.exists(pin) or os.path.getsize(pin)<100*1000:
585 paac2 = recpath + "/" + title + "_2.aac"
586 pmp32 = recpath + "/" + title + "_2.mp3"
587 if not os.path.exists(paac2) and not os.path.exists(pmp32):
588 tv2audio.ts2pentaaudio_BonTsDemux(os.path.join(recpath, title+".ts"), recdblist.BONTSDEMUX_DELAY, opt)
592 if configreader.getenv("make_mp4")=="1":
596 if re.search("m", opt):
598 if re.search("4", opt):
600 recdblist.printutf8(pin)
601 if not re.search("0", opt):
603 pout = recpath + "/" + title + ".mp4"
604 tv2mp4.ts2mp4(pin, pout, opt)
606 pout = recpath + "/" + title + ".mkv"
607 tv2mkv.ts2mkv(pin, pout, opt)
608 if re.search("8", opt) or re.search("9", opt):
610 optt=optt.replace("8","MW8")
611 optt=optt.replace("9","MW9")
612 poutt = recpath + "/" + "m_"+title + ".mp4"
613 if re.search("d", opt) or re.search("5", opt):
614 if os.path.exists(os.path.join(recpath, "m_"+title+".m2v")):
615 shutil.move(os.path.join(recpath, title+".m2v"),os.path.join(recpath, "m_"+title+".m2v"))
616 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.aac")):
617 shutil.move(os.path.join(recpath, title+"_1.aac"),os.path.join(recpath, "m_"+title+"_1.aac"))
618 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.mp3")):
619 shutil.move(os.path.join(recpath, title+"_1.mp3"),os.path.join(recpath, "m_"+title+"_1.mp3"))
620 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.aac")):
621 shutil.move(os.path.join(recpath, title+"_2.aac"),os.path.join(recpath, "m_"+title+"_2.aac"))
622 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.mp3")):
623 shutil.move(os.path.join(recpath, title+"_2.mp3"),os.path.join(recpath, "m_"+title+"_2.mp3"))
624 shutil.move(os.path.join(recpath, title+".ts"),os.path.join(recpath, "m_"+title+".ts"))
625 tv2mp4.ts2mp4(os.path.join(recpath, "m_"+title+".ts"), poutt, optt)
626 shutil.move(os.path.join(recpath, "m_"+title+".ts"),os.path.join(recpath, title+".ts"))
629 optt=optt.replace("8","MW8")
630 optt=optt.replace("9","MW9")
631 poutt = recpath + "/" + "m_"+title + ".mp4"
632 shutil.move(os.path.join(recpath, title+".ts"),os.path.join(recpath, "m_"+title+".ts"))
633 if re.search("d", opt) or re.search("5", opt):
634 if os.path.exists(os.path.join(recpath, "m_"+title+".m2v")):
635 shutil.move(os.path.join(recpath, title+".m2v"),os.path.join(recpath, "m_"+title+".m2v"))
636 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.aac")):
637 shutil.move(os.path.join(recpath, title+"_1.aac"),os.path.join(recpath, "m_"+title+"_1.aac"))
638 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.mp3")):
639 shutil.move(os.path.join(recpath, title+"_1.mp3"),os.path.join(recpath, "m_"+title+"_1.mp3"))
640 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.aac")):
641 shutil.move(os.path.join(recpath, title+"_2.aac"),os.path.join(recpath, "m_"+title+"_2.aac"))
642 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.mp3")):
643 shutil.move(os.path.join(recpath, title+"_2.mp3"),os.path.join(recpath, "m_"+title+"_2.mp3"))
644 tv2mp4.ts2mp4(os.path.join(recpath, "m_"+title+".ts"), poutt, optt)
645 shutil.move(os.path.join(recpath, "m_"+title+".ts"),os.path.join(recpath, title+".ts"))
646 recdb.del_reckey(typetxting, title, chtxt, btime)
648 if re.search("E", opt):
650 if os.path.exists(os.path.join(recpath,title+".mp4")):
651 shutil.copy(os.path.join(recpath,title+".mp4"), os.path.join(movepath,title+".mp4"))
652 os.chmod(os.path.join(movepath,title+".mp4"),0777)
653 recque.writeRecQue(movepath, chtxt, title, opt)
654 os.chmod(os.path.join(movepath,title+".recq"),0777)
655 elif os.path.exists(os.path.join(recpath,title+".mkv")):
656 shutil.copy(os.path.join(recpath,title+".mkv"), os.path.join(movepath,title+".mkv"))
657 os.chmod(os.path.join(movepath,title+".mkv"),0777)
658 recque.writeRecQue(movepath, chtxt, title, opt)
659 os.chmod(os.path.join(movepath,title+".recq"),0777)
660 except Exception, inst:
661 errtxt1="move mkv/mp4 error."
662 errtxt2=str(type(inst))+"\n"
663 errtxt2=errtxt2+str(inst)
664 recdblist.Commonlogex("Error", "type_encode_que(timerec.py)", errtxt1,errtxt2+traceback.format_exc(),log_level=200)
665 recdb.rec_reckey(recdblist.REC_MOVE_END, title, chtxt, btime, etime, opt)
666 recdb.rec_reckey(typetxtfin, title, chtxt, btime, etime, opt)
669 recdb.del_reckey(typetxtnow, title, chtxt, btime)
670 bt = bt + datetime.timedelta(seconds=600)
671 et = et + datetime.timedelta(seconds=600)
672 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
673 etime = et.strftime("%Y-%m-%d %H:%M:%S")
674 recdb.rec_reckey(typetxtnow, title, chtxt, btime, etime, opt)