3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009 Yukikaze
23 recpath = configreader.getpath('recpath')
24 movepath = configreader.getpath('move_destpath')
25 path = str(os.path.dirname(os.path.abspath(__file__))) + "/"
31 recdb.delete_old("24")
32 tasks = recdb.getnow("2")
33 inum = recdb.countRecNow_minutes("10")
34 print "番組表更新処理"+ datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
35 print "inum:" + str(inum) + "bscsrec:" + str(status.getBSCSRecording()) + "terec:" + str(status.getTERecording())
38 dnow=datetime.datetime.now()
39 if dnow.hour==12 and dnow.minute<5 :
44 for k in recdb.get_key():
46 update = chdb.update()
56 if bctype.find('te') > -1:
57 recnum = status.getTERecording() + recdb.countRecNow_minutes_TE("10")
58 print bctype + "//ing:" + str(status.getTERecording()) + ":task:" + str(recdb.countRecNow_minutes_TE("10"))
60 recnum = status.getBSCSRecording() + recdb.countRecNow_minutes_BSCS("10")
61 print bctype + "//ing:" + str(status.getBSCSRecording()) + ":task:" + str(recdb.countRecNow_minutes_BSCS("10"))
64 rec10d.rec10db.update_status_by_bctype_chdata(bctype, "0")
65 epgdb.updatebc(bctype)
66 update = chdb.update()
83 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
86 bt = datetime.datetime.strptime("2009-01-01 00:00:00", "%Y-%m-%d %H:%M:%S")
89 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
92 et = datetime.datetime.strptime("2009-01-01 00:00:00", "%Y-%m-%d %H:%M:%S")
97 tnow = datetime.datetime.now()
99 dt = dtt.days * 24 * 60 * 60 + dtt.seconds
100 if task["type"] == recdb.REC_RESERVE:#"res,"+chtxt+","+title+","+btime+","+etime+","+opt
101 if (dt < 58 * 60 and dt > 20 * 60):
103 if pid != 0:#親プロセスの場合
105 else:#子プロセスの場合 アップデートを行って終了
106 bctypet = chdb.chtxtsearch(chtxt)['bctype']
107 chdatat = rec10d.rec10db.select_by_bctype_chdata(bctypet)
108 dt1 = datetime.datetime.strptime(chdatat[0][5], "%Y-%m-%d %H:%M:%S")-datetime.datetime.now()
109 dt1 = dt1.days * 24 * 60 * 60 + dt1.seconds
111 recdata = epgdb.searchtime2(title.decode('utf-8'), btime, "5", chtxt)
119 bt = datetime.datetime.strptime(btimen, "%Y-%m-%d %H:%M:%S")
120 et = datetime.datetime.strptime(etimen, "%Y-%m-%d %H:%M:%S")
121 btimen = bt.strftime("%Y-%m-%d %H:%M:%S")
122 etimen = et.strftime("%Y-%m-%d %H:%M:%S")
125 recdb.del_reckey(recdb.REC_RESERVE, title, chtxt, btime)
126 recdb.rec_reckey(recdb.REC_FINAL_RESERVE, titlen, chtxtn, btimen, etimen, opt)
127 recdb.rec_reclog(titlen, chtxtn, btimen, etimen, opt, exp, longexp, category)
128 auto_rec.add_key(chtxt, titlen,exp+" "+longexp)
129 auto_rec.add_key("ALL", titlen,exp+" "+longexp)
130 print "Oikake "+title+" : "+titlen+" "+btimen+" "+etimen
131 except Exception, inst:
132 print "Error happended in Oikake DB"
136 print "nothing match"
138 if rec10d.rec10db.select_by_bctype_chdata(bctypet)[0][6] != "0":
139 rec10d.rec10db.update_status_by_bctype_chdata(bctypet, "3")
143 recdb.del_reckey(recdb.REC_RESERVE, title, chtxt, btime)
144 recdb.rec_reckey(recdb.REC_FINAL_RESERVE, title, chtxt, btime, etime, opt)
145 except Exception, inst:
148 elif task["type"] == recdb.REC_KEYWORD:#"key,"+chtxt+","+keyword+","+btime+","+deltatime+","+opt
149 deltatime = task['deltatime']
151 recdata = epgdb.searchtime2(title.decode('utf-8'), btime, deltatime, chtxt)
160 bt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
161 et = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
162 btimet = bt.strftime("%Y-%m-%d %H:%M:%S")
163 etimet = et.strftime("%Y-%m-%d %H:%M:%S")
165 recdb.del_reckey(recdb.REC_KEYWORD, title, chtxt, btime)
166 recdb.rec_reckey(recdb.REC_RESERVE, titlet, chtxtt, btimet, etimet, opt)
167 recdb.rec_reclog(titlet, chtxtt, btimet, etimet, opt, exp,longexp,category)
168 auto_rec.add_key(chtxt, titlet,exp+" "+longexp)
169 auto_rec.add_key("ALL", titlet,exp+" "+longexp)
170 print "key "+title+" : "+titlet+" "+btimet+" "+etimet
171 except Exception, inst:
172 print "Error happened in REC_KEYWORD DB"
176 print "nothing match"
177 elif task["type"] == recdb.REC_KEYWORD_EVERY_SOME_DAYS:#"keyevery,"+chtxt+","+keyword+","+btime+","+deltatime+","+opt+","+deltaday
178 deltatime = task['deltatime']
179 deltaday = task['deltaday']
180 dd = datetime.timedelta(days=int(deltaday))
182 recdb.del_reckey(recdb.REC_KEYWORD_EVERY_SOME_DAYS, title, chtxt, btime)
185 btxt = bt.strftime("%Y-%m-%d %H:%M:%S")
186 etxt = et.strftime("%Y-%m-%d %H:%M:%S")
187 recdb.everyreserv(title, chtxt, btxt, etxt, deltatime, opt, deltaday)
189 recdb.keyreserv(title, chtxt, btime, etime, deltatime, opt)
190 recdb.del_reckey(recdb.REC_KEYWORD_EVERY_SOME_DAYS, title, chtxt, btime)
193 btxt = bt.strftime("%Y-%m-%d %H:%M:%S")
194 etxt = et.strftime("%Y-%m-%d %H:%M:%S")
195 recdb.everyreserv(title, chtxt, btxt, etxt, deltatime, opt, deltaday)
196 elif task["type"] == recdb.REC_FINAL_RESERVE:#"rec,"+chtxt+","+title+","+btime+","+etime+","+opt
198 if dt < 6 * 60 and dt > 0:
199 recdb.del_reckey(recdb.REC_FINAL_RESERVE, title, chtxt, btime)
200 recdb.rec_reckey(recdb.REC_TS_RECORDING, title, chtxt, btime, etime, opt)
201 print "録画開始 "+title+" "+btime+" "+etime
203 if pid != 0:#親プロセスの場合
208 testpath=[os.path.join(recpath,title+".ts.b25")]
209 testpath.append(os.path.join(recpath,title+".ts"))
210 testpath.append(os.path.join(recpath,title+".avi"))
211 testpath.append(os.path.join(recpath,title+".mkv"))
212 testpath.append(os.path.join(recpath,title+".log"))
215 if os.path.exists(ti):
218 ttitle=title+"_"+datetime.datetime.now().strftime("%Y%m%d%H%M")
219 tv2avi.timetv2b25(recpath + "/" + ttitle + ".avi", chtxt, btime, etime, opt)
220 recdb.del_reckey(recdb.REC_TS_RECORDING, title, chtxt, btime)
221 tnow = datetime.datetime.now()
222 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
223 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
225 bt = tnow + datetime.timedelta(seconds=600)
226 et = et + dt + datetime.timedelta(seconds=600)
227 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
228 etime = et.strftime("%Y-%m-%d %H:%M:%S")
229 recdb.rec_reckey(recdb.REC_TS_DECODE_QUE, ttitle, chtxt, btime, etime, opt)
231 elif task["type"] == recdb.REC_TS_DECODE_QUE:
235 if pid != 0:#親プロセスの場合
240 if status.getB25Decoding() < 2:
241 pin = recpath + "/" + title
242 recdb.del_reckey(recdb.REC_TS_DECODE_QUE, title, chtxt, btime)
243 recdb.rec_reckey(recdb.REC_TS_DECODING, title, chtxt, btime, etime, opt)
244 tv2avi.b252ts(pin, chtxt, btime, etime, opt)
245 recdb.del_reckey(recdb.REC_TS_DECODING, title, chtxt, btime)
246 if not os.access(recpath + "/" + title + ".ts", os.F_OK):
247 recdb.del_reckey(recdb.REC_TS_DECODING, title, chtxt, btime)
248 recdb.rec_reckey(recdb.REC_MISS_DECODE, title, chtxt, btime, etime, opt)
249 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
250 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
252 tnow = datetime.datetime.now()
253 bt = tnow + datetime.timedelta(seconds=900)
255 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
256 etime = et.strftime("%Y-%m-%d %H:%M:%S")
257 recdb.rec_reckey(recdb.REC_ENCODE_QUE, title, chtxt, btime, etime, opt)
258 #print checker.checkB25Decode(recpath + "/" + title + ".ts.b25", recpath + "/" + title + ".ts")
259 if checker.checkB25Decode(recpath + "/" + title + ".ts.b25", recpath + "/" + title + ".ts") == 1:
260 os.remove(recpath + "/" + title + ".ts.b25")
263 recdb.del_reckey(recdb.REC_TS_DECODE_QUE, title, chtxt, btime)
264 bt = bt + datetime.timedelta(seconds=600)
265 et = et + 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_ENCODE_QUE:
272 encodenum=encodenum+1
278 time.sleep(5*encodenum)
279 if status.getEncoding() < int(configreader.getenv("enc_max")):
281 pin = recpath + "/" + title + ".ts"
282 if re.search("d", opt):
283 pin = recpath + "/" + title + ".sa.avi"
284 if re.search("5", opt):
285 pin = recpath + "/" + title + ".sa.avi"
286 #pout = recpath + "/" + title + ".avi"
287 pout = recpath + "/" + title + ".mp4"
288 print [pin, pout, opt]
290 #print pin+":"+pout+":"+opt
291 recdb.del_reckey(recdb.REC_ENCODE_QUE, title, chtxt, btime)
292 recdb.rec_reckey(recdb.REC_ENCODE_LOCAL, title, chtxt, btime, etime, opt)
293 #tv2mkv.ts2mkv(pin, pout, opt)
294 tv2mp4.ts2mp4(pin, pout, opt)
295 #tv2avi.ts2avi(pin, pout, opt)
296 recdb.del_reckey(recdb.REC_ENCODE_LOCAL, title, chtxt, btime)
297 recdb.rec_reckey(recdb.REC_FIN_LOCAL, title, chtxt, btime, etime, opt)
300 recdb.del_reckey(recdb.REC_ENCODE_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_ENCODE_QUE, title, chtxt, btime, etime, opt)
307 elif task["type"] == recdb.REC_AVI_TO_MKV:
313 recdb.del_reckey(recdb.REC_AVI_TO_MKV, title, chtxt, btime)
314 recdb.rec_reckey(recdb.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
315 tv2mkv.avi2mkv(os.path.join(recpath,title+".avi"),os.path.join(recpath,title+".mkv"))
316 recdb.del_reckey(recdb.REC_CHANGING_CANTAINER, title, chtxt, btime)
318 elif task["type"] == recdb.REC_AVI_TO_MP4:
324 recdb.del_reckey(recdb.REC_AVI_TO_MP4, title, chtxt, btime)
325 recdb.rec_reckey(recdb.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
326 tv2mp4.avi2mp4(os.path.join(recpath,title+".avi"),os.path.join(recpath,title+".mp4"))
327 recdb.del_reckey(recdb.REC_CHANGING_CANTAINER, title, chtxt, btime)
329 elif task["type"] == recdb.REC_MKV_TO_MP4:
335 recdb.del_reckey(recdb.REC_AVI_TO_MP4, title, chtxt, btime)
336 recdb.rec_reckey(recdb.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
337 tv2mp4.mkv2mp4(os.path.join(recpath,title+".mkv"),os.path.join(recpath,title+".mp4"))
338 recdb.del_reckey(recdb.REC_CHANGING_CANTAINER, title, chtxt, btime)
340 elif task["type"] == recdb.REC_AUTO_KEYWORD:#"key,"+chtxt+","+keyword+","+btime+","+deltatime+","+opt
343 recdatum = epgdb.searchtime_auto(title.decode('utf-8'), btime, deltatime, chtxt)
344 for recdata in recdatum:
353 btt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
354 ett = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
355 btimet = btt.strftime("%Y-%m-%d %H:%M:%S")
356 etimet = ett.strftime("%Y-%m-%d %H:%M:%S")
358 recdb.rec_reckey(recdb.REC_AUTO_SUGGEST_REC, titlet, chtxtt, btimet, etimet, opt)
359 except Exception, inst:
362 dd = datetime.timedelta(days=1)
365 btxt = bt.strftime("%Y-%m-%d %H:%M:%S")
366 etxt = et.strftime("%Y-%m-%d %H:%M:%S")
368 recdb.del_reckey(recdb.REC_AUTO_KEYWORD, title, chtxt, btime)
369 recdb.auto_keyreserv(title, chtxt, btxt, etxt, "24", opt)
370 except Exception, inst:
373 elif task["type"] == recdb.REC_MOVE_AFTER_RECORD:#"res,"+chtxt+","+title+","+btime+","+etime+","+opt
374 if (dt < 58 * 60 and dt > 20 * 60):
376 if pid != 0:#親プロセスの場合
378 else:#子プロセスの場合 アップデートを行って終了
379 bctypet = chdb.chtxtsearch(chtxt)['bctype']
380 chdatat = rec10d.rec10db.select_by_bctype_chdata(bctypet)
381 dt1 = datetime.datetime.strptime(chdatat[0][5], "%Y-%m-%d %H:%M:%S")-datetime.datetime.now()
382 dt1 = dt1.days * 24 * 60 * 60 + dt1.seconds
384 recdata = epgdb.searchtime2(title.decode('utf-8'), btime, "5", chtxt)
392 bt = datetime.datetime.strptime(btimen, "%Y-%m-%d %H:%M:%S")
393 et = datetime.datetime.strptime(etimen, "%Y-%m-%d %H:%M:%S")
394 btimen = bt.strftime("%Y-%m-%d %H:%M:%S")
395 etimen = et.strftime("%Y-%m-%d %H:%M:%S")
398 recdb.del_reckey(recdb.REC_MOVE_AFTER_RECORD, title, chtxt, btime)
399 recdb.rec_reckey(recdb.REC_MOVE_AFTER_RECORD_FINAL, titlen, chtxtn, btimen, etimen, opt)
400 recdb.rec_reclog(titlen, chtxtn, btimen, etimen, opt, exp, longexp, category)
401 auto_rec.add_key(chtxt, titlen,exp+" "+longexp)
402 auto_rec.add_key("ALL", titlen,exp+" "+longexp)
403 print "Oikake "+title+" : "+titlen+" "+btimen+" "+etimen
404 except Exception, inst:
405 print "Error happended in Oikake DB"
409 print "nothing match"
411 if rec10d.rec10db.select_by_bctype_chdata(bctypet)[0][6] != "0":
412 rec10d.rec10db.update_status_by_bctype_chdata(bctypet, "3")
416 recdb.del_reckey(recdb.REC_MOVE_AFTER_RECORD, title, chtxt, btime)
417 recdb.rec_reckey(recdb.REC_MOVE_AFTER_RECORD_FINAL, title, chtxt, btime, etime, opt)
418 except Exception, inst:
421 elif task["type"] == recdb.REC_MOVE_AFTER_DECODE:#"res,"+chtxt+","+title+","+btime+","+etime+","+opt
422 if (dt < 58 * 60 and dt > 20 * 60):
424 if pid != 0:#親プロセスの場合
426 else:#子プロセスの場合 アップデートを行って終了
427 bctypet = chdb.chtxtsearch(chtxt)['bctype']
428 chdatat = rec10d.rec10db.select_by_bctype_chdata(bctypet)
429 dt1 = datetime.datetime.strptime(chdatat[0][5], "%Y-%m-%d %H:%M:%S")-datetime.datetime.now()
430 dt1 = dt1.days * 24 * 60 * 60 + dt1.seconds
432 recdata = epgdb.searchtime2(title.decode('utf-8'), btime, "5", chtxt)
440 bt = datetime.datetime.strptime(btimen, "%Y-%m-%d %H:%M:%S")
441 et = datetime.datetime.strptime(etimen, "%Y-%m-%d %H:%M:%S")
442 btimen = bt.strftime("%Y-%m-%d %H:%M:%S")
443 etimen = et.strftime("%Y-%m-%d %H:%M:%S")
446 recdb.del_reckey(recdb.REC_MOVE_AFTER_DECODE, title, chtxt, btime)
447 recdb.rec_reckey(recdb.REC_MOVE_AFTER_DECODE_FINAL, titlen, chtxtn, btimen, etimen, opt)
448 recdb.rec_reclog(titlen, chtxtn, btimen, etimen, opt, exp, longexp, category)
449 auto_rec.add_key(chtxt, titlen,exp+" "+longexp)
450 auto_rec.add_key("ALL", titlen,exp+" "+longexp)
451 print "Oikake "+title+" : "+titlen+" "+btimen+" "+etimen
452 except Exception, inst:
453 print "Error happended in Oikake DB"
457 print "nothing match"
459 if rec10d.rec10db.select_by_bctype_chdata(bctypet)[0][6] != "0":
460 rec10d.rec10db.update_status_by_bctype_chdata(bctypet, "3")
464 recdb.del_reckey(recdb.REC_MOVE_AFTER_DECODE, title, chtxt, btime)
465 recdb.rec_reckey(recdb.REC_MOVE_AFTER_DECODE_FINAL, title, chtxt, btime, etime, opt)
466 except Exception, inst:
469 elif task["type"] == recdb.REC_MOVE_AFTER_ENCODE:#"res,"+chtxt+","+title+","+btime+","+etime+","+opt
470 if (dt < 58 * 60 and dt > 20 * 60):
472 if pid != 0:#親プロセスの場合
474 else:#子プロセスの場合 アップデートを行って終了
475 bctypet = chdb.chtxtsearch(chtxt)['bctype']
476 chdatat = rec10d.rec10db.select_by_bctype_chdata(bctypet)
477 dt1 = datetime.datetime.strptime(chdatat[0][5], "%Y-%m-%d %H:%M:%S")-datetime.datetime.now()
478 dt1 = dt1.days * 24 * 60 * 60 + dt1.seconds
480 recdata = epgdb.searchtime2(title.decode('utf-8'), btime, "5", chtxt)
488 bt = datetime.datetime.strptime(btimen, "%Y-%m-%d %H:%M:%S")
489 et = datetime.datetime.strptime(etimen, "%Y-%m-%d %H:%M:%S")
490 btimen = bt.strftime("%Y-%m-%d %H:%M:%S")
491 etimen = et.strftime("%Y-%m-%d %H:%M:%S")
494 recdb.del_reckey(recdb.REC_MOVE_AFTER_ENCODE, title, chtxt, btime)
495 recdb.rec_reckey(recdb.REC_MOVE_AFTER_ENCODE_FINAL, titlen, chtxtn, btimen, etimen, opt)
496 recdb.rec_reclog(titlen, chtxtn, btimen, etimen, opt, exp, longexp, category)
497 auto_rec.add_key(chtxt, titlen,exp+" "+longexp)
498 auto_rec.add_key("ALL", titlen,exp+" "+longexp)
499 print "Oikake "+title+" : "+titlen+" "+btimen+" "+etimen
500 except Exception, inst:
501 print "Error happended in Oikake DB"
505 print "nothing match"
507 if rec10d.rec10db.select_by_bctype_chdata(bctypet)[0][6] != "0":
508 rec10d.rec10db.update_status_by_bctype_chdata(bctypet, "3")
512 recdb.del_reckey(recdb.REC_MOVE_AFTER_ENCODE, title, chtxt, btime)
513 recdb.rec_reckey(recdb.REC_MOVE_AFTER_ENCODE_FINAL, title, chtxt, btime, etime, opt)
514 except Exception, inst:
517 elif task["type"] == recdb.REC_MOVE_AFTER_RECORD_FINAL:#"rec,"+chtxt+","+title+","+btime+","+etime+","+opt
519 if dt < 6 * 60 and dt > 0:
520 recdb.del_reckey(recdb.REC_MOVE_AFTER_RECORD_FINAL, title, chtxt, btime)
521 recdb.rec_reckey(recdb.REC_MOVE_AFTER_RECORD_RECORDING, title, chtxt, btime, etime, opt)
522 print "録画開始 "+title+" "+btime+" "+etime
524 if pid != 0:#親プロセスの場合
529 testpath=[os.path.join(recpath,title+".ts.b25")]
530 testpath.append(os.path.join(recpath,title+".ts"))
531 testpath.append(os.path.join(recpath,title+".avi"))
532 testpath.append(os.path.join(recpath,title+".mkv"))
533 testpath.append(os.path.join(recpath,title+".log"))
536 if os.path.exists(ti):
539 ttitle=title+"_"+datetime.datetime.now().strftime("%Y%m%d%H%M")
540 tv2avi.timetv2b25(recpath + "/" + ttitle + ".avi", chtxt, btime, etime, opt)
541 recdb.del_reckey(recdb.REC_MOVE_AFTER_RECORD_RECORDING, title, chtxt, btime)
542 shutil.copy(os.path.join(recpath,title+".ts.b25"),os.path.join(movepath,title+".ts.b25"))
544 elif task["type"] == recdb.REC_MOVE_AFTER_DECODE_FINAL:#"rec,"+chtxt+","+title+","+btime+","+etime+","+opt
546 if dt < 6 * 60 and dt > 0:
547 recdb.del_reckey(recdb.REC_MOVE_AFTER_DECODE_FINAL, title, chtxt, btime)
548 recdb.rec_reckey(recdb.REC_MOVE_AFTER_DECODE_RECORDING, title, chtxt, btime, etime, opt)
549 print "録画開始 "+title+" "+btime+" "+etime
551 if pid != 0:#親プロセスの場合
556 testpath=[os.path.join(recpath,title+".ts.b25")]
557 testpath.append(os.path.join(recpath,title+".ts"))
558 testpath.append(os.path.join(recpath,title+".avi"))
559 testpath.append(os.path.join(recpath,title+".mkv"))
560 testpath.append(os.path.join(recpath,title+".log"))
563 if os.path.exists(ti):
566 ttitle=title+"_"+datetime.datetime.now().strftime("%Y%m%d%H%M")
567 tv2avi.timetv2b25(recpath + "/" + ttitle + ".avi", chtxt, btime, etime, opt)
568 recdb.del_reckey(recdb.REC_MOVE_AFTER_DECODE_RECORDING, title, chtxt, btime)
569 tnow = datetime.datetime.now()
570 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
571 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
573 bt = tnow + datetime.timedelta(seconds=600)
574 et = et + dt + datetime.timedelta(seconds=600)
575 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
576 etime = et.strftime("%Y-%m-%d %H:%M:%S")
577 recdb.rec_reckey(recdb.REC_MOVE_AFTER_DECODE_DECODE_QUE, ttitle, chtxt, btime, etime, opt)
579 elif task["type"] == recdb.REC_MOVE_AFTER_ENCODE_FINAL:#"rec,"+chtxt+","+title+","+btime+","+etime+","+opt
581 if dt < 6 * 60 and dt > 0:
582 recdb.del_reckey(recdb.REC_MOVE_AFTER_ENCODE_FINAL, title, chtxt, btime)
583 recdb.rec_reckey(recdb.REC_MOVE_AFTER_ENCODE_RECORDING, title, chtxt, btime, etime, opt)
584 print "録画開始 "+title+" "+btime+" "+etime
586 if pid != 0:#親プロセスの場合
591 testpath=[os.path.join(recpath,title+".ts.b25")]
592 testpath.append(os.path.join(recpath,title+".ts"))
593 testpath.append(os.path.join(recpath,title+".avi"))
594 testpath.append(os.path.join(recpath,title+".mkv"))
595 testpath.append(os.path.join(recpath,title+".log"))
598 if os.path.exists(ti):
601 ttitle=title+"_"+datetime.datetime.now().strftime("%Y%m%d%H%M")
602 tv2avi.timetv2b25(recpath + "/" + ttitle + ".avi", chtxt, btime, etime, opt)
603 recdb.del_reckey(recdb.REC_MOVE_AFTER_ENCODE_RECORDING, title, chtxt, btime)
604 tnow = datetime.datetime.now()
605 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
606 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
608 bt = tnow + datetime.timedelta(seconds=600)
609 et = et + dt + datetime.timedelta(seconds=600)
610 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
611 etime = et.strftime("%Y-%m-%d %H:%M:%S")
612 recdb.rec_reckey(recdb.REC_MOVE_AFTER_DECODE_DECODE_QUE, ttitle, chtxt, btime, etime, opt)
614 elif task["type"] == recdb.REC_MOVE_AFTER_DECODE_DECODE_QUE:
618 if pid != 0:#親プロセスの場合
623 if status.getB25Decoding() < 2:
624 pin = recpath + "/" + title
625 recdb.del_reckey(recdb.REC_MOVE_AFTER_DECODE_DECODE_QUE, title, chtxt, btime)
626 recdb.rec_reckey(recdb.REC_MOVE_AFTER_DECODE_DECODING, title, chtxt, btime, etime, opt)
627 tv2avi.b252ts(pin, chtxt, btime, etime, opt)
628 recdb.del_reckey(recdb.REC_MOVE_AFTER_DECODE_DECODING, title, chtxt, btime)
629 if not os.access(recpath + "/" + title + ".ts", os.F_OK):
630 recdb.del_reckey(recdb.REC_MOVE_AFTER_DECODE_DECODING, title, chtxt, btime)
631 recdb.rec_reckey(recdb.REC_MISS_DECODE, title, chtxt, btime, etime, opt)
632 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
633 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
635 tnow = datetime.datetime.now()
636 bt = tnow + datetime.timedelta(seconds=900)
638 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
639 etime = et.strftime("%Y-%m-%d %H:%M:%S")
640 shutil.copy(os.path.join(recpath,title+".ts"),os.path.join(movepath,title+".ts"))
642 recdb.del_reckey(recdb.REC_MOVE_AFTER_DECODE_DECODE_QUE, title, chtxt, btime)
643 bt = bt + datetime.timedelta(seconds=600)
644 et = et + datetime.timedelta(seconds=600)
645 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
646 etime = et.strftime("%Y-%m-%d %H:%M:%S")
647 recdb.rec_reckey(recdb.REC_MOVE_AFTER_DECODE_DECODE_QUE, title, chtxt, btime, etime, opt)
649 elif task["type"] == recdb.REC_MOVE_AFTER_ENCODE_DECODE_QUE:
653 if pid != 0:#親プロセスの場合
658 if status.getB25Decoding() < 2:
659 pin = recpath + "/" + title
660 recdb.del_reckey(recdb.REC_MOVE_AFTER_ENCODE_DECODE_QUE, title, chtxt, btime)
661 recdb.rec_reckey(recdb.REC_MOVE_AFTER_ENCODE_DECODING, title, chtxt, btime, etime, opt)
662 tv2avi.b252ts(pin, chtxt, btime, etime, opt)
663 recdb.del_reckey(recdb.REC_MOVE_AFTER_DECODE_DECODING, title, chtxt, btime)
664 if not os.access(recpath + "/" + title + ".ts", os.F_OK):
665 recdb.del_reckey(recdb.REC_MOVE_AFTER_ENCODE_DECODING, title, chtxt, btime)
666 recdb.rec_reckey(recdb.REC_MISS_DECODE, title, chtxt, btime, etime, opt)
667 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
668 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
670 tnow = datetime.datetime.now()
671 bt = tnow + datetime.timedelta(seconds=900)
673 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
674 etime = et.strftime("%Y-%m-%d %H:%M:%S")
675 recdb.rec_reckey(recdb.REC_MOVE_AFTER_ENCODE_ENCODE_QUE, title, chtxt, btime, etime, opt)
676 #print checker.checkB25Decode(recpath + "/" + title + ".ts.b25", recpath + "/" + title + ".ts")
677 if checker.checkB25Decode(recpath + "/" + title + ".ts.b25", recpath + "/" + title + ".ts") == 1:
678 os.remove(recpath + "/" + title + ".ts.b25")
681 recdb.del_reckey(recdb.REC_MOVE_AFTER_ENCODE_DECODE_QUE, title, chtxt, btime)
682 bt = bt + datetime.timedelta(seconds=600)
683 et = et + datetime.timedelta(seconds=600)
684 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
685 etime = et.strftime("%Y-%m-%d %H:%M:%S")
686 recdb.rec_reckey(recdb.REC_MOVE_AFTER_ENCODE_DECODE_QUE, title, chtxt, btime, etime, opt)
688 elif task["type"] == recdb.REC_MOVE_AFTER_ENCODE_ENCODE_QUE:
690 encodenum=encodenum+1
696 time.sleep(5*encodenum)
697 if status.getEncoding() < int(configreader.getenv("enc_max")):
699 pin = recpath + "/" + title + ".ts"
700 if re.search("d", opt):
701 pin = recpath + "/" + title + ".sa.avi"
702 if re.search("5", opt):
703 pin = recpath + "/" + title + ".sa.avi"
704 #pout = recpath + "/" + title + ".avi"
705 pout = recpath + "/" + title + ".mp4"
706 print [pin, pout, opt]
708 #print pin+":"+pout+":"+opt
709 recdb.del_reckey(recdb.REC_MOVE_AFTER_ENCODE_ENCODE_QUE, title, chtxt, btime)
710 recdb.rec_reckey(recdb.REC_MOVE_AFTER_ENCODE_ENCODING, title, chtxt, btime, etime, opt)
711 #tv2mkv.ts2mkv(pin, pout, opt)
712 tv2mp4.ts2mp4(pin, pout, opt)
713 #tv2avi.ts2avi(pin, pout, opt)
714 recdb.del_reckey(recdb.REC_MOVE_AFTER_ENCODE_ENCODING, title, chtxt, btime)
715 recdb.rec_reckey(recdb.REC_FIN_LOCAL, title, chtxt, btime, etime, opt)
716 shutil.copy(os.path.join(recpath,title+".mp4"),os.path.join(movepath,title+".mp4"))
719 recdb.del_reckey(recdb.REC_ENCODE_QUE, title, chtxt, btime)
720 bt = bt + datetime.timedelta(seconds=600)
721 et = et + datetime.timedelta(seconds=600)
722 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
723 etime = et.strftime("%Y-%m-%d %H:%M:%S")
724 recdb.rec_reckey(recdb.REC_ENCODE_QUE, title, chtxt, btime, etime, opt)
727 def search_keyword(key):
728 tnow = datetime.datetime.now()
729 nows =tnow.strftime("%Y-%m-%d %H:%M:%S")
731 recdatum = epgdb.searchtime_auto(k.decode('utf-8'),nows, "144")
732 for recdata in recdatum:
738 btt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
739 ett = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
740 btimet = btt.strftime("%Y-%m-%d %H:%M:%S")
741 etimet = ett.strftime("%Y-%m-%d %H:%M:%S")
743 recdb.rec_reckey(recdb.REC_AUTO_SUGGEST_REC, titlet, chtxtt, btimet, etimet,"")
744 except Exception, inst: