# Copyright (C) 2009 Yukikaze
import datetime
import os
+import os.path
import re
import sys
import time
recdb.rec_reckey(recdb.REC_AUTO_SUGGEST_REC, titlet, chtxtt, btimet, etimet,"")
except Exception, inst:
print type(inst)
- print inst
\ No newline at end of file
+ print inst
+def type_reserve(chtxt,title,bt,et,opt):
+ chtxtnow=chtxt
+ chtxtfinal=""
+ if chtxt==recdb.REC_RESERVE:
+ chtxtfinal=recdb.REC_FINAL_RESERVE
+ elif chtxt==recdb.REC_MOVE_AFTER_DECODE:
+ chtxtfinal=recdb.REC_MOVE_AFTER_DECODE_FINAL
+ elif chtxt==recdb.REC_MOVE_AFTER_RECORD:
+ chtxtfinal=recdb.REC_MOVE_AFTER_RECORD_FINAL
+ elif chtxt==recdb.REC_MOVE_AFTER_ENCODE:
+ chtxtfinal=recdb.REC_MOVE_AFTER_ENCODE_FINAL
+ tnow = datetime.datetime.now()
+ dtt = bt-tnow
+ dt = dtt.days * 24 * 60 * 60 + dtt.seconds
+ if (dt < 58 * 60 and dt > 20 * 60):
+ pid = os.fork()
+ if pid != 0:#親プロセスの場合
+ ""
+ else:#子プロセスの場合 アップデートを行って終了
+ bctypet = chdb.chtxtsearch(chtxt)['bctype']
+ chdatat = rec10d.rec10db.select_by_bctype_chdata(bctypet)
+ dt1 = datetime.datetime.strptime(chdatat[0][5], "%Y-%m-%d %H:%M:%S")-datetime.datetime.now()
+ dt1 = dt1.days * 24 * 60 * 60 + dt1.seconds
+ if dt1 < 60 * 60:
+ recdata = epgdb.searchtime2(title.decode('utf-8'), btime, "5", chtxt)
+ chtxtn = recdata[0]
+ titlen = recdata[1]
+ btimen = recdata[2]
+ etimen = recdata[3]
+ exp = recdata[4]
+ longexp = recdata[5]
+ category=recdata[6]
+ bt = datetime.datetime.strptime(btimen, "%Y-%m-%d %H:%M:%S")
+ et = datetime.datetime.strptime(etimen, "%Y-%m-%d %H:%M:%S")
+ btimen = bt.strftime("%Y-%m-%d %H:%M:%S")
+ etimen = et.strftime("%Y-%m-%d %H:%M:%S")
+ if chtxt != "":
+ try:
+ recdb.del_reckey(chtxtnow, title, chtxt, btime)
+ recdb.rec_reckey(chtxtfinal, titlen, chtxtn, btimen, etimen, opt)
+ recdb.rec_reclog(titlen, chtxtn, btimen, etimen, opt, exp, longexp, category)
+ auto_rec.add_key(chtxt, titlen,exp+" "+longexp)
+ auto_rec.add_key("ALL", titlen,exp+" "+longexp)
+ print "Oikake "+title+" : "+titlen+" "+btimen+" "+etimen
+ except Exception, inst:
+ print "Error happended in Oikake DB"
+ print type(inst)
+ print inst
+ else:
+ print "nothing match"
+ else:
+ if rec10d.rec10db.select_by_bctype_chdata(bctypet)[0][6] != "0":
+ rec10d.rec10db.update_status_by_bctype_chdata(bctypet, "3")
+ sys.exit()
+ elif dt <= 20 * 60:
+ try:
+ recdb.del_reckey(chtxtnow, title, chtxt, btime)
+ recdb.rec_reckey(chtxtfinal, title, chtxt, btime, etime, opt)
+ except Exception, inst:
+ print type(inst)
+ print inst
+def type_final(chtxt,title,bt,et,opt):
+ chtxtnow=chtxt
+ chtxting=""
+ chtxtdecque=""
+ if chtxtnow==recdb.REC_FINAL_RESERVE:
+ chtxting=recdb.REC_TS_RECORDING
+ chtxtdecque=recdb.REC_TS_DECODE_QUE
+ elif chtxtnow==recdb.REC_MOVE_AFTER_DECODE_FINAL:
+ chtxting=recdb.REC_MOVE_AFTER_DECODE_RECORDING
+ chtxtdecque=recdb.REC_MOVE_AFTER_DECODE_DECODE_QUE
+ elif chtxtnow==recdb.REC_MOVE_AFTER_RECORD_FINAL
+ chtxting=recdb.REC_MOVE_AFTER_RECORD_RECORDING
+ chtxtdecque=""
+ elif chtxtnow==recdb.REC_MOVE_AFTER_ENCODE_FINAL:
+ chtxting=recdb.REC_MOVE_AFTER_ENCODE_RECORDING
+ chtxtdecque=recdb.REC_MOVE_AFTER_ENCODE_DECODE_QUE
+ tnow = datetime.datetime.now()
+ dtt = bt-tnow
+ dt = dtt.days * 24 * 60 * 60 + dtt.seconds
+ print dt
+ if dt < 6 * 60 and dt > 0:
+ recdb.del_reckey(chtxtnow, title, chtxt, btime)
+ recdb.rec_reckey(chtxting, title, chtxt, btime, etime, opt)
+ print "録画開始 "+title+" "+btime+" "+etime
+ pid = os.fork()
+ if pid != 0:#親プロセスの場合
+ ""
+ else:
+ ttitle=title
+ #print title
+ 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+".log"))
+ tcheck=0
+ for ti in testpath:
+ if os.path.exists(ti):
+ tcheck=tcheck+1
+ if tcheck>0:
+ ttitle=title+"_"+datetime.datetime.now().strftime("%Y%m%d%H%M")
+ tv2avi.timetv2b25(recpath + "/" + ttitle + ".avi", chtxt, btime, etime, opt)
+ recdb.del_reckey(chtxting, title, chtxt, btime)
+ if chtxtdecque != "":
+ tnow = datetime.datetime.now()
+ bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
+ et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
+ dt = tnow-bt
+ bt = tnow + datetime.timedelta(seconds=600)
+ et = et + dt + datetime.timedelta(seconds=600)
+ btime = bt.strftime("%Y-%m-%d %H:%M:%S")
+ etime = et.strftime("%Y-%m-%d %H:%M:%S")
+ recdb.rec_reckey(chtxtdecque, ttitle, chtxt, btime, etime, opt)
+ else:
+ shutil.copy(os.path.join(recpath,title+".ts.b25"), os.path.join(movepath,title+".ts.b25"))
+ sys.exit()
\ No newline at end of file