#!/usr/bin/python
# coding: UTF-8
# Rec10 TS Recording Tools
-# Copyright (C) 2009 Yukikaze
+# Copyright (C) 2009-2010 Yukikaze
import datetime
import os
import os.path
ett = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
btimet = btt.strftime("%Y-%m-%d %H:%M:%S")
etimet = ett.strftime("%Y-%m-%d %H:%M:%S")
- try:
- recdb.add_auto_keyword(chtxtt, titlet, btimet, etimet)
- except Exception, inst:
- print "error occures in search_keyword"
- print type(inst)
- print inst
+ if status.getSettings_auto_jbk()==1:
+ topt=status.getSettings_auto_opt()
+ try:
+ maxnum=0
+ if len(ch['ch'])>2:
+ maxnum=epgdb.count_schedule_timeline(btimet, etimet)[1]
+ maxnum=int(configreader.getenv("bscs_max"))-maxnum
+ else:
+ maxnum=epgdb.count_schedule_timeline(btimet, etimet)[0]
+ maxnum=int(configreader.getenv("te_max"))-maxnum
+ if maxnum>0:
+ topt=status.getSettings_auto_opt()
+ recdb.recreserv(titlet,chtxtt, btimet, etimet,topt)
+ except Exception, inst:
+ print "error occures in search_keyword_auto_jbk"
+ print type(inst)
+ print inst
+ else:
+ try:
+ recdb.add_auto_keyword(chtxtt, titlet, btimet, etimet)
+ except Exception, inst:
+ print "error occures in search_keyword"
+ print type(inst)
+ print inst
def type_reserve(typetxt,chtxt,title,bt,et,opt):
btime = bt.strftime("%Y-%m-%d %H:%M:%S")
etime = et.strftime("%Y-%m-%d %H:%M:%S")
auto_rec.add_key("ALL", titlen,exp+" "+longexp)
recdblist.printutf8(u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen)
except Exception, inst:
- print "Error happended in Oikake DB"
+ print "Error happened in Oikake DB"
print type(inst)
print inst
else:
auto_rec.add_key("ALL", titlen,exp+" "+longexp)
recdblist.printutf8(u"追いかけ機能実行中: "+title+" : "+titlen+" "+btimen+" "+etimen)
except Exception, inst:
- print "Error happended in Oikake DB"
+ print "Error happened in Oikake DB"
print type(inst)
print inst
elif dt <= 20 * 60:
if os.path.exists(ti):
tcheck=tcheck+1
if re.search("N", opt) or tcheck>0:
- newtitle=newtitle+u"_"+bt.strftime("%Y%m%d%H%M")
+ iff=""
+ try:
+ iff=u"("+configreader.getenv("iff")+u")_"
+ except:
+ iff=""
+ newtitle=newtitle+u"_"+iff+bt.strftime("%Y-%m-%dT%H:%M:%S")
recdb.rec_reckey(typetxting, newtitle, chtxt, btime, etime, opt)
recdblist.printutf8(u"録画開始 "+newtitle+" "+btime+" "+etime)
tv2avi.timetv2b25(recpath + "/" + newtitle + ".avi", chtxt, btime, etime, opt)
etime = et.strftime("%Y-%m-%d %H:%M:%S")
recdb.rec_reckey(typetxtdecque, newtitle, chtxt, btime, etime, opt)
else:
- shutil.copy(os.path.join(recpath,title+".ts.b25"), os.path.join(movepath,title+".ts.b25"))
+ try:
+ shutil.copy(os.path.join(recpath,title+".ts.b25"), os.path.join(movepath,title+".ts.b25"))
+ except:
+ ""
recdb.rec_reckey(recdblist.REC_MOVE_END, newtitle, chtxt, btime, etime, opt)
sys.exit()
def type_keyword(typetxt,chtxt,title,bt,et,opt,deltatime):
etime = et.strftime("%Y-%m-%d %H:%M:%S")
recdb.rec_reckey(typetxtencque, title, chtxt, btime, etime, opt)
else:
- if opt.rfind("d")>=0:
- shutil.copy(os.path.join(recpath,title+".sa.avi"),os.path.join(movepath,title+".sa.avi"))
- elif opt.rfind("5")>=0:
- shutil.copy(os.path.join(recpath,title+".sa.avi"),os.path.join(movepath,title+".sa.avi"))
- else:
+ try:
shutil.copy(os.path.join(recpath,title+".ts"), os.path.join(movepath,title+".ts"))
+ except Exception, inst:
+ errtxt="Error happened in type_decode_que in timerec.\n"
+ errtxt=errtxt+"move ts error.\n"
+ errtxt=errtxt+type(inst)+"\n"
+ errtxt=errtxt+inst
+ recdblist.addlog(os.path.join(recpath,title+".ts"), errtxt, "timerec-move(Decode) error")
recdb.rec_reckey(recdblist.REC_MOVE_END, title, chtxt, btime, etime, opt)
if checker.checkB25Decode(recpath + "/" + title + ".ts.b25", recpath + "/" + title + ".ts") == 1:
os.remove(recpath + "/" + title + ".ts.b25")
typetxtfin=recdblist.REC_FIN_LOCAL
if dt < 10 * 60:
if status.getEncoding() < int(configreader.getenv("enc_max")):
+ recdb.del_reckey(typetxtnow, title, chtxt, btime)
+ recdb.rec_reckey(typetxting, title, chtxt, btime, etime, opt)
recdblist.printutf8(opt)
pin = recpath + "/" + title + ".ts"
if re.search("d", opt):
- pin = recpath + "/" + title + ".sa.avi"
+ pin = recpath + "/" + title + ".m2v"
+ if not os.path.exists(pin):
+ tv2avi.dualaudio2sep(os.path.join(recpath, title+".ts"),"167")
+ time.sleep(3)
if re.search("5", opt):
pin = recpath + "/" + title + ".sa.avi"
- #pout = recpath + "/" + title + ".avi"
+ if not os.path.exists(pin):
+ tv2avi.pentaaudiots2avi(os.path.join(recpath, title+".ts"), pin)
+ time.sleep(3)
pout = recpath + "/" + title + ".mkv"
recdblist.printutf8(pin)
- #recdblist.printutf8(pin+":"+pout+":"+opt)
- recdb.del_reckey(typetxtnow, title, chtxt, btime)
- recdb.rec_reckey(typetxting, title, chtxt, btime, etime, opt)
tv2mkv.ts2mkv(pin, pout, opt)
- #tv2mp4.ts2mp4(pin, pout, opt)
- #tv2avi.ts2avi(pin, pout, opt)
recdb.del_reckey(typetxting, title, chtxt, btime)
if re.search("E", opt):
- shutil.copy(os.path.join(recpath,title+".mp4"), os.path.join(movepath,title+".mp4"))
+ try:
+ if os.path.exists(os.path.join(recpath,title+".mp4")):
+ shutil.copy(os.path.join(recpath,title+".mp4"), os.path.join(movepath,title+".mp4"))
+ elif os.path.exists(os.path.join(recpath,title+".mkv")):
+ shutil.copy(os.path.join(recpath,title+".mkv"), os.path.join(movepath,title+".mkv"))
+ except Exception, inst:
+ errtxt="Error happened in type_encode_que in timerec.\n"
+ errtxt=errtxt+"move mkv/mp4 error.\n"
+ errtxt=errtxt+type(inst)+"\n"
+ errtxt=errtxt+inst
+ recdblist.addlog(os.path.join(recpath,title+".ts"), errtxt, "timerec-move(Encode) error")
recdb.rec_reckey(recdblist.REC_MOVE_END, title, chtxt, btime, etime, opt)
recdb.rec_reckey(typetxtfin, title, chtxt, btime, etime, opt)
sys.exit()