3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009-2010 Yukikaze
27 recpath = configreader.getpath('recpath')
28 movepath = configreader.getpath('move_destpath')
29 path = str(os.path.dirname(os.path.abspath(__file__))) + "/"
36 if rec10d.rec10db.select_installed_in_status()==0 or rec10d.rec10db.select_version_in_status()<recdblist.version:
40 recdb.delete_old("24")
41 recdb.delete_old_auto_bayes("1")
42 recdb.delete_old_auto_keyword("1")
43 tasks = recdb.getnow("3")
44 inum = recdb.countRecNow_minutes("10")
45 recdblist.printutf8(u"rec10処理開始"+ datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
46 recdblist.printutf8(u"直近録画予約件数:" + str(inum) + u"BS/CS録画中件数:" + str(status.getBSCSRecording()) + u"TE録画中件数:" + str(status.getTERecording()) )
49 dnow=datetime.datetime.now()
55 for k in recdb.get_key():
64 auto_process.auto_check(recpath)
66 auto_process.kill_dead_encode(recpath)
68 update = chdb.update()
77 if bctype.find('te') > -1:
78 recnum = status.getTERecording() + recdb.countRecNow_minutes_TE("10")
79 recdblist.printutf8(u"放送種別:"+bctype + u"||該当チューナー実行中件数:" + str(status.getTERecording()) + u":直近予約件数:" + str(recdb.countRecNow_minutes_TE("10")))
80 recnum = int(configreader.getenv("te_max")) -recnum
82 recnum = status.getBSCSRecording() + recdb.countRecNow_minutes_BSCS("10")
83 recdblist.printutf8(u"放送種別:"+bctype + u"||該当チューナー実行中件数:" + str(status.getBSCSRecording()) + u":直近予約件数:" + str(recdb.countRecNow_minutes_BSCS("10")))
84 recnum = int(configreader.getenv("bscs_max")) -recnum
86 recdblist.printutf8(str(update))
87 rec10d.rec10db.update_status_by_bctype_epg_ch(bctype, "0")
88 epgdb.updatebc(bctype)
89 update = chdb.update()
94 auto_process.update_all_timeline_epg()
101 auto_process.update_all_timeline_epg()
104 typetxt = task["type"]
106 chtxt = task['chtxt']
110 title = task['title']
114 btime = task['btime']
115 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
118 bt = datetime.datetime.strptime("2009-01-01 00:00:00", "%Y-%m-%d %H:%M:%S")
120 etime = task['etime']
121 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
124 et = datetime.datetime.strptime("2009-01-01 00:00:00", "%Y-%m-%d %H:%M:%S")
129 tnow = datetime.datetime.now()
131 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
132 if task["type"] == recdblist.REC_RESERVE:#"res,"+chtxt+","+title+","+btime+","+etime+","+opt
134 if pid != 0:#親プロセスの場合
136 else:#子プロセスの場合 アップデートを行って終了
137 type_reserve(task["type"],chtxt,title,bt,et,opt)
139 elif task["type"] == recdblist.REC_KEYWORD:#"key,"+chtxt+","+keyword+","+btime+","+deltatime+","+opt
140 deltatime = task['deltatime']
142 if pid != 0:#親プロセスの場合
144 else:#子プロセスの場合 アップデートを行って終了
145 type_keyword(task["type"],chtxt,title, bt, et, opt, deltatime)
147 elif task["type"] == recdblist.REC_KEYWORD_EVERY_SOME_DAYS:#"keyevery,"+chtxt+","+keyword+","+btime+","+deltatime+","+opt+","+deltaday
148 deltatime = task['deltatime']
149 deltaday = task['deltaday']
151 keyeverycounter=task['counter']
155 if pid != 0:#親プロセスの場合
157 else:#子プロセスの場合 アップデートを行って終了
158 type_keyword_every_day(task["type"],chtxt, title, bt, et, opt, deltatime, deltaday,keyeverycounter)
160 elif task["type"] == recdblist.REC_FINAL_RESERVE:#"rec,"+chtxt+","+title+","+btime+","+etime+","+opt
162 if pid != 0:#親プロセスの場合
164 else:#子プロセスの場合 アップデートを行って終了
165 type_final(task["type"],chtxt, title, bt, et, opt)
167 elif task["type"] == recdblist.REC_TS_DECODE_QUE:
170 if pid != 0:#親プロセスの場合
172 else:#子プロセスの場合 アップデートを行って終了
174 type_decode_que(task["type"],chtxt, title, bt, et, opt)
176 elif task["type"] == recdblist.REC_ENCODE_QUE:
177 encodenum=encodenum+1
179 if pid != 0:#親プロセスの場合
181 else:#子プロセスの場合 アップデートを行って終了
182 time.sleep(5*encodenum)
183 type_encode_que(task["type"],chtxt, title, bt, et, opt)
185 elif task["type"] == recdblist.REC_AVI_TO_MKV:
193 if configreader.getenv("make_mp4")==1:
197 if re.search("m", opt):
199 if re.search("4", opt):
201 recdb.del_reckey(recdblist.REC_AVI_TO_MKV, title, chtxt, btime)
202 recdb.rec_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
204 tv2mp4.raw2mp4(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mp4"),opt)
206 tv2mkv.raw2mkv(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mkv"),opt)
207 recdb.del_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime)
209 elif task["type"] == recdblist.REC_AVI_TO_MP4:
217 if configreader.getenv("make_mp4")==1:
221 if re.search("m", opt):
223 if re.search("4", opt):
225 recdb.del_reckey(recdblist.REC_AVI_TO_MP4, title, chtxt, btime)
226 recdb.rec_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
228 tv2mp4.ts2mp4(pin, pout, opt)
229 tv2mp4.raw2mp4(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mp4"),opt)
231 tv2mkv.raw2mkv(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mkv"),opt)
232 recdb.del_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime)
234 elif task["type"] == recdblist.REC_MKV_TO_MP4:
240 recdb.del_reckey(recdblist.REC_MKV_TO_MP4, title, chtxt, btime)
241 recdb.rec_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
242 tv2mp4.mkv2mp4(os.path.join(recpath,title+".mkv"),os.path.join(recpath,title+".mp4"))
243 recdb.del_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime)
246 def search_keyword(key):
247 tnow = datetime.datetime.now()
248 nows =tnow.strftime("%Y-%m-%d %H:%M:%S")
250 recdatum = epgdb.searchtime_auto(k,nows, "144")
251 for recdata in recdatum:
257 btt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
258 ett = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
259 btimet = btt.strftime("%Y-%m-%d %H:%M:%S")
260 etimet = ett.strftime("%Y-%m-%d %H:%M:%S")
261 if status.getSettings_auto_jbk()==1:
262 topt=status.getSettings_auto_opt()
266 maxnum=epgdb.count_schedule_timeline(btimet, etimet)[1]
267 maxnum=int(configreader.getenv("bscs_max"))-maxnum
269 maxnum=epgdb.count_schedule_timeline(btimet, etimet)[0]
270 maxnum=int(configreader.getenv("te_max"))-maxnum
272 topt=status.getSettings_auto_opt()
273 recdb.recreserv(titlet,chtxtt, btimet, etimet,topt)
274 except Exception, inst:
275 recdblist.printutf8("error occures in search_keyword_auto_jbk")
276 recdblist.printutf8(str(type(inst)))
277 recdblist.printutf8(str(inst))
280 recdb.add_auto_keyword(chtxtt, titlet, btimet, etimet)
281 except Exception, inst:
282 recdblist.printutf8("error occures in search_keyword")
283 recdblist.printutf8(str(type(inst)))
284 recdblist.printutf8(str(inst))
285 def type_reserve(typetxt,chtxt,title,bt,et,opt):
286 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
287 etime = et.strftime("%Y-%m-%d %H:%M:%S")
290 if typetxt==recdblist.REC_RESERVE:
291 typetxtfinal=recdblist.REC_FINAL_RESERVE
292 tnow = datetime.datetime.now()
294 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
295 if (dt < 58 * 60 and dt > 30 * 60):
296 bctypet = chdb.chtxtsearch(chtxt)['bctype']
297 chdatat = rec10d.rec10db.select_by_bctype_epg_ch(bctypet)
298 dt1 = datetime.datetime.strptime(chdatat[0][5], "%Y-%m-%d %H:%M:%S")-datetime.datetime.now()
299 dt1 = dt1.days * 24 * 60 * 60 + dt1.seconds
301 recdata = epgdb.searchtime2(title, btime, "5", chtxt)
309 bt = datetime.datetime.strptime(btimen, "%Y-%m-%d %H:%M:%S")
310 et = datetime.datetime.strptime(etimen, "%Y-%m-%d %H:%M:%S")
311 btimen = bt.strftime("%Y-%m-%d %H:%M:%S")
312 etimen = et.strftime("%Y-%m-%d %H:%M:%S")
315 recdb.del_reckey(typetxtnow, title, chtxt, btime)
316 recdb.rec_reckey(typetxtfinal, titlen, chtxtn, btimen, etimen, opt)
317 recdb.rec_reclog(titlen, chtxtn, btimen, etimen, opt, exp, longexp, category)
318 auto_rec.add_key(chtxt, titlen,exp+" "+longexp)
319 auto_rec.add_key("ALL", titlen,exp+" "+longexp)
320 recdblist.printutf8(u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen)
321 except Exception, inst:
322 recdblist.printutf8("Error happened in Oikake DB")
323 recdblist.printutf8(str(type(inst)))
324 recdblist.printutf8(str(inst))
326 recdblist.printutf8(u"追いかけ機能エラー:番組データが見付かりません。")
328 if rec10d.rec10db.select_by_bctype_epg_ch(bctypet)[0][6] != "0":
329 rec10d.rec10db.update_status_by_bctype_epg_ch(bctypet, "3")
331 elif (dt <= 30 * 60 and dt > 20 * 60):
332 recdata = epgdb.searchtime2(title, btime, "5", chtxt)
340 bt = datetime.datetime.strptime(btimen, "%Y-%m-%d %H:%M:%S")
341 et = datetime.datetime.strptime(etimen, "%Y-%m-%d %H:%M:%S")
342 btimen = bt.strftime("%Y-%m-%d %H:%M:%S")
343 etimen = et.strftime("%Y-%m-%d %H:%M:%S")
346 recdb.del_reckey(typetxtnow, title, chtxt, btime)
347 recdb.rec_reckey(typetxtfinal, titlen, chtxtn, btimen, etimen, opt)
348 recdb.rec_reclog(titlen, chtxtn, btimen, etimen, opt, exp, longexp, category)
349 auto_rec.add_key(chtxt, titlen,exp+" "+longexp)
350 auto_rec.add_key("ALL", titlen,exp+" "+longexp)
351 recdblist.printutf8(u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen)
352 except Exception, inst:
353 recdblist.printutf8("Error happened in Oikake DB")
354 recdblist.printutf8(str(type(inst)))
355 recdblist.printutf8(str(inst))
358 recdb.del_reckey(typetxtnow, title, chtxt, btime)
359 recdb.rec_reckey(typetxtfinal, title, chtxt, btime, etime, opt)
360 except Exception, inst:
361 recdblist.printutf8(str(type(inst)))
362 recdblist.printutf8(str(inst))
363 def type_final(typetxt,chtxt,title,bt,et,opt):
364 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
365 etime = et.strftime("%Y-%m-%d %H:%M:%S")
369 if typetxt==recdblist.REC_FINAL_RESERVE:
370 typetxting=recdblist.REC_TS_RECORDING
371 typetxtdecque=recdblist.REC_TS_DECODE_QUE
372 tnow = datetime.datetime.now()
374 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
375 if dt < 6 * 60 and dt > 0:
377 recdb.del_reckey(typetxtnow, title, chtxt, btime)
378 testpath=[os.path.join(recpath,title+".ts.b25")]
379 testpath.append(os.path.join(recpath,title+".ts"))
380 testpath.append(os.path.join(recpath,title+".avi"))
381 testpath.append(os.path.join(recpath,title+".mp4"))
382 testpath.append(os.path.join(recpath,title+".log"))
385 if os.path.exists(ti):
387 if re.search("N", opt) or tcheck>0:
390 iff=u"("+configreader.getenv("iff")+u")_"
394 newtitle=newtitle+u"_"+iff+newtime.strftime("%Y-%m-%dT%H-%M-%S")
395 recdb.rec_reckey(typetxting, newtitle, chtxt, btime, etime, opt)
396 recdblist.printutf8(u"録画開始 "+newtitle+" "+btime+" "+etime)
397 tv2avi.timetv2b25(recpath + "/" + newtitle + ".avi", chtxt, btime, etime, opt)
398 recdb.del_reckey(typetxting, newtitle, chtxt, btime)
399 if not re.search("R", opt):
400 tnow = datetime.datetime.now()
401 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
402 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
404 bt = tnow + datetime.timedelta(seconds=600)
405 et = et + dt + datetime.timedelta(seconds=600)
406 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
407 etime = et.strftime("%Y-%m-%d %H:%M:%S")
408 recdb.rec_reckey(typetxtdecque, newtitle, chtxt, btime, etime, opt)
411 shutil.copy(os.path.join(recpath,title+".ts.b25"), os.path.join(movepath,title+".ts.b25"))
414 recdb.rec_reckey(recdblist.REC_MOVE_END, newtitle, chtxt, btime, etime, opt)
416 def type_keyword(typetxt,chtxt,title,bt,et,opt,deltatime):
417 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
418 etime = et.strftime("%Y-%m-%d %H:%M:%S")
421 if typetxt==recdblist.REC_KEYWORD:
422 typetxtres=recdblist.REC_RESERVE
423 tnow = datetime.datetime.now()
425 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
428 recdata = epgdb.searchtime2(title, btime, deltatime, chtxt)
437 bt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
438 et = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
439 btimet = bt.strftime("%Y-%m-%d %H:%M:%S")
440 etimet = et.strftime("%Y-%m-%d %H:%M:%S")
442 recdb.del_reckey(typetxtnow, title, chtxt, btime)
443 recdb.rec_reckey(typetxtres, titlet, chtxtt, btimet, etimet, opt)
444 recdb.rec_reclog(titlet, chtxtt, btimet, etimet, opt, exp,longexp,category)
445 auto_rec.add_key(chtxt, titlet,exp+" "+longexp)
446 auto_rec.add_key("ALL", titlet,exp+" "+longexp)
447 recdblist.printutf8(u"key "+title+u" : "+titlet+u" "+btimet+u" "+etimet)
448 #except Exception, inst:
449 # recdblist.printutf8("Error happened in REC_KEYWORD DB")
450 # recdblist.printutf8(type(inst))
451 # recdblist.printutf8(inst)
453 recdblist.printutf8("nothing match")
454 def type_keyword_every_day(type,chtxt,title,bt,et,opt,deltatime,deltaday,counter):
455 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
456 etime = et.strftime("%Y-%m-%d %H:%M:%S")
457 tnow = datetime.datetime.now()
459 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
460 dd = datetime.timedelta(days=int(deltaday))
462 recdb.del_reckey(recdblist.REC_KEYWORD_EVERY_SOME_DAYS, title, chtxt, btime)
465 btxt = bt.strftime("%Y-%m-%d %H:%M:%S")
466 etxt = et.strftime("%Y-%m-%d %H:%M:%S")
467 recdb.everyreserv(title, chtxt, btxt, etxt, deltatime, opt, deltaday)
469 recdb.del_reckey(recdblist.REC_KEYWORD_EVERY_SOME_DAYS, title, chtxt, btime)
472 btxt = bt.strftime("%Y-%m-%d %H:%M:%S")
473 etxt = et.strftime("%Y-%m-%d %H:%M:%S")
475 recdb.everyreserv(title, chtxt, btxt, etxt, deltatime, opt, deltaday,counter-1)
477 recdb.everyreserv(title, chtxt, btxt, etxt, deltatime, opt, deltaday,-1)
478 recdata = epgdb.searchtime2(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.keyreserv(titlet, chtxtt, btimet, etimet, deltatime, opt)
494 recdb.keyreserv(title, chtxt, btime, etime, deltatime, opt)
495 def type_decode_que(typetxt,chtxt,title,bt,et,opt):
496 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
497 etime = et.strftime("%Y-%m-%d %H:%M:%S")
498 tnow = datetime.datetime.now()
500 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
505 if typetxt== recdblist.REC_TS_DECODE_QUE:
506 typetxting=recdblist.REC_TS_DECODING
507 typetxtmiss=recdblist.REC_MISS_DECODE
508 typetxtencque=recdblist.REC_ENCODE_QUE
509 tnow = datetime.datetime.now()
511 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
513 if status.getB25Decoding() < 2:
514 pin = recpath + "/" + title
515 recdb.del_reckey(typetxtnow, title, chtxt, btime)
516 recdb.rec_reckey(typetxting, title, chtxt, btime, etime, opt)
517 tv2avi.b252ts(pin, chtxt, btime, etime, opt)
518 recdb.del_reckey(typetxting, title, chtxt, btime)
519 if not os.access(recpath + "/" + title + ".ts", os.F_OK):
520 recdb.del_reckey(typetxting, title, chtxt, btime)
521 recdb.rec_reckey(typetxtmiss, title, chtxt, btime, etime, opt)
525 cstch=int(chdb.chtxtsearch(chtxt)['csch'])
529 ch=checker.checkB25Decode(recpath + "/" + title + ".ts.b25", recpath + "/" + title + ".ts",cstch)
532 os.remove(recpath + "/" + title + ".ts.b25")
533 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
534 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
536 if not re.search("D", opt):
537 tnow = datetime.datetime.now()
538 bt = tnow + datetime.timedelta(seconds=600)
540 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
541 etime = et.strftime("%Y-%m-%d %H:%M:%S")
542 recdb.rec_reckey(typetxtencque, title, chtxt, btime, etime, opt)
545 shutil.copy(os.path.join(recpath,title+".ts"), os.path.join(movepath,title+".ts"))
546 except Exception, inst:
547 errtxt="Error happened in type_decode_que in timerec.\n"
548 errtxt=errtxt+"move ts error.\n"
549 errtxt=errtxt+str(type(inst))+"\n"
550 errtxt=errtxt+str(inst)
551 recdblist.addlog(os.path.join(recpath,title+".ts"), errtxt, "timerec-move(Decode) error")
552 recdb.rec_reckey(recdblist.REC_MOVE_END, title, chtxt, btime, etime, opt)
554 recdb.del_reckey(typetxtnow, title, chtxt, btime)
555 bt = bt + datetime.timedelta(seconds=600)
556 et = et + datetime.timedelta(seconds=600)
557 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
558 etime = et.strftime("%Y-%m-%d %H:%M:%S")
559 recdb.rec_reckey(typetxtnow, title, chtxt, btime, etime, opt)
562 def type_encode_que(typetxt,chtxt,title,bt,et,opt):
563 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
564 etime = et.strftime("%Y-%m-%d %H:%M:%S")
565 tnow = datetime.datetime.now()
567 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
571 if typetxt==recdblist.REC_ENCODE_QUE:
572 typetxting=recdblist.REC_ENCODE_LOCAL
573 typetxtfin=recdblist.REC_FIN_LOCAL
575 if status.getEncoding() < int(configreader.getenv("enc_max")):
576 recdb.del_reckey(typetxtnow, title, chtxt, btime)
577 recdb.rec_reckey(typetxting, title, chtxt, btime, etime, opt)
578 recdblist.printutf8(opt)
579 pin = recpath + "/" + title + ".ts"
580 if re.search("d", opt):
581 pin = recpath + "/" + title + ".m2v"
582 if not os.path.exists(pin) or os.path.getsize(pin)<100*1000:
583 paac2 = recpath + "/" + title + "_2.aac"
584 pmp32 = recpath + "/" + title + "_2.mp3"
585 if not os.path.exists(paac2) and not os.path.exists(pmp32):
586 tv2avi.dualaudio2sep(os.path.join(recpath, title+".ts"),"167")
588 elif re.search("5", opt):
589 pin = recpath + "/" + title + ".m2v"
590 if not os.path.exists(pin) or os.path.getsize(pin)<100*1000:
591 paac2 = recpath + "/" + title + "_2.aac"
592 pmp32 = recpath + "/" + title + "_2.mp3"
593 if not os.path.exists(paac2) and not os.path.exists(pmp32):
594 tv2avi.pentaaudio2sep(os.path.join(recpath, title+".ts"))
596 elif re.search("b", opt):
597 pin = recpath + "/" + title + ".m2v"
598 if not os.path.exists(pin) or os.path.getsize(pin)<100*1000:
599 paac2 = recpath + "/" + title + "_1.aac"
600 pmp32 = recpath + "/" + title + "_1.mp3"
601 if not os.path.exists(paac2) and not os.path.exists(pmp32):
602 tv2avi.singleaudio2sep(os.path.join(recpath, title+".ts"))
606 if configreader.getenv("make_mp4")=="1":
610 if re.search("m", opt):
612 if re.search("4", opt):
614 recdblist.printutf8(pin)
615 if not re.search("0", opt):
617 pout = recpath + "/" + title + ".mp4"
618 tv2mp4.ts2mp4(pin, pout, opt)
620 pout = recpath + "/" + title + ".mkv"
621 tv2mkv.ts2mkv(pin, pout, opt)
622 if re.search("8", opt) or re.search("9", opt):
624 optt=optt.replace("8","MW8")
625 optt=optt.replace("9","MW9")
626 poutt = recpath + "/" + "m_"+title + ".mp4"
627 if re.search("d", opt) or re.search("5", opt):
628 if os.path.exists(os.path.join(recpath, "m_"+title+".m2v")):
629 shutil.move(os.path.join(recpath, title+".m2v"),os.path.join(recpath, "m_"+title+".m2v"))
630 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.aac")):
631 shutil.move(os.path.join(recpath, title+"_1.aac"),os.path.join(recpath, "m_"+title+"_1.aac"))
632 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.mp3")):
633 shutil.move(os.path.join(recpath, title+"_1.mp3"),os.path.join(recpath, "m_"+title+"_1.mp3"))
634 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.aac")):
635 shutil.move(os.path.join(recpath, title+"_2.aac"),os.path.join(recpath, "m_"+title+"_2.aac"))
636 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.mp3")):
637 shutil.move(os.path.join(recpath, title+"_2.mp3"),os.path.join(recpath, "m_"+title+"_2.mp3"))
638 shutil.move(os.path.join(recpath, title+".ts"),os.path.join(recpath, "m_"+title+".ts"))
639 tv2mp4.ts2mp4(os.path.join(recpath, "m_"+title+".ts"), poutt, optt)
640 shutil.move(os.path.join(recpath, "m_"+title+".ts"),os.path.join(recpath, title+".ts"))
643 optt=optt.replace("8","MW8")
644 optt=optt.replace("9","MW9")
645 poutt = recpath + "/" + "m_"+title + ".mp4"
646 shutil.move(os.path.join(recpath, title+".ts"),os.path.join(recpath, "m_"+title+".ts"))
647 if re.search("d", opt) or re.search("5", opt):
648 if os.path.exists(os.path.join(recpath, "m_"+title+".m2v")):
649 shutil.move(os.path.join(recpath, title+".m2v"),os.path.join(recpath, "m_"+title+".m2v"))
650 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.aac")):
651 shutil.move(os.path.join(recpath, title+"_1.aac"),os.path.join(recpath, "m_"+title+"_1.aac"))
652 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.mp3")):
653 shutil.move(os.path.join(recpath, title+"_1.mp3"),os.path.join(recpath, "m_"+title+"_1.mp3"))
654 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.aac")):
655 shutil.move(os.path.join(recpath, title+"_2.aac"),os.path.join(recpath, "m_"+title+"_2.aac"))
656 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.mp3")):
657 shutil.move(os.path.join(recpath, title+"_2.mp3"),os.path.join(recpath, "m_"+title+"_2.mp3"))
658 tv2mp4.ts2mp4(os.path.join(recpath, "m_"+title+".ts"), poutt, optt)
659 shutil.move(os.path.join(recpath, "m_"+title+".ts"),os.path.join(recpath, title+".ts"))
660 recdb.del_reckey(typetxting, title, chtxt, btime)
662 if re.search("E", opt):
664 if os.path.exists(os.path.join(recpath,title+".mp4")):
665 shutil.copy(os.path.join(recpath,title+".mp4"), os.path.join(movepath,title+".mp4"))
666 elif os.path.exists(os.path.join(recpath,title+".mkv")):
667 shutil.copy(os.path.join(recpath,title+".mkv"), os.path.join(movepath,title+".mkv"))
668 except Exception, inst:
669 errtxt="Error happened in type_encode_que in timerec.\n"
670 errtxt=errtxt+"move mkv/mp4 error.\n"
671 errtxt=errtxt+str(type(inst))+"\n"
672 errtxt=errtxt+str(inst)
673 recdblist.addlog(os.path.join(recpath,title+".ts"), errtxt, "timerec-move(Encode) error")
674 recdb.rec_reckey(recdblist.REC_MOVE_END, title, chtxt, btime, etime, opt)
675 recdb.rec_reckey(typetxtfin, title, chtxt, btime, etime, opt)
678 recdb.del_reckey(typetxtnow, title, chtxt, btime)
679 bt = bt + datetime.timedelta(seconds=600)
680 et = et + datetime.timedelta(seconds=600)
681 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
682 etime = et.strftime("%Y-%m-%d %H:%M:%S")
683 recdb.rec_reckey(typetxtnow, title, chtxt, btime, etime, opt)