#!/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
import tv2avi
import tv2mkv
import tv2mp4
+import install
import recdblist
recpath = configreader.getpath('recpath')
movepath = configreader.getpath('move_destpath')
数分毎に実行されるタスク処理
予定によって子プロセスを生成し処理する。
"""
+ try:
+ if rec10d.rec10db.select_installed_in_status()==0:
+ install.install()
+ except:
+ install.install()
recdb.delete_old("24")
recdb.delete_old_auto_bayes("1")
recdb.delete_old_auto_keyword("1")
if pid!=0:
""
else:
+ time.sleep(10)
auto_process.auto_check(recpath)
sys.exit()
update = chdb.update()
else:
recdb.del_reckey(recdblist.REC_AVI_TO_MKV, title, chtxt, btime)
recdb.rec_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
- tv2mkv.avi2mkv(os.path.join(recpath,title+".avi"),os.path.join(recpath,title+".mkv"))
+ #tv2mp4.avi2mp4(os.path.join(recpath,title+".avi"),os.path.join(recpath,title+".mkv"),opt)
+ tv2mkv.avi2mkv(os.path.join(recpath,title+".avi"),os.path.join(recpath,title+".mkv"),opt)
recdb.del_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime)
sys.exit()
elif task["type"] == recdblist.REC_AVI_TO_MP4:
else:
recdb.del_reckey(recdblist.REC_AVI_TO_MP4, title, chtxt, btime)
recdb.rec_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
- tv2mp4.avi2mp4(os.path.join(recpath,title+".avi"),os.path.join(recpath,title+".mp4"))
+ tv2mp4.avi2mp4(os.path.join(recpath,title+".avi"),os.path.join(recpath,title+".mp4"),opt)
recdb.del_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime)
sys.exit()
elif task["type"] == recdblist.REC_MKV_TO_MP4:
if pid > 0:#親プロセスの場合
""
else:
- recdb.del_reckey(recdblist.REC_AVI_TO_MP4, title, chtxt, btime)
+ recdb.del_reckey(recdblist.REC_MKV_TO_MP4, title, chtxt, btime)
recdb.rec_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
tv2mp4.mkv2mp4(os.path.join(recpath,title+".mkv"),os.path.join(recpath,title+".mp4"))
recdb.del_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime)
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")
testpath=[os.path.join(recpath,title+".ts.b25")]
testpath.append(os.path.join(recpath,title+".ts"))
testpath.append(os.path.join(recpath,title+".avi"))
- testpath.append(os.path.join(recpath,title+".mkv"))
+ testpath.append(os.path.join(recpath,title+".mp4"))
testpath.append(os.path.join(recpath,title+".log"))
tcheck=0
for ti in testpath:
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:
+ print "Error happend in type_decode_que in timerec"
+ print "move ts error."
+ print type(inst)
+ print inst
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"
- pout = recpath + "/" + title + ".mp4"
+ 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)
+ tv2mkv.ts2mkv(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:
+ print "Error happend in type_encode_que in timerec"
+ print "move mkv/mp4 error."
+ print type(inst)
+ print inst
recdb.rec_reckey(recdblist.REC_MOVE_END, title, chtxt, btime, etime, opt)
recdb.rec_reckey(typetxtfin, title, chtxt, btime, etime, opt)
sys.exit()