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()
105 typetxt = task["type"]
107 chtxt = task['chtxt']
111 title = task['title']
115 btime = task['btime']
116 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
119 bt = datetime.datetime.strptime("2009-01-01 00:00:00", "%Y-%m-%d %H:%M:%S")
121 etime = task['etime']
122 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
125 et = datetime.datetime.strptime("2009-01-01 00:00:00", "%Y-%m-%d %H:%M:%S")
130 tnow = datetime.datetime.now()
132 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
133 if task["type"] == recdblist.REC_RESERVE:#"res,"+chtxt+","+title+","+btime+","+etime+","+opt
135 if pid != 0:#親プロセスの場合
137 else:#子プロセスの場合 アップデートを行って終了
138 type_reserve(task["type"],chtxt,title,bt,et,opt)
140 elif task["type"] == recdblist.REC_KEYWORD:#"key,"+chtxt+","+keyword+","+btime+","+deltatime+","+opt
141 deltatime = task['deltatime']
143 if pid != 0:#親プロセスの場合
145 else:#子プロセスの場合 アップデートを行って終了
146 type_keyword(task["type"],chtxt,title, bt, et, opt, deltatime)
148 elif task["type"] == recdblist.REC_KEYWORD_EVERY_SOME_DAYS:#"keyevery,"+chtxt+","+keyword+","+btime+","+deltatime+","+opt+","+deltaday
149 deltatime = task['deltatime']
150 deltaday = task['deltaday']
152 keyeverycounter=task['counter']
156 if pid != 0:#親プロセスの場合
158 else:#子プロセスの場合 アップデートを行って終了
159 type_keyword_every_day(task["type"],chtxt, title, bt, et, opt, deltatime, deltaday,keyeverycounter)
161 elif task["type"] == recdblist.REC_FINAL_RESERVE:#"rec,"+chtxt+","+title+","+btime+","+etime+","+opt
163 if pid != 0:#親プロセスの場合
165 else:#子プロセスの場合 アップデートを行って終了
166 type_final(task["type"],chtxt, title, bt, et, opt)
168 elif task["type"] == recdblist.REC_TS_DECODE_QUE:
171 if pid != 0:#親プロセスの場合
173 else:#子プロセスの場合 アップデートを行って終了
175 type_decode_que(task["type"],chtxt, title, bt, et, opt)
177 elif task["type"] == recdblist.REC_ENCODE_QUE:
178 encodenum=encodenum+1
180 if pid != 0:#親プロセスの場合
182 else:#子プロセスの場合 アップデートを行って終了
183 time.sleep(5*encodenum)
184 type_encode_que(task["type"],chtxt, title, bt, et, opt)
186 elif task["type"] == recdblist.REC_AVI_TO_MKV:
194 if configreader.getenv("make_mp4")==1:
198 if re.search("m", opt):
200 if re.search("4", opt):
202 recdb.del_reckey(recdblist.REC_AVI_TO_MKV, title, chtxt, btime)
203 recdb.rec_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
205 tv2mp4.raw2mp4(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mp4"),opt)
207 tv2mkv.raw2mkv(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mkv"),opt)
208 recdb.del_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime)
210 elif task["type"] == recdblist.REC_AVI_TO_MP4:
218 if configreader.getenv("make_mp4")==1:
222 if re.search("m", opt):
224 if re.search("4", opt):
226 recdb.del_reckey(recdblist.REC_AVI_TO_MP4, title, chtxt, btime)
227 recdb.rec_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
229 tv2mp4.ts2mp4(pin, pout, opt)
230 tv2mp4.raw2mp4(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mp4"),opt)
232 tv2mkv.raw2mkv(os.path.join(recpath,title+".264"),os.path.join(recpath,title+".mkv"),opt)
233 recdb.del_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime)
235 elif task["type"] == recdblist.REC_MKV_TO_MP4:
241 recdb.del_reckey(recdblist.REC_MKV_TO_MP4, title, chtxt, btime)
242 recdb.rec_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
243 tv2mp4.mkv2mp4(os.path.join(recpath,title+".mkv"),os.path.join(recpath,title+".mp4"))
244 recdb.del_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime)
247 def search_keyword(key):
248 tnow = datetime.datetime.now()
249 nows =tnow.strftime("%Y-%m-%d %H:%M:%S")
251 recdatum = epgdb.searchtime_auto(k,nows, "144")
252 for recdata in recdatum:
258 btt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
259 ett = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
260 btimet = btt.strftime("%Y-%m-%d %H:%M:%S")
261 etimet = ett.strftime("%Y-%m-%d %H:%M:%S")
262 if status.getSettings_auto_jbk()==1:
263 topt=status.getSettings_auto_opt()
267 maxnum=epgdb.count_schedule_timeline(btimet, etimet)[1]
268 maxnum=int(configreader.getenv("bscs_max"))-maxnum
270 maxnum=epgdb.count_schedule_timeline(btimet, etimet)[0]
271 maxnum=int(configreader.getenv("te_max"))-maxnum
273 topt=status.getSettings_auto_opt()
274 recdb.recreserv(titlet,chtxtt, btimet, etimet,topt)
275 except Exception, inst:
276 recdblist.printutf8("error occures in search_keyword_auto_jbk")
277 recdblist.printutf8(str(type(inst)))
278 recdblist.printutf8(str(inst))
281 recdb.add_auto_keyword(chtxtt, titlet, btimet, etimet)
282 except Exception, inst:
283 recdblist.printutf8("error occures in search_keyword")
284 recdblist.printutf8(str(type(inst)))
285 recdblist.printutf8(str(inst))
286 def type_reserve(typetxt,chtxt,title,bt,et,opt):
287 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
288 etime = et.strftime("%Y-%m-%d %H:%M:%S")
291 if typetxt==recdblist.REC_RESERVE:
292 typetxtfinal=recdblist.REC_FINAL_RESERVE
293 tnow = datetime.datetime.now()
295 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
296 if (dt < 58 * 60 and dt > 30 * 60):
297 bctypet = chdb.chtxtsearch(chtxt)['bctype']
298 chdatat = rec10d.rec10db.select_by_bctype_epg_ch(bctypet)
299 dt1 = datetime.datetime.strptime(chdatat[0][5], "%Y-%m-%d %H:%M:%S")-datetime.datetime.now()
300 dt1 = dt1.days * 24 * 60 * 60 + dt1.seconds
302 recdata = epgdb.searchtime2(title, btime, "5", chtxt)
310 bt = datetime.datetime.strptime(btimen, "%Y-%m-%d %H:%M:%S")
311 et = datetime.datetime.strptime(etimen, "%Y-%m-%d %H:%M:%S")
312 btimen = bt.strftime("%Y-%m-%d %H:%M:%S")
313 etimen = et.strftime("%Y-%m-%d %H:%M:%S")
316 recdb.del_reckey(typetxtnow, title, chtxt, btime)
317 recdb.rec_reckey(typetxtfinal, titlen, chtxtn, btimen, etimen, opt)
318 recdb.rec_reclog(titlen, chtxtn, btimen, etimen, opt, exp, longexp, category)
319 auto_rec.add_key(chtxt, titlen,exp+" "+longexp)
320 auto_rec.add_key("ALL", titlen,exp+" "+longexp)
321 recdblist.printutf8(u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen)
322 except Exception, inst:
323 recdblist.printutf8("Error happened in Oikake DB")
324 recdblist.printutf8(str(type(inst)))
325 recdblist.printutf8(str(inst))
327 recdblist.printutf8(u"追いかけ機能エラー:番組データが見付かりません。")
329 if rec10d.rec10db.select_by_bctype_epg_ch(bctypet)[0][6] != "0":
330 rec10d.rec10db.update_status_by_bctype_epg_ch(bctypet, "3")
332 elif (dt <= 30 * 60 and dt > 20 * 60):
333 recdata = epgdb.searchtime2(title, btime, "5", chtxt)
341 bt = datetime.datetime.strptime(btimen, "%Y-%m-%d %H:%M:%S")
342 et = datetime.datetime.strptime(etimen, "%Y-%m-%d %H:%M:%S")
343 btimen = bt.strftime("%Y-%m-%d %H:%M:%S")
344 etimen = et.strftime("%Y-%m-%d %H:%M:%S")
347 recdb.del_reckey(typetxtnow, title, chtxt, btime)
348 recdb.rec_reckey(typetxtfinal, titlen, chtxtn, btimen, etimen, opt)
349 recdb.rec_reclog(titlen, chtxtn, btimen, etimen, opt, exp, longexp, category)
350 auto_rec.add_key(chtxt, titlen,exp+" "+longexp)
351 auto_rec.add_key("ALL", titlen,exp+" "+longexp)
352 recdblist.printutf8(u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen)
353 except Exception, inst:
354 recdblist.printutf8("Error happened in Oikake DB")
355 recdblist.printutf8(str(type(inst)))
356 recdblist.printutf8(str(inst))
359 recdb.del_reckey(typetxtnow, title, chtxt, btime)
360 recdb.rec_reckey(typetxtfinal, title, chtxt, btime, etime, opt)
361 except Exception, inst:
362 recdblist.printutf8(str(type(inst)))
363 recdblist.printutf8(str(inst))
364 def type_final(typetxt,chtxt,title,bt,et,opt):
365 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
366 etime = et.strftime("%Y-%m-%d %H:%M:%S")
370 if typetxt==recdblist.REC_FINAL_RESERVE:
371 typetxting=recdblist.REC_TS_RECORDING
372 typetxtdecque=recdblist.REC_TS_DECODE_QUE
373 tnow = datetime.datetime.now()
375 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
376 if dt < 6 * 60 and dt > 0:
378 recdb.del_reckey(typetxtnow, title, chtxt, btime)
379 testpath=[os.path.join(recpath,title+".ts.b25")]
380 testpath.append(os.path.join(recpath,title+".ts"))
381 testpath.append(os.path.join(recpath,title+".avi"))
382 testpath.append(os.path.join(recpath,title+".mp4"))
383 testpath.append(os.path.join(recpath,title+".log"))
386 if os.path.exists(ti):
388 if re.search("N", opt) or tcheck>0:
391 iff=u"("+configreader.getenv("iff")+u")_"
395 newtitle=newtitle+u"_"+iff+newtime.strftime("%Y-%m-%dT%H-%M-%S")
396 recdb.rec_reckey(typetxting, newtitle, chtxt, btime, etime, opt)
397 recdblist.printutf8(u"録画開始 "+newtitle+" "+btime+" "+etime)
398 tv2avi.timetv2b25(recpath + "/" + newtitle + ".avi", chtxt, btime, etime, opt)
399 recdb.del_reckey(typetxting, newtitle, chtxt, btime)
400 if not re.search("R", opt):
401 tnow = datetime.datetime.now()
402 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
403 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
405 bt = tnow + datetime.timedelta(seconds=600)
406 et = et + dt + datetime.timedelta(seconds=600)
407 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
408 etime = et.strftime("%Y-%m-%d %H:%M:%S")
409 recdb.rec_reckey(typetxtdecque, newtitle, chtxt, btime, etime, opt)
412 shutil.copy(os.path.join(recpath,title+".ts.b25"), os.path.join(movepath,title+".ts.b25"))
415 recdb.rec_reckey(recdblist.REC_MOVE_END, newtitle, chtxt, btime, etime, opt)
417 def type_keyword(typetxt,chtxt,title,bt,et,opt,deltatime):
418 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
419 etime = et.strftime("%Y-%m-%d %H:%M:%S")
422 if typetxt==recdblist.REC_KEYWORD:
423 typetxtres=recdblist.REC_RESERVE
424 tnow = datetime.datetime.now()
426 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
429 recdata = epgdb.searchtime2(title, btime, deltatime, chtxt)
438 bt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
439 et = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
440 btimet = bt.strftime("%Y-%m-%d %H:%M:%S")
441 etimet = et.strftime("%Y-%m-%d %H:%M:%S")
443 recdb.del_reckey(typetxtnow, title, chtxt, btime)
444 recdb.rec_reckey(typetxtres, titlet, chtxtt, btimet, etimet, opt)
445 recdb.rec_reclog(titlet, chtxtt, btimet, etimet, opt, exp,longexp,category)
446 auto_rec.add_key(chtxt, titlet,exp+" "+longexp)
447 auto_rec.add_key("ALL", titlet,exp+" "+longexp)
448 recdblist.printutf8(u"key "+title+u" : "+titlet+u" "+btimet+u" "+etimet)
449 #except Exception, inst:
450 # recdblist.printutf8("Error happened in REC_KEYWORD DB")
451 # recdblist.printutf8(type(inst))
452 # recdblist.printutf8(inst)
454 recdblist.printutf8("nothing match")
455 def type_keyword_every_day(type,chtxt,title,bt,et,opt,deltatime,deltaday,counter):
456 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
457 etime = et.strftime("%Y-%m-%d %H:%M:%S")
458 tnow = datetime.datetime.now()
460 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
461 dd = datetime.timedelta(days=int(deltaday))
463 recdb.del_reckey(recdblist.REC_KEYWORD_EVERY_SOME_DAYS, title, chtxt, btime)
466 btxt = bt.strftime("%Y-%m-%d %H:%M:%S")
467 etxt = et.strftime("%Y-%m-%d %H:%M:%S")
468 recdb.everyreserv(title, chtxt, btxt, etxt, deltatime, opt, deltaday)
470 recdb.del_reckey(recdblist.REC_KEYWORD_EVERY_SOME_DAYS, title, chtxt, btime)
473 btxt = bt.strftime("%Y-%m-%d %H:%M:%S")
474 etxt = et.strftime("%Y-%m-%d %H:%M:%S")
476 recdb.everyreserv(title, chtxt, btxt, etxt, deltatime, opt, deltaday,counter-1)
478 recdb.everyreserv(title, chtxt, btxt, etxt, deltatime, opt, deltaday,-1)
479 recdata = epgdb.searchtime2(title, btime, deltatime, chtxt)
488 bt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
489 et = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
490 btimet = bt.strftime("%Y-%m-%d %H:%M:%S")
491 etimet = et.strftime("%Y-%m-%d %H:%M:%S")
493 recdb.keyreserv(titlet, chtxtt, btimet, etimet, deltatime, opt)
495 recdb.keyreserv(title, chtxt, btime, etime, deltatime, opt)
496 def type_decode_que(typetxt,chtxt,title,bt,et,opt):
497 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
498 etime = et.strftime("%Y-%m-%d %H:%M:%S")
499 tnow = datetime.datetime.now()
501 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
506 if typetxt== recdblist.REC_TS_DECODE_QUE:
507 typetxting=recdblist.REC_TS_DECODING
508 typetxtmiss=recdblist.REC_MISS_DECODE
509 typetxtencque=recdblist.REC_ENCODE_QUE
510 tnow = datetime.datetime.now()
512 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
514 if status.getB25Decoding() < 2:
515 pin = recpath + "/" + title
516 recdb.del_reckey(typetxtnow, title, chtxt, btime)
517 recdb.rec_reckey(typetxting, title, chtxt, btime, etime, opt)
518 tv2avi.b252ts(pin, chtxt, btime, etime, opt)
519 recdb.del_reckey(typetxting, title, chtxt, btime)
520 if not os.access(recpath + "/" + title + ".ts", os.F_OK):
521 recdb.del_reckey(typetxting, title, chtxt, btime)
522 recdb.rec_reckey(typetxtmiss, title, chtxt, btime, etime, opt)
526 cstch=int(chdb.chtxtsearch(chtxt)['csch'])
530 ch=checker.checkB25Decode(recpath + "/" + title + ".ts.b25", recpath + "/" + title + ".ts",cstch)
533 os.remove(recpath + "/" + title + ".ts.b25")
534 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
535 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
537 if not re.search("D", opt):
538 tnow = datetime.datetime.now()
539 bt = tnow + datetime.timedelta(seconds=600)
541 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
542 etime = et.strftime("%Y-%m-%d %H:%M:%S")
543 recdb.rec_reckey(typetxtencque, title, chtxt, btime, etime, opt)
546 shutil.copy(os.path.join(recpath,title+".ts"), os.path.join(movepath,title+".ts"))
547 except Exception, inst:
548 errtxt="Error happened in type_decode_que in timerec.\n"
549 errtxt=errtxt+"move ts error.\n"
550 errtxt=errtxt+str(type(inst))+"\n"
551 errtxt=errtxt+str(inst)
552 recdblist.addlog(os.path.join(recpath,title+".ts"), errtxt, "timerec-move(Decode) error")
553 recdb.rec_reckey(recdblist.REC_MOVE_END, title, chtxt, btime, etime, opt)
555 recdb.del_reckey(typetxtnow, title, chtxt, btime)
556 bt = bt + datetime.timedelta(seconds=600)
557 et = et + datetime.timedelta(seconds=600)
558 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
559 etime = et.strftime("%Y-%m-%d %H:%M:%S")
560 recdb.rec_reckey(typetxtnow, title, chtxt, btime, etime, opt)
563 def type_encode_que(typetxt,chtxt,title,bt,et,opt):
564 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
565 etime = et.strftime("%Y-%m-%d %H:%M:%S")
566 tnow = datetime.datetime.now()
568 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
572 if typetxt==recdblist.REC_ENCODE_QUE:
573 typetxting=recdblist.REC_ENCODE_LOCAL
574 typetxtfin=recdblist.REC_FIN_LOCAL
576 if status.getEncoding() < int(configreader.getenv("enc_max")):
577 recdb.del_reckey(typetxtnow, title, chtxt, btime)
578 recdb.rec_reckey(typetxting, title, chtxt, btime, etime, opt)
579 recdblist.printutf8(opt)
580 pin = recpath + "/" + title + ".ts"
581 if re.search("d", opt):
582 pin = recpath + "/" + title + ".m2v"
583 if not os.path.exists(pin) or os.path.getsize(pin)<100*1000:
584 paac2 = recpath + "/" + title + "_2.aac"
585 pmp32 = recpath + "/" + title + "_2.mp3"
586 if not os.path.exists(paac2) and not os.path.exists(pmp32):
587 tv2avi.dualaudio2sep(os.path.join(recpath, title+".ts"),"167")
589 elif re.search("5", opt):
590 pin = recpath + "/" + title + ".m2v"
591 if not os.path.exists(pin) or os.path.getsize(pin)<100*1000:
592 paac2 = recpath + "/" + title + "_2.aac"
593 pmp32 = recpath + "/" + title + "_2.mp3"
594 if not os.path.exists(paac2) and not os.path.exists(pmp32):
595 tv2avi.pentaaudio2sep(os.path.join(recpath, title+".ts"))
599 if configreader.getenv("make_mp4")=="1":
603 if re.search("m", opt):
605 if re.search("4", opt):
607 recdblist.printutf8(pin)
608 if not re.search("0", opt):
610 pout = recpath + "/" + title + ".mp4"
611 tv2mp4.ts2mp4(pin, pout, opt)
613 pout = recpath + "/" + title + ".mkv"
614 tv2mkv.ts2mkv(pin, pout, opt)
615 if re.search("8", opt) or re.search("9", opt):
617 optt=optt.replace("8","MW8")
618 optt=optt.replace("9","MW9")
619 poutt = recpath + "/" + "m_"+title + ".mp4"
620 if re.search("d", opt) or re.search("5", opt):
621 if os.path.exists(os.path.join(recpath, "m_"+title+".m2v")):
622 shutil.move(os.path.join(recpath, title+".m2v"),os.path.join(recpath, "m_"+title+".m2v"))
623 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.aac")):
624 shutil.move(os.path.join(recpath, title+"_1.aac"),os.path.join(recpath, "m_"+title+"_1.aac"))
625 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.mp3")):
626 shutil.move(os.path.join(recpath, title+"_1.mp3"),os.path.join(recpath, "m_"+title+"_1.mp3"))
627 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.aac")):
628 shutil.move(os.path.join(recpath, title+"_2.aac"),os.path.join(recpath, "m_"+title+"_2.aac"))
629 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.mp3")):
630 shutil.move(os.path.join(recpath, title+"_2.mp3"),os.path.join(recpath, "m_"+title+"_2.mp3"))
631 shutil.move(os.path.join(recpath, title+".ts"),os.path.join(recpath, "m_"+title+".ts"))
632 tv2mp4.ts2mp4(os.path.join(recpath, "m_"+title+".ts"), poutt, optt)
633 shutil.move(os.path.join(recpath, "m_"+title+".ts"),os.path.join(recpath, title+".ts"))
636 optt=optt.replace("8","MW8")
637 optt=optt.replace("9","MW9")
638 poutt = recpath + "/" + "m_"+title + ".mp4"
639 shutil.move(os.path.join(recpath, title+".ts"),os.path.join(recpath, "m_"+title+".ts"))
640 if re.search("d", opt) or re.search("5", opt):
641 if os.path.exists(os.path.join(recpath, "m_"+title+".m2v")):
642 shutil.move(os.path.join(recpath, title+".m2v"),os.path.join(recpath, "m_"+title+".m2v"))
643 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.aac")):
644 shutil.move(os.path.join(recpath, title+"_1.aac"),os.path.join(recpath, "m_"+title+"_1.aac"))
645 if os.path.exists(os.path.join(recpath, "m_"+title+"_1.mp3")):
646 shutil.move(os.path.join(recpath, title+"_1.mp3"),os.path.join(recpath, "m_"+title+"_1.mp3"))
647 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.aac")):
648 shutil.move(os.path.join(recpath, title+"_2.aac"),os.path.join(recpath, "m_"+title+"_2.aac"))
649 if os.path.exists(os.path.join(recpath, "m_"+title+"_2.mp3")):
650 shutil.move(os.path.join(recpath, title+"_2.mp3"),os.path.join(recpath, "m_"+title+"_2.mp3"))
651 tv2mp4.ts2mp4(os.path.join(recpath, "m_"+title+".ts"), poutt, optt)
652 shutil.move(os.path.join(recpath, "m_"+title+".ts"),os.path.join(recpath, title+".ts"))
653 recdb.del_reckey(typetxting, title, chtxt, btime)
655 if re.search("E", opt):
657 if os.path.exists(os.path.join(recpath,title+".mp4")):
658 shutil.copy(os.path.join(recpath,title+".mp4"), os.path.join(movepath,title+".mp4"))
659 elif os.path.exists(os.path.join(recpath,title+".mkv")):
660 shutil.copy(os.path.join(recpath,title+".mkv"), os.path.join(movepath,title+".mkv"))
661 except Exception, inst:
662 errtxt="Error happened in type_encode_que in timerec.\n"
663 errtxt=errtxt+"move mkv/mp4 error.\n"
664 errtxt=errtxt+str(type(inst))+"\n"
665 errtxt=errtxt+str(inst)
666 recdblist.addlog(os.path.join(recpath,title+".ts"), errtxt, "timerec-move(Encode) error")
667 recdb.rec_reckey(recdblist.REC_MOVE_END, title, chtxt, btime, etime, opt)
668 recdb.rec_reckey(typetxtfin, title, chtxt, btime, etime, opt)
671 recdb.del_reckey(typetxtnow, title, chtxt, btime)
672 bt = bt + datetime.timedelta(seconds=600)
673 et = et + datetime.timedelta(seconds=600)
674 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
675 etime = et.strftime("%Y-%m-%d %H:%M:%S")
676 recdb.rec_reckey(typetxtnow, title, chtxt, btime, etime, opt)