3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009-2010 Yukikaze
26 from recdblist import verbose_level_now
28 recpath = configreader.getpath('recpath')
29 movepath = configreader.getpath('move_destpath')
30 path = str(os.path.dirname(os.path.abspath(__file__))) + "/"
37 if rec10d.rec10db.select_installed_in_status()==0 or rec10d.rec10db.select_version_in_status()<recdblist.version:
41 recdb.delete_old("24")
42 recdb.delete_old_auto_bayes("1")
43 recdb.delete_old_auto_keyword("1")
44 tasks = recdb.getnow("3")
45 inum = recdb.countRecNow_minutes("10")
46 recdblist.printutf8(u"rec10処理開始"+ datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),verbose_level=800)
47 recdblist.printutf8(u"直近録画予約件数:" + str(inum) + u"BS/CS録画中件数:" + str(status.getBSCSRecording()) + u"TE録画中件数:" + str(status.getTERecording()) ,verbose_level=800)
50 dnow=datetime.datetime.now()
56 for k in recdb.get_key():
65 auto_process.auto_check(recpath)
67 auto_process.kill_dead_encode(recpath)
69 update = chdb.update()
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")),verbose_level=800)
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")),verbose_level=800)
85 recnum = int(configreader.getenv("bscs_max")) -recnum
87 recdblist.printutf8(str(update))
88 rec10d.rec10db.update_status_by_bctype_epg_ch(bctype, "0",verbose_level=750)
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.Commonlogex("Error", "search_keyword_auto_jbk(timerec.py)", str(type(inst)),str(inst),log_level=200)
279 recdb.add_auto_keyword(chtxtt, titlet, btimet, etimet)
280 except Exception, inst:
281 recdblist.Commonlogex("Error", "search_keyword(timerec.py)", str(type(inst)),str(inst),log_level=200)
282 def type_reserve(typetxt,chtxt,title,bt,et,opt):
283 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
284 etime = et.strftime("%Y-%m-%d %H:%M:%S")
287 if typetxt==recdblist.REC_RESERVE:
288 typetxtfinal=recdblist.REC_FINAL_RESERVE
289 tnow = datetime.datetime.now()
291 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
292 if (dt < 58 * 60 and dt > 30 * 60):
293 bctypet = chdb.chtxtsearch(chtxt)['bctype']
294 chdatat = rec10d.rec10db.select_by_bctype_epg_ch(bctypet)
295 dt1 = datetime.datetime.strptime(chdatat[0][5], "%Y-%m-%d %H:%M:%S")-datetime.datetime.now()
296 dt1 = dt1.days * 24 * 60 * 60 + dt1.seconds
298 recdata = epgdb.searchtime2(title, btime, "5", chtxt)
306 bt = datetime.datetime.strptime(btimen, "%Y-%m-%d %H:%M:%S")
307 et = datetime.datetime.strptime(etimen, "%Y-%m-%d %H:%M:%S")
308 btimen = bt.strftime("%Y-%m-%d %H:%M:%S")
309 etimen = et.strftime("%Y-%m-%d %H:%M:%S")
312 recdb.del_reckey(typetxtnow, title, chtxt, btime)
313 recdb.rec_reckey(typetxtfinal, titlen, chtxtn, btimen, etimen, opt)
314 recdb.rec_reclog(titlen, chtxtn, btimen, etimen, opt, exp, longexp, category)
315 auto_rec.add_key(chtxt, titlen,exp+" "+longexp)
316 auto_rec.add_key("ALL", titlen,exp+" "+longexp)
317 recdblist.printutf8(u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen)
318 except Exception, inst:
319 recdblist.Commonlogex("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst),log_level=200)
321 recdblist.printutf8(u"追いかけ機能エラー:番組データが見付かりません。")
323 if rec10d.rec10db.select_by_bctype_epg_ch(bctypet)[0][6] != "0":
324 rec10d.rec10db.update_status_by_bctype_epg_ch(bctypet, "3")
326 elif (dt <= 30 * 60 and dt > 20 * 60):
327 recdata = epgdb.searchtime2(title, btime, "5", chtxt)
335 bt = datetime.datetime.strptime(btimen, "%Y-%m-%d %H:%M:%S")
336 et = datetime.datetime.strptime(etimen, "%Y-%m-%d %H:%M:%S")
337 btimen = bt.strftime("%Y-%m-%d %H:%M:%S")
338 etimen = et.strftime("%Y-%m-%d %H:%M:%S")
341 recdb.del_reckey(typetxtnow, title, chtxt, btime)
342 recdb.rec_reckey(typetxtfinal, titlen, chtxtn, btimen, etimen, opt)
343 recdb.rec_reclog(titlen, chtxtn, btimen, etimen, opt, exp, longexp, category)
344 auto_rec.add_key(chtxt, titlen,exp+" "+longexp)
345 auto_rec.add_key("ALL", titlen,exp+" "+longexp)
346 #recdblist.printutf8(u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen)
347 recdblist.Commonlogex(u"通常", "Oikake (timerec.py)",u"追いかけ機能実行中",u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen,log_level=500)
348 except Exception, inst:
349 recdblist.Commonlogex("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst),log_level=200)
352 recdb.del_reckey(typetxtnow, title, chtxt, btime)
353 recdb.rec_reckey(typetxtfinal, title, chtxt, btime, etime, opt)
354 except Exception, inst:
355 recdblist.Commonlogex("Error", "Oikake DB(timerec.py)", str(type(inst)),str(inst),log_level=200)
356 def type_final(typetxt,chtxt,title,bt,et,opt):
357 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
358 etime = et.strftime("%Y-%m-%d %H:%M:%S")
362 if typetxt==recdblist.REC_FINAL_RESERVE:
363 typetxting=recdblist.REC_TS_RECORDING
364 typetxtdecque=recdblist.REC_TS_DECODE_QUE
365 tnow = datetime.datetime.now()
367 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
368 if dt < 6 * 60 and dt > 0:
370 recdb.del_reckey(typetxtnow, title, chtxt, btime)
371 testpath=[os.path.join(recpath,title+".ts.b25")]
372 testpath.append(os.path.join(recpath,title+".ts"))
373 testpath.append(os.path.join(recpath,title+".avi"))
374 testpath.append(os.path.join(recpath,title+".mp4"))
375 testpath.append(os.path.join(recpath,title+".log"))
378 if os.path.exists(ti):
380 if re.search("N", opt) or tcheck>0:
383 iff=u"("+configreader.getenv("iff")+u")_"
387 newtitle=newtitle+u"_"+iff+newtime.strftime("%Y-%m-%dT%H-%M-%S")
388 recdb.rec_reckey(typetxting, newtitle, chtxt, btime, etime, opt)
389 recdblist.Commonlogex(u"通常","timerec.py",u"録画開始 "+newtitle+" "+btime+" "+etime,"",log_level=500)
390 tv2avi.timetv2b25(recpath + "/" + newtitle + ".avi", chtxt, btime, etime, opt)
391 recdb.del_reckey(typetxting, newtitle, chtxt, btime)
392 if not re.search("R", opt):
393 tnow = datetime.datetime.now()
394 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
395 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
397 bt = tnow + datetime.timedelta(seconds=600)
398 et = et + dt + datetime.timedelta(seconds=600)
399 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
400 etime = et.strftime("%Y-%m-%d %H:%M:%S")
401 recdb.rec_reckey(typetxtdecque, newtitle, chtxt, btime, etime, opt)
404 shutil.copy(os.path.join(recpath,title+".ts.b25"), os.path.join(movepath,title+".ts.b25"))
407 recdb.rec_reckey(recdblist.REC_MOVE_END, newtitle, chtxt, btime, etime, opt)
409 def type_keyword(typetxt,chtxt,title,bt,et,opt,deltatime):
410 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
411 etime = et.strftime("%Y-%m-%d %H:%M:%S")
414 if typetxt==recdblist.REC_KEYWORD:
415 typetxtres=recdblist.REC_RESERVE
416 tnow = datetime.datetime.now()
418 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
421 recdata = epgdb.searchtime2(title, btime, deltatime, chtxt)
430 bt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
431 et = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
432 btimet = bt.strftime("%Y-%m-%d %H:%M:%S")
433 etimet = et.strftime("%Y-%m-%d %H:%M:%S")
435 recdb.del_reckey(typetxtnow, title, chtxt, btime)
436 recdb.rec_reckey(typetxtres, titlet, chtxtt, btimet, etimet, opt)
437 recdb.rec_reclog(titlet, chtxtt, btimet, etimet, opt, exp,longexp,category)
438 auto_rec.add_key(chtxt, titlet,exp+" "+longexp)
439 auto_rec.add_key("ALL", titlet,exp+" "+longexp)
440 recdblist.Commonlogex(u"通常","timerec.py",u"key "+title+u" : "+titlet+u" "+btimet+u" "+etimet,"",log_level=500)
441 #except Exception, inst:
442 # recdblist.printutf8("Error happened in REC_KEYWORD DB")
443 # recdblist.printutf8(type(inst))
444 # recdblist.printutf8(inst)
446 recdblist.printutf8("nothing match")
447 def type_keyword_every_day(type,chtxt,title,bt,et,opt,deltatime,deltaday,counter):
448 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
449 etime = et.strftime("%Y-%m-%d %H:%M:%S")
450 tnow = datetime.datetime.now()
452 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
453 dd = datetime.timedelta(days=int(deltaday))
455 recdb.del_reckey(recdblist.REC_KEYWORD_EVERY_SOME_DAYS, title, chtxt, btime)
458 btxt = bt.strftime("%Y-%m-%d %H:%M:%S")
459 etxt = et.strftime("%Y-%m-%d %H:%M:%S")
460 recdb.everyreserv(title, chtxt, btxt, etxt, deltatime, opt, 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")
468 recdb.everyreserv(title, chtxt, btxt, etxt, deltatime, opt, deltaday,counter-1)
470 recdb.everyreserv(title, chtxt, btxt, etxt, deltatime, opt, deltaday,-1)
471 recdata = epgdb.searchtime2(title, btime, deltatime, chtxt)
480 bt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
481 et = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
482 btimet = bt.strftime("%Y-%m-%d %H:%M:%S")
483 etimet = et.strftime("%Y-%m-%d %H:%M:%S")
485 recdb.keyreserv(titlet, chtxtt, btimet, etimet, deltatime, opt)
487 recdb.keyreserv(title, chtxt, btime, etime, deltatime, opt)
488 def type_decode_que(typetxt,chtxt,title,bt,et,opt):
489 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
490 etime = et.strftime("%Y-%m-%d %H:%M:%S")
491 tnow = datetime.datetime.now()
493 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
498 if typetxt== recdblist.REC_TS_DECODE_QUE:
499 typetxting=recdblist.REC_TS_DECODING
500 typetxtmiss=recdblist.REC_MISS_DECODE
501 typetxtencque=recdblist.REC_ENCODE_QUE
502 tnow = datetime.datetime.now()
504 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
506 if status.getB25Decoding() < 2:
507 pin = recpath + "/" + title
508 recdb.del_reckey(typetxtnow, title, chtxt, btime)
509 recdb.rec_reckey(typetxting, title, chtxt, btime, etime, opt)
510 tv2avi.b252ts(pin, chtxt, btime, etime, opt)
511 recdb.del_reckey(typetxting, title, chtxt, btime)
512 if not os.access(recpath + "/" + title + ".ts", os.F_OK):
513 recdb.del_reckey(typetxting, title, chtxt, btime)
514 recdb.rec_reckey(typetxtmiss, title, chtxt, btime, etime, opt)
516 auto_process.deltmpfile(recpath, title, ".ts")
517 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
518 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
520 if not re.search("D", opt):
521 tnow = datetime.datetime.now()
522 bt = tnow + datetime.timedelta(seconds=600)
524 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
525 etime = et.strftime("%Y-%m-%d %H:%M:%S")
526 recdb.rec_reckey(typetxtencque, title, chtxt, btime, etime, opt)
529 shutil.copy(os.path.join(recpath,title+".ts"), os.path.join(movepath,title+".ts"))
531 if os.path.getsize(os.path.join(recpath,title+".ts"))==os.path.getsize(os.path.join(movepath,title+".ts")):
532 os.remove(os.path.join(recpath,title+".ts"))
533 except Exception, inst:
534 errtxt1="move ts error.\n"
535 errtxt2=str(type(inst))+"\n"
536 errtxt2=errtxt2+str(inst)
537 recdblist.Commonlogex("Error", "type_decode_que(timerec.py)", errtxt1,errtxt2,log_level=200)
538 recdb.rec_reckey(recdblist.REC_MOVE_END, title, chtxt, btime, etime, opt)
540 recdb.del_reckey(typetxtnow, title, chtxt, btime)
541 bt = bt + datetime.timedelta(seconds=600)
542 et = et + 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(typetxtnow, title, chtxt, btime, etime, opt)
548 def type_encode_que(typetxt,chtxt,title,bt,et,opt):
549 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
550 etime = et.strftime("%Y-%m-%d %H:%M:%S")
551 tnow = datetime.datetime.now()
553 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
557 if typetxt==recdblist.REC_ENCODE_QUE:
558 typetxting=recdblist.REC_ENCODE_LOCAL
559 typetxtfin=recdblist.REC_FIN_LOCAL
561 if status.getEncoding() < int(configreader.getenv("enc_max")):
562 recdb.del_reckey(typetxtnow, title, chtxt, btime)
563 recdb.rec_reckey(typetxting, title, chtxt, btime, etime, opt)
564 recdblist.printutf8(opt)
565 pin = recpath + "/" + title + ".ts"
566 if re.search("d", opt):
567 pin = recpath + "/" + title + ".m2v"
568 if not os.path.exists(pin) or os.path.getsize(pin)<100*1000:
569 paac2 = recpath + "/" + title + "_2.aac"
570 pmp32 = recpath + "/" + title + "_2.mp3"
571 if not os.path.exists(paac2) and not os.path.exists(pmp32):
572 tv2avi.dualaudio2sep(os.path.join(recpath, title+".ts"),"167")
574 elif re.search("5", 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 tv2avi.pentaaudio2sep(os.path.join(recpath, title+".ts"))
582 elif re.search("b", opt):
583 pin = recpath + "/" + title + ".m2v"
584 if not os.path.exists(pin) or os.path.getsize(pin)<100*1000:
585 paac2 = recpath + "/" + title + "_1.aac"
586 pmp32 = recpath + "/" + title + "_1.mp3"
587 if not os.path.exists(paac2) and not os.path.exists(pmp32):
588 tv2avi.singleaudio2sep(os.path.join(recpath, title+".ts"))
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 elif os.path.exists(os.path.join(recpath,title+".mkv")):
653 shutil.copy(os.path.join(recpath,title+".mkv"), os.path.join(movepath,title+".mkv"))
654 except Exception, inst:
655 errtxt1="move mkv/mp4 error."
656 errtxt2=str(type(inst))+"\n"
657 errtxt2=errtxt2+str(inst)
658 recdblist.Commonlogex("Error", "type_encode_que(timerec.py)", errtxt1,errtxt2,log_level=200)
659 recdb.rec_reckey(recdblist.REC_MOVE_END, title, chtxt, btime, etime, opt)
660 recdb.rec_reckey(typetxtfin, title, chtxt, btime, etime, opt)
663 recdb.del_reckey(typetxtnow, title, chtxt, btime)
664 bt = bt + datetime.timedelta(seconds=600)
665 et = et + datetime.timedelta(seconds=600)
666 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
667 etime = et.strftime("%Y-%m-%d %H:%M:%S")
668 recdb.rec_reckey(typetxtnow, title, chtxt, btime, etime, opt)