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()
69 recdblist.printutf8(u"1/3"+datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
78 if bctype.find('te') > -1:
79 recnum = status.getTERecording() + recdb.countRecNow_minutes_TE("10")
80 recdblist.printutf8(u"放送種別:"+bctype + u"||該当チューナー実行中件数:" + str(status.getTERecording()) + u":直近予約件数:" + str(recdb.countRecNow_minutes_TE("10")))
81 recnum = int(configreader.getenv("te_max")) -recnum
83 recnum = status.getBSCSRecording() + recdb.countRecNow_minutes_BSCS("10")
84 recdblist.printutf8(u"放送種別:"+bctype + u"||該当チューナー実行中件数:" + str(status.getBSCSRecording()) + u":直近予約件数:" + str(recdb.countRecNow_minutes_BSCS("10")))
85 recnum = int(configreader.getenv("bscs_max")) -recnum
87 recdblist.printutf8(str(update))
88 rec10d.rec10db.update_status_by_bctype_epg_ch(bctype, "0")
89 epgdb.updatebc(bctype)
90 update = chdb.update()
95 auto_process.update_all_timeline_epg()
102 auto_process.update_all_timeline_epg()
104 recdblist.printutf8(u"2/3"+datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
106 typetxt = task["type"]
108 chtxt = task['chtxt']
112 title = task['title']
116 btime = task['btime']
117 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
120 bt = datetime.datetime.strptime("2009-01-01 00:00:00", "%Y-%m-%d %H:%M:%S")
122 etime = task['etime']
123 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
126 et = datetime.datetime.strptime("2009-01-01 00:00:00", "%Y-%m-%d %H:%M:%S")
131 tnow = datetime.datetime.now()
133 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
134 if task["type"] == recdblist.REC_RESERVE:#"res,"+chtxt+","+title+","+btime+","+etime+","+opt
136 if pid != 0:#親プロセスの場合
138 else:#子プロセスの場合 アップデートを行って終了
139 type_reserve(task["type"],chtxt,title,bt,et,opt)
141 elif task["type"] == recdblist.REC_KEYWORD:#"key,"+chtxt+","+keyword+","+btime+","+deltatime+","+opt
142 deltatime = task['deltatime']
144 if pid != 0:#親プロセスの場合
146 else:#子プロセスの場合 アップデートを行って終了
147 type_keyword(task["type"],chtxt,title, bt, et, opt, deltatime)
149 elif task["type"] == recdblist.REC_KEYWORD_EVERY_SOME_DAYS:#"keyevery,"+chtxt+","+keyword+","+btime+","+deltatime+","+opt+","+deltaday
150 deltatime = task['deltatime']
151 deltaday = task['deltaday']
153 keyeverycounter=task['counter']
157 if pid != 0:#親プロセスの場合
159 else:#子プロセスの場合 アップデートを行って終了
160 type_keyword_every_day(task["type"],chtxt, title, bt, et, opt, deltatime, deltaday,keyeverycounter)
162 elif task["type"] == recdblist.REC_FINAL_RESERVE:#"rec,"+chtxt+","+title+","+btime+","+etime+","+opt
164 if pid != 0:#親プロセスの場合
166 else:#子プロセスの場合 アップデートを行って終了
167 type_final(task["type"],chtxt, title, bt, et, opt)
169 elif task["type"] == recdblist.REC_TS_DECODE_QUE:
172 if pid != 0:#親プロセスの場合
174 else:#子プロセスの場合 アップデートを行って終了
176 type_decode_que(task["type"],chtxt, title, bt, et, opt)
178 elif task["type"] == recdblist.REC_ENCODE_QUE:
179 encodenum=encodenum+1
181 if pid != 0:#親プロセスの場合
183 else:#子プロセスの場合 アップデートを行って終了
184 time.sleep(5*encodenum)
185 type_encode_que(task["type"],chtxt, title, bt, et, opt)
187 elif task["type"] == recdblist.REC_AVI_TO_MKV:
195 if configreader.getenv("make_mp4")==1:
199 if re.search("m", opt):
201 if re.search("4", opt):
203 recdb.del_reckey(recdblist.REC_AVI_TO_MKV, title, chtxt, btime)
204 recdb.rec_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
206 tv2mp4.raw2mp4(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mp4"),opt)
208 tv2mkv.raw2mkv(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mkv"),opt)
209 recdb.del_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime)
211 elif task["type"] == recdblist.REC_AVI_TO_MP4:
219 if configreader.getenv("make_mp4")==1:
223 if re.search("m", opt):
225 if re.search("4", opt):
227 recdb.del_reckey(recdblist.REC_AVI_TO_MP4, title, chtxt, btime)
228 recdb.rec_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
230 tv2mp4.ts2mp4(pin, pout, opt)
231 tv2mp4.raw2mp4(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mp4"),opt)
233 tv2mkv.raw2mkv(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mkv"),opt)
234 recdb.del_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime)
236 elif task["type"] == recdblist.REC_MKV_TO_MP4:
242 recdb.del_reckey(recdblist.REC_MKV_TO_MP4, title, chtxt, btime)
243 recdb.rec_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
244 tv2mp4.mkv2mp4(os.path.join(recpath,title+".mkv"),os.path.join(recpath,title+".mp4"))
245 recdb.del_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime)
247 recdblist.printutf8(u"3/3"+datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
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.printutf8("error occures in search_keyword_auto_jbk")
279 recdblist.printutf8(str(type(inst)))
280 recdblist.printutf8(str(inst))
283 recdb.add_auto_keyword(chtxtt, titlet, btimet, etimet)
284 except Exception, inst:
285 recdblist.printutf8("error occures in search_keyword")
286 recdblist.printutf8(str(type(inst)))
287 recdblist.printutf8(str(inst))
288 def type_reserve(typetxt,chtxt,title,bt,et,opt):
289 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
290 etime = et.strftime("%Y-%m-%d %H:%M:%S")
293 if typetxt==recdblist.REC_RESERVE:
294 typetxtfinal=recdblist.REC_FINAL_RESERVE
295 tnow = datetime.datetime.now()
297 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
298 if (dt < 58 * 60 and dt > 30 * 60):
299 bctypet = chdb.chtxtsearch(chtxt)['bctype']
300 chdatat = rec10d.rec10db.select_by_bctype_epg_ch(bctypet)
301 dt1 = datetime.datetime.strptime(chdatat[0][5], "%Y-%m-%d %H:%M:%S")-datetime.datetime.now()
302 dt1 = dt1.days * 24 * 60 * 60 + dt1.seconds
304 recdata = epgdb.searchtime2(title, btime, "5", chtxt)
312 bt = datetime.datetime.strptime(btimen, "%Y-%m-%d %H:%M:%S")
313 et = datetime.datetime.strptime(etimen, "%Y-%m-%d %H:%M:%S")
314 btimen = bt.strftime("%Y-%m-%d %H:%M:%S")
315 etimen = et.strftime("%Y-%m-%d %H:%M:%S")
318 recdb.del_reckey(typetxtnow, title, chtxt, btime)
319 recdb.rec_reckey(typetxtfinal, titlen, chtxtn, btimen, etimen, opt)
320 recdb.rec_reclog(titlen, chtxtn, btimen, etimen, opt, exp, longexp, category)
321 auto_rec.add_key(chtxt, titlen,exp+" "+longexp)
322 auto_rec.add_key("ALL", titlen,exp+" "+longexp)
323 recdblist.printutf8(u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen)
324 except Exception, inst:
325 recdblist.printutf8("Error happened in Oikake DB")
326 recdblist.printutf8(str(type(inst)))
327 recdblist.printutf8(str(inst))
329 recdblist.printutf8(u"追いかけ機能エラー:番組データが見付かりません。")
331 if rec10d.rec10db.select_by_bctype_epg_ch(bctypet)[0][6] != "0":
332 rec10d.rec10db.update_status_by_bctype_epg_ch(bctypet, "3")
334 elif (dt <= 30 * 60 and dt > 20 * 60):
335 recdata = epgdb.searchtime2(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.del_reckey(typetxtnow, title, chtxt, btime)
350 recdb.rec_reckey(typetxtfinal, titlen, chtxtn, btimen, etimen, opt)
351 recdb.rec_reclog(titlen, chtxtn, btimen, etimen, opt, exp, longexp, category)
352 auto_rec.add_key(chtxt, titlen,exp+" "+longexp)
353 auto_rec.add_key("ALL", titlen,exp+" "+longexp)
354 recdblist.printutf8(u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen)
355 except Exception, inst:
356 recdblist.printutf8("Error happened in Oikake DB")
357 recdblist.printutf8(str(type(inst)))
358 recdblist.printutf8(str(inst))
361 recdb.del_reckey(typetxtnow, title, chtxt, btime)
362 recdb.rec_reckey(typetxtfinal, title, chtxt, btime, etime, opt)
363 except Exception, inst:
364 recdblist.printutf8(str(type(inst)))
365 recdblist.printutf8(str(inst))
366 def type_final(typetxt,chtxt,title,bt,et,opt):
367 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
368 etime = et.strftime("%Y-%m-%d %H:%M:%S")
372 if typetxt==recdblist.REC_FINAL_RESERVE:
373 typetxting=recdblist.REC_TS_RECORDING
374 typetxtdecque=recdblist.REC_TS_DECODE_QUE
375 tnow = datetime.datetime.now()
377 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
378 if dt < 6 * 60 and dt > 0:
380 recdb.del_reckey(typetxtnow, title, chtxt, btime)
381 testpath=[os.path.join(recpath,title+".ts.b25")]
382 testpath.append(os.path.join(recpath,title+".ts"))
383 testpath.append(os.path.join(recpath,title+".avi"))
384 testpath.append(os.path.join(recpath,title+".mp4"))
385 testpath.append(os.path.join(recpath,title+".log"))
388 if os.path.exists(ti):
390 if re.search("N", opt) or tcheck>0:
393 iff=u"("+configreader.getenv("iff")+u")_"
397 newtitle=newtitle+u"_"+iff+newtime.strftime("%Y-%m-%dT%H-%M-%S")
398 recdb.rec_reckey(typetxting, newtitle, chtxt, btime, etime, opt)
399 recdblist.printutf8(u"録画開始 "+newtitle+" "+btime+" "+etime)
400 tv2avi.timetv2b25(recpath + "/" + newtitle + ".avi", chtxt, btime, etime, opt)
401 recdb.del_reckey(typetxting, newtitle, chtxt, btime)
402 if not re.search("R", opt):
403 tnow = datetime.datetime.now()
404 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
405 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
407 bt = tnow + datetime.timedelta(seconds=600)
408 et = et + dt + datetime.timedelta(seconds=600)
409 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
410 etime = et.strftime("%Y-%m-%d %H:%M:%S")
411 recdb.rec_reckey(typetxtdecque, newtitle, chtxt, btime, etime, opt)
414 shutil.copy(os.path.join(recpath,title+".ts.b25"), os.path.join(movepath,title+".ts.b25"))
417 recdb.rec_reckey(recdblist.REC_MOVE_END, newtitle, chtxt, btime, etime, opt)
419 def type_keyword(typetxt,chtxt,title,bt,et,opt,deltatime):
420 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
421 etime = et.strftime("%Y-%m-%d %H:%M:%S")
424 if typetxt==recdblist.REC_KEYWORD:
425 typetxtres=recdblist.REC_RESERVE
426 tnow = datetime.datetime.now()
428 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
431 recdata = epgdb.searchtime2(title, btime, deltatime, chtxt)
440 bt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
441 et = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
442 btimet = bt.strftime("%Y-%m-%d %H:%M:%S")
443 etimet = et.strftime("%Y-%m-%d %H:%M:%S")
445 recdb.del_reckey(typetxtnow, title, chtxt, btime)
446 recdb.rec_reckey(typetxtres, titlet, chtxtt, btimet, etimet, opt)
447 recdb.rec_reclog(titlet, chtxtt, btimet, etimet, opt, exp,longexp,category)
448 auto_rec.add_key(chtxt, titlet,exp+" "+longexp)
449 auto_rec.add_key("ALL", titlet,exp+" "+longexp)
450 recdblist.printutf8(u"key "+title+u" : "+titlet+u" "+btimet+u" "+etimet)
451 #except Exception, inst:
452 # recdblist.printutf8("Error happened in REC_KEYWORD DB")
453 # recdblist.printutf8(type(inst))
454 # recdblist.printutf8(inst)
456 recdblist.printutf8("nothing match")
457 def type_keyword_every_day(type,chtxt,title,bt,et,opt,deltatime,deltaday,counter):
458 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
459 etime = et.strftime("%Y-%m-%d %H:%M:%S")
460 tnow = datetime.datetime.now()
462 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
463 dd = datetime.timedelta(days=int(deltaday))
465 recdb.del_reckey(recdblist.REC_KEYWORD_EVERY_SOME_DAYS, title, chtxt, btime)
468 btxt = bt.strftime("%Y-%m-%d %H:%M:%S")
469 etxt = et.strftime("%Y-%m-%d %H:%M:%S")
470 recdb.everyreserv(title, chtxt, btxt, etxt, deltatime, opt, deltaday)
472 recdb.del_reckey(recdblist.REC_KEYWORD_EVERY_SOME_DAYS, title, chtxt, btime)
475 btxt = bt.strftime("%Y-%m-%d %H:%M:%S")
476 etxt = et.strftime("%Y-%m-%d %H:%M:%S")
478 recdb.everyreserv(title, chtxt, btxt, etxt, deltatime, opt, deltaday,counter-1)
480 recdb.everyreserv(title, chtxt, btxt, etxt, deltatime, opt, deltaday,-1)
481 recdata = epgdb.searchtime2(title, btime, deltatime, chtxt)
490 bt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
491 et = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
492 btimet = bt.strftime("%Y-%m-%d %H:%M:%S")
493 etimet = et.strftime("%Y-%m-%d %H:%M:%S")
495 recdb.keyreserv(titlet, chtxtt, btimet, etimet, deltatime, opt)
497 recdb.keyreserv(title, chtxt, btime, etime, deltatime, opt)
498 def type_decode_que(typetxt,chtxt,title,bt,et,opt):
499 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
500 etime = et.strftime("%Y-%m-%d %H:%M:%S")
501 tnow = datetime.datetime.now()
503 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
508 if typetxt== recdblist.REC_TS_DECODE_QUE:
509 typetxting=recdblist.REC_TS_DECODING
510 typetxtmiss=recdblist.REC_MISS_DECODE
511 typetxtencque=recdblist.REC_ENCODE_QUE
512 tnow = datetime.datetime.now()
514 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
516 if status.getB25Decoding() < 2:
517 pin = recpath + "/" + title
518 recdb.del_reckey(typetxtnow, title, chtxt, btime)
519 recdb.rec_reckey(typetxting, title, chtxt, btime, etime, opt)
520 tv2avi.b252ts(pin, chtxt, btime, etime, opt)
521 recdb.del_reckey(typetxting, title, chtxt, btime)
522 if not os.access(recpath + "/" + title + ".ts", os.F_OK):
523 recdb.del_reckey(typetxting, title, chtxt, btime)
524 recdb.rec_reckey(typetxtmiss, title, chtxt, btime, etime, opt)
528 cstch=int(chdb.chtxtsearch(chtxt)['csch'])
532 ch=checker.checkB25Decode(recpath + "/" + title + ".ts.b25", recpath + "/" + title + ".ts",cstch)
535 os.remove(recpath + "/" + title + ".ts.b25")
536 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
537 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
539 if not re.search("D", opt):
540 tnow = datetime.datetime.now()
541 bt = tnow + datetime.timedelta(seconds=600)
543 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
544 etime = et.strftime("%Y-%m-%d %H:%M:%S")
545 recdb.rec_reckey(typetxtencque, title, chtxt, btime, etime, opt)
548 shutil.copy(os.path.join(recpath,title+".ts"), os.path.join(movepath,title+".ts"))
549 except Exception, inst:
550 errtxt="Error happened in type_decode_que in timerec.\n"
551 errtxt=errtxt+"move ts error.\n"
552 errtxt=errtxt+str(type(inst))+"\n"
553 errtxt=errtxt+str(inst)
554 recdblist.addlog(os.path.join(recpath,title+".ts"), errtxt, "timerec-move(Decode) error")
555 recdb.rec_reckey(recdblist.REC_MOVE_END, title, chtxt, btime, etime, opt)
557 recdb.del_reckey(typetxtnow, title, chtxt, btime)
558 bt = bt + datetime.timedelta(seconds=600)
559 et = et + datetime.timedelta(seconds=600)
560 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
561 etime = et.strftime("%Y-%m-%d %H:%M:%S")
562 recdb.rec_reckey(typetxtnow, title, chtxt, btime, etime, opt)
565 def type_encode_que(typetxt,chtxt,title,bt,et,opt):
566 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
567 etime = et.strftime("%Y-%m-%d %H:%M:%S")
568 tnow = datetime.datetime.now()
570 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
574 if typetxt==recdblist.REC_ENCODE_QUE:
575 typetxting=recdblist.REC_ENCODE_LOCAL
576 typetxtfin=recdblist.REC_FIN_LOCAL
578 if status.getEncoding() < int(configreader.getenv("enc_max")):
579 recdb.del_reckey(typetxtnow, title, chtxt, btime)
580 recdb.rec_reckey(typetxting, title, chtxt, btime, etime, opt)
581 recdblist.printutf8(opt)
582 pin = recpath + "/" + title + ".ts"
583 if re.search("d", opt):
584 pin = recpath + "/" + title + ".m2v"
585 if not os.path.exists(pin) or os.path.getsize(pin)<100*1000:
586 paac2 = recpath + "/" + title + "_2.aac"
587 pmp32 = recpath + "/" + title + "_2.mp3"
588 if not os.path.exists(paac2) and not os.path.exists(pmp32):
589 tv2avi.dualaudio2sep(os.path.join(recpath, title+".ts"),"167")
591 elif re.search("5", opt):
592 pin = recpath + "/" + title + ".m2v"
593 if not os.path.exists(pin) or os.path.getsize(pin)<100*1000:
594 paac2 = recpath + "/" + title + "_2.aac"
595 pmp32 = recpath + "/" + title + "_2.mp3"
596 if not os.path.exists(paac2) and not os.path.exists(pmp32):
597 tv2avi.pentaaudio2sep(os.path.join(recpath, title+".ts"))
601 if configreader.getenv("make_mp4")=="1":
605 if re.search("m", opt):
607 if re.search("4", opt):
609 recdblist.printutf8(pin)
610 if not re.search("0", opt):
612 pout = recpath + "/" + title + ".mp4"
613 tv2mp4.ts2mp4(pin, pout, opt)
615 pout = recpath + "/" + title + ".mkv"
616 tv2mkv.ts2mkv(pin, pout, opt)
617 if re.search("8", opt) or re.search("9", opt):
619 optt=optt.replace("8","MW8")
620 optt=optt.replace("9","MW9")
621 poutt = recpath + "/" + "m_"+title + ".mp4"
622 if re.search("d", opt) or re.search("5", opt):
623 if os.path.exists(os.path.join(recpath, "m_"+title+".m2v")):
624 shutil.move(os.path.join(recpath, title+".m2v"),os.path.join(recpath, "m_"+title+".m2v"))
625 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.aac")):
626 shutil.move(os.path.join(recpath, title+"_1.aac"),os.path.join(recpath, "m_"+title+"_1.aac"))
627 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.mp3")):
628 shutil.move(os.path.join(recpath, title+"_1.mp3"),os.path.join(recpath, "m_"+title+"_1.mp3"))
629 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.aac")):
630 shutil.move(os.path.join(recpath, title+"_2.aac"),os.path.join(recpath, "m_"+title+"_2.aac"))
631 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.mp3")):
632 shutil.move(os.path.join(recpath, title+"_2.mp3"),os.path.join(recpath, "m_"+title+"_2.mp3"))
633 shutil.move(os.path.join(recpath, title+".ts"),os.path.join(recpath, "m_"+title+".ts"))
634 tv2mp4.ts2mp4(os.path.join(recpath, "m_"+title+".ts"), poutt, optt)
635 shutil.move(os.path.join(recpath, "m_"+title+".ts"),os.path.join(recpath, title+".ts"))
638 optt=optt.replace("8","MW8")
639 optt=optt.replace("9","MW9")
640 poutt = recpath + "/" + "m_"+title + ".mp4"
641 shutil.move(os.path.join(recpath, title+".ts"),os.path.join(recpath, "m_"+title+".ts"))
642 if re.search("d", opt) or re.search("5", opt):
643 if os.path.exists(os.path.join(recpath, "m_"+title+".m2v")):
644 shutil.move(os.path.join(recpath, title+".m2v"),os.path.join(recpath, "m_"+title+".m2v"))
645 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.aac")):
646 shutil.move(os.path.join(recpath, title+"_1.aac"),os.path.join(recpath, "m_"+title+"_1.aac"))
647 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.mp3")):
648 shutil.move(os.path.join(recpath, title+"_1.mp3"),os.path.join(recpath, "m_"+title+"_1.mp3"))
649 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.aac")):
650 shutil.move(os.path.join(recpath, title+"_2.aac"),os.path.join(recpath, "m_"+title+"_2.aac"))
651 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.mp3")):
652 shutil.move(os.path.join(recpath, title+"_2.mp3"),os.path.join(recpath, "m_"+title+"_2.mp3"))
653 tv2mp4.ts2mp4(os.path.join(recpath, "m_"+title+".ts"), poutt, optt)
654 shutil.move(os.path.join(recpath, "m_"+title+".ts"),os.path.join(recpath, title+".ts"))
655 recdb.del_reckey(typetxting, title, chtxt, btime)
657 if re.search("E", opt):
659 if os.path.exists(os.path.join(recpath,title+".mp4")):
660 shutil.copy(os.path.join(recpath,title+".mp4"), os.path.join(movepath,title+".mp4"))
661 elif os.path.exists(os.path.join(recpath,title+".mkv")):
662 shutil.copy(os.path.join(recpath,title+".mkv"), os.path.join(movepath,title+".mkv"))
663 except Exception, inst:
664 errtxt="Error happened in type_encode_que in timerec.\n"
665 errtxt=errtxt+"move mkv/mp4 error.\n"
666 errtxt=errtxt+str(type(inst))+"\n"
667 errtxt=errtxt+str(inst)
668 recdblist.addlog(os.path.join(recpath,title+".ts"), errtxt, "timerec-move(Encode) error")
669 recdb.rec_reckey(recdblist.REC_MOVE_END, title, chtxt, btime, etime, opt)
670 recdb.rec_reckey(typetxtfin, title, chtxt, btime, etime, opt)
673 recdb.del_reckey(typetxtnow, title, chtxt, btime)
674 bt = bt + datetime.timedelta(seconds=600)
675 et = et + datetime.timedelta(seconds=600)
676 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
677 etime = et.strftime("%Y-%m-%d %H:%M:%S")
678 recdb.rec_reckey(typetxtnow, title, chtxt, btime, etime, opt)