3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009 Yukikaze
18 recpath=configreader.getpath('recpath')
19 path=str(os.path.dirname(os.path.abspath(__file__)))+"/"
26 tasks=recdb.getnow("2")
28 inum=recdb.countRecNow_minutes("10")
29 #inum=recdb.countRecNow("1")
31 print "inum:"+str(inum)+"bscsrec:"+str(status.getBSCSRecording())+"terec:"+str(status.getTERecording())+" epg:"+str(status.getEPGUpdating())
33 #if inum+status.getBSCSRecording()+status.getTERecording() < 2:
44 if bctype.find('te')!=-1:
45 recnum=status.getTERecording()+recdb.countRecNow_minutes_TE("10")
46 print bctype+"//ing:"+str(status.getTERecording())+":task:"+str(recdb.countRecNow_minutes_TE("10"))
48 recnum=status.getBSCSRecording()+recdb.countRecNow_minutes_BSCS("10")
49 print bctype+"//ing:"+str(status.getBSCSRecording())+":task:"+str(recdb.countRecNow_minutes_BSCS("10"))
52 rec10d.rec10db.update_status_by_bctype_chdata(bctype,"0")
53 epgdb.updatebc(bctype)
55 #rec10d.rec10db.update_by_bctype_chdata(bctype)
60 """if len(update)>0 and status.getEPGUpdating()==0:
61 #status.setEPGUpdating(1)
64 status.setEPGUpdating(1)
68 else:#子プロセスの場合 アップデートを行って終了
73 epgdb.updatebc(bctype)
79 status.setEPGUpdating(0)
93 bt=datetime.datetime.strptime(btime,"%Y-%m-%d %H:%M:%S")
96 bt=datetime.datetime.strptime("2009-01-01 00:00:00","%Y-%m-%d %H:%M:%S")
99 et=datetime.datetime.strptime(etime,"%Y-%m-%d %H:%M:%S")
102 et=datetime.datetime.strptime("2009-01-01 00:00:00","%Y-%m-%d %H:%M:%S")
107 tnow=datetime.datetime.now()
109 dt=dtt.days*24*60*60+dtt.seconds
111 if task["type"]==recdb.REC_RESERVE:#"res,"+chtxt+","+title+","+btime+","+etime+","+opt
113 if (dt<58*60 and dt>20*60):
117 else:#子プロセスの場合 アップデートを行って終了
118 bctypet=chdb.chtxtsearch(chtxt)['bctype']
119 chdatat=rec10d.rec10db.select_by_bctype_chdata(bctypet)
120 dt1=datetime.datetime.now()-datetime.datetime.strptime(chdatat[5],"%Y-%m-%d %H:%M:%S")
121 dt1=dt1.days*24*60*60+dt1.seconds
123 recdata=epgdb.searchtime2(title.decode('utf-8'),btime,"5",chtxt)
128 bt=datetime.datetime.strptime(btimen,"%Y-%m-%d %H:%M:%S")
129 et=datetime.datetime.strptime(etimen,"%Y-%m-%d %H:%M:%S")
130 btimen=bt.strftime("%Y-%m-%d %H:%M:%S")
131 etimen=et.strftime("%Y-%m-%d %H:%M:%S")
134 recdb.del_reckey(recdb.REC_RESERVE, title, chtxt, btime)
135 recdb.rec_reckey(recdb.REC_FINAL_RESERVE, titlen, chtxtn, btimen, etimen, opt)
136 except Exception,inst:
140 print "nothing match"
142 rec10d.rec10db.update_status_by_bctype_chdata(bctypet,"3")
143 """cht=chdb.chtxtsearch(chtxt)['bctype']
144 if cht.find('te')!=-1:
148 bctypetemp=chdb.chtxtsearch(chtxt)['bctype']
150 gettaskbscs=recdb.countRecNow_minutes_BSCS("10")
151 getnowbscs=status.getBSCSRecording()
152 bscs=getnowbscs+gettaskbscs
153 if bscs <2 and status.getEPGUpdating()!=1:
154 print "now(bscs):"+str(getnowbscs)+" task(bscs):"+str(gettaskbscs)
155 status.setEPGUpdating(1)
156 rec10d.rec10db.update_status_by_bctype_chdata(bctype,"0")
157 epgdb.updatebc(bctypetemp)
160 status.setEPGUpdating(0)
164 gettaskte=recdb.countRecNow_minutes_TE("10")
165 getnowte=status.getTERecording()
166 te=getnowte+gettaskte
167 if te <2 and status.getEPGUpdating()!=1:
168 print "now(te):"+str(getnowte)+" task(te):"+str(gettaskte)
169 status.setEPGUpdating(1)
170 epgdb.updatebc(bctypetemp)
172 status.setEPGUpdating(0)
177 recdata=epgdb.searchtime2(title.decode('utf-8'),btime,"5",chtxt)
182 bt=datetime.datetime.strptime(btimen,"%Y-%m-%d %H:%M:%S")
183 et=datetime.datetime.strptime(etimen,"%Y-%m-%d %H:%M:%S")
184 btimen=bt.strftime("%Y-%m-%d %H:%M:%S")
185 etimen=et.strftime("%Y-%m-%d %H:%M:%S")
188 recdb.del_reckey(recdb.REC_RESERVE, title, chtxt, btime)
189 recdb.rec_reckey(recdb.REC_FINAL_RESERVE, titlen, chtxtn, btimen, etimen, opt)
190 except Exception,inst:
194 print "nothing match"
201 recdb.del_reckey(recdb.REC_RESERVE, title, chtxt, btime)
202 recdb.rec_reckey(recdb.REC_FINAL_RESERVE, title, chtxt, btime, etime, opt)
203 except Exception,inst:
206 elif task["type"]==recdb.REC_KEYWORD:#"key,"+chtxt+","+keyword+","+btime+","+deltatime+","+opt
207 deltatime=task['deltatime']
209 recdata=epgdb.searchtime2(title.decode('utf-8'),btime,deltatime,chtxt)
215 bt=datetime.datetime.strptime(btimet,"%Y-%m-%d %H:%M:%S")
216 et=datetime.datetime.strptime(etimet,"%Y-%m-%d %H:%M:%S")
217 btimet=bt.strftime("%Y-%m-%d %H:%M:%S")
218 etimet=et.strftime("%Y-%m-%d %H:%M:%S")
220 recdb.del_reckey(recdb.REC_KEYWORD, title, chtxt, btime)
221 recdb.rec_reckey(recdb.REC_RESERVE, titlet, chtxtt, btimet, etimet, opt)
222 except Exception,inst:
226 print "nothing match"
227 elif task["type"]==recdb.REC_KEYWORD_EVERY_SOME_DAYS:#"keyevery,"+chtxt+","+keyword+","+btime+","+deltatime+","+opt+","+deltaday
228 deltatime=task['deltatime']
229 deltaday=task['deltaday']
230 dd=datetime.timedelta(days=int(deltaday))
232 recdb.del_reckey(recdb.REC_KEYWORD_EVERY_SOME_DAYS, title, chtxt, btime)
235 btxt=bt.strftime("%Y-%m-%d %H:%M:%S")
236 etxt=et.strftime("%Y-%m-%d %H:%M:%S")
237 recdb.everyreserv(title,chtxt,btxt,etxt,deltatime,opt,deltaday)
239 recdb.keyreserv(title,chtxt,btime,etime,deltatime,opt)
240 recdb.del_reckey(recdb.REC_KEYWORD_EVERY_SOME_DAYS, title, chtxt, btime)
243 btxt=bt.strftime("%Y-%m-%d %H:%M:%S")
244 etxt=et.strftime("%Y-%m-%d %H:%M:%S")
245 recdb.everyreserv(title,chtxt,btxt,etxt,deltatime,opt,deltaday)
247 elif task["type"]==recdb.REC_FINAL_RESERVE:#"rec,"+chtxt+","+title+","+btime+","+etime+","+opt
250 recdb.del_reckey(recdb.REC_FINAL_RESERVE, title, chtxt, btime)
251 recdb.rec_reckey(recdb.REC_TS_RECORDING, title, chtxt, btime, etime, opt)
258 tv2avi.timetv2b25(recpath+"/"+title+".avi", chtxt, btime, etime, opt)
259 recdb.del_reckey(recdb.REC_TS_RECORDING, title, chtxt, btime)
260 tnow=datetime.datetime.now()
261 bt=datetime.datetime.strptime(btime,"%Y-%m-%d %H:%M:%S")
262 et=datetime.datetime.strptime(etime,"%Y-%m-%d %H:%M:%S")
264 bt=tnow+datetime.timedelta(seconds=600)
265 et=et+dt+datetime.timedelta(seconds=600)
266 btime=bt.strftime("%Y-%m-%d %H:%M:%S")
267 etime=et.strftime("%Y-%m-%d %H:%M:%S")
268 recdb.rec_reckey(recdb.REC_TS_DECODE_QUE,title,chtxt,btime,etime,opt)
270 elif task["type"]==recdb.REC_TS_DECODE_QUE:
272 if status.getB25Decoding()<2:
277 pin=recpath+"/"+title
278 recdb.del_reckey(recdb.REC_TS_DECODE_QUE,title,chtxt,btime)
279 recdb.rec_reckey(recdb.REC_TS_DECODING, title, chtxt, btime, etime, opt)
280 tv2avi.b252ts(pin, chtxt, btime, etime, opt)
281 recdb.del_reckey(recdb.REC_TS_DECODING,title,chtxt,btime)
282 if not os.access(recpath+"/"+title+".ts", os.F_OK):
283 recdb.del_reckey(recdb.REC_TS_DECODING, title, chtxt, btime)
284 recdb.rec_reckey(recdb.REC_MISS_DECODE, title, chtxt, btime, etime, opt)
285 tnow=datetime.datetime.now()
286 bt=datetime.datetime.strptime(btime,"%Y-%m-%d %H:%M:%S")
287 et=datetime.datetime.strptime(etime,"%Y-%m-%d %H:%M:%S")
289 bt=tnow+datetime.timedelta(seconds=600)
290 et=et+dt+datetime.timedelta(seconds=600)
291 btime=bt.strftime("%Y-%m-%d %H:%M:%S")
292 etime=et.strftime("%Y-%m-%d %H:%M:%S")
293 recdb.rec_reckey(recdb.REC_ENCODE_QUE, title, chtxt, btime, etime, opt)
294 print "b25check "+recpath+"/"+title+".ts.b25 "+recpath+"/"+title+".ts"
295 print checker.checkB25Decode(recpath+"/"+title+".ts.b25",recpath+"/"+title+".ts")
296 if checker.checkB25Decode(recpath+"/"+title+".ts.b25",recpath+"/"+title+".ts")==1:
297 os.remove(recpath+"/"+title+".ts.b25")
300 recdb.del_reckey(recdb.REC_TS_DECODE_QUE,title,chtxt,btime)
301 bt=bt+datetime.timedelta(seconds=600)
302 et=et+datetime.timedelta(seconds=600)
303 btime=bt.strftime("%Y-%m-%d %H:%M:%S")
304 etime=et.strftime("%Y-%m-%d %H:%M:%S")
305 recdb.rec_reckey(recdb.REC_TS_DECODE_QUE,title,chtxt,btime,etime,opt)
306 elif task["type"]==recdb.REC_ENCODE_QUE:
308 if status.getEncoding()<int(configreader.getenv("enc_max")):
313 pin=recpath+"/"+title+".ts"
314 if re.search("d",opt):
315 pin=recpath+"/"+title+"sa.avi"
316 if re.search("5",opt):
317 pin=recpath+"/"+title+"sa.avi"
318 pout=recpath+"/"+title+".avi"
320 #print pin+":"+pout+":"+opt
321 recdb.del_reckey(recdb.REC_ENCODE_QUE,title,chtxt,btime)
322 recdb.rec_reckey(recdb.REC_ENCODE_LOCAL, title, chtxt, btime, etime, opt)
323 tv2avi.ts2avi(pin, pout, opt)
324 recdb.del_reckey(recdb.REC_ENCODE_LOCAL,title,chtxt,btime)
325 recdb.rec_reckey(recdb.REC_FIN_LOCAL, title, chtxt, btime, etime, opt)
328 recdb.del_reckey(recdb.REC_ENCODE_QUE,title,chtxt,btime)
329 bt=bt+datetime.timedelta(seconds=600)
330 et=et+datetime.timedelta(seconds=600)
331 btime=bt.strftime("%Y-%m-%d %H:%M:%S")
332 etime=et.strftime("%Y-%m-%d %H:%M:%S")
333 recdb.rec_reckey(recdb.REC_ENCODE_QUE,title,chtxt,btime,etime,opt)