OSDN Git Service

implement move after process.
authorgn64_jp <gn64_jp@4e526526-5e11-4fc0-8910-f8fd03428081>
Sat, 21 Nov 2009 14:31:29 +0000 (14:31 +0000)
committergn64_jp <gn64_jp@4e526526-5e11-4fc0-8910-f8fd03428081>
Sat, 21 Nov 2009 14:31:29 +0000 (14:31 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/rec10@229 4e526526-5e11-4fc0-8910-f8fd03428081

rec10/trunk/src/auto_process.py
rec10/trunk/src/config.ini
rec10/trunk/src/dbMySQL.py
rec10/trunk/src/recdb.py
rec10/trunk/src/timerec.py

index 6663893..f001cad 100644 (file)
@@ -1,3 +1,4 @@
+import recdb
 #!/usr/bin/python
 # coding: UTF-8
 # Rec10 TS Recording Tools
@@ -6,6 +7,8 @@ import os
 import glob
 import time
 
+import rec10d
+import os.path
 import tv2mp4
 def Update_to_MP4(path):
     """
@@ -46,4 +49,70 @@ def Update_to_MP4(path):
                             mkvdtime = int(time.time()-os.path.getmtime(mkvpath))
                             if mkvdtime>300:
                                 print mkvpath+":"+mp4path
-                                tv2mp4.mkv2mp4(mkvpath,mp4path)
\ No newline at end of file
+                                tv2mp4.mkv2mp4(mkvpath,mp4path)
+def auto_check(path):
+    avilist = glob.glob(path + "/*.avi")
+    mkvlist = glob.glob(path+"/*.mkv")
+    tslist = glob.glob(path+"/*.ts")
+    b25list = glob.glob(path+"/*.ts.b25")
+    filelist=avilist+mkvlist+mp4list+tslist+b25list
+    rec10d.rec10db.new_procstatus()
+    for fn in filelist:
+        if fn.rfind("sa.avi")==-1:
+            dir = os.path.split(fn)[0]
+            file = os.path.split(fn)[1]
+            title = os.path.splitext(file)[0]
+            ext = os.path.splitext(file)[1]
+            if ext == "b25":
+                title=title.replace(".ts","")
+            proc=check_process(dir, title)
+            if proc=="b25":
+                rec10d.rec10db.add_procstatus(recdb.REC_AUTO_SUGGEST_DECODE,title)
+            elif proc=="ts":
+                rec10d.rec10db.add_procstatus(recdb.REC_AUTO_SUGGEST_ENCODE,title)
+            elif proc =="avi":
+                rec10d.rec10db.add_procstatus(recdb.REC_AUTO_SUGGEST_AVI2MP4,title)
+            elif proc =="mkv":
+                rec10d.rec10db.add_procstatus(recdb.REC_AUTO_SUGGEST_MKV2MP4,title)
+"""
+    処理がどの段階まで言ったのかを調査し返す。
+    return
+    recording
+    b25
+    b25decoding
+    tssplitting
+    ts
+    encoding
+    avi
+    mp4making
+    mp4
+"""
+def check_process(path,title):
+    path1 = os.path.join(path,title+".mp4")
+    if os.path.exists(path1):
+        if int(time.time()-os.path.getmtime(path1))>300:
+            return "mp4"
+        else:
+            return "mp4making"
+    elif os.path.exists(os.path.join(path,title+".avi")):
+        if int(time.time()-os.path.getmtime(os.path.join(path,title+".avi")))>300:
+            return "avi"
+        else:
+            return "encoding"
+    elif os.path.exists(os.path.join(path,title+".ts")):
+        if int(time.time()-os.path.getmtime(os.path.join(path,title+".ts")))>300:
+            return "ts"
+        else:
+            return "tssplitting"
+    elif os.path.exists(os.path.join(path,title+".sa.avi")):
+        if int(time.time()-os.path.getmtime(os.path.join(path,title+".sa.avi")))>300:
+            return "ts"
+        else:
+            return "tssplitting"
+    elif os.path.exists(os.path.join(path,title+".ts.b25")):
+        if int(time.time()-os.path.getmtime(os.path.join(path,title+".ts.b25")))>300:
+            return "b25"
+        else:
+            return "recording"
+    
+
index 927666d..56660c5 100644 (file)
@@ -9,6 +9,8 @@ rec10 = /
 recpath = /path of /recording
 #録画終了後に動画を置いておくフォルダを指定するとrectool.plでリスト化できます。
 recorded = /path of /recordedpath
+複数のrec10で役割を分担するときに用いる移動先
+move_destpath =
 epgdump = 
 tssplitter =
 MP4Box =
index 1a2d0c1..dec6be7 100644 (file)
@@ -220,6 +220,33 @@ class DB_MySQL:
                       (status, bctype)\
                       )
         self.close_db(db)
+
+    def add_procstatus(self,type,title):
+        db = self.connect_db()
+        db[1].execute('\
+        INSERT IGNORE into procstatus \
+        (type,title) \
+        values (%s,%s)', \
+                      ( type, title))
+        ##db.commit()
+        self.close_db(db)
+    def new_procstatus(self):
+        db = self.connect_db()
+        try:
+            db[1].execute('drop table procstatus')
+        except:
+            ""
+        try:
+            db[1].execute('\
+            CREATE TABLE procstatus \
+            (\
+            type VARCHAR(20),\
+            title VARCHAR(100) PRIMARY KEY,\
+            UNIQUE unibayeskey(title)\
+            )')
+        except:
+            ""
+        self.close_db(db)
     def add_reclog(self , chtxt="", title="", btime="", etime="", opt="", exp="", longexp="", category=""):
         db = self.connect_db()
         db[1].execute('\
index 89369ed..fb5dd10 100644 (file)
@@ -28,7 +28,31 @@ global REC_AVI_TO_MKV
 global REC_AVI_TO_MP4
 global REC_MKV_TO_MP4
 global REC_CHANGING_CANTAINER
-global REC_AUTO_SUGGEST
+
+#ここから処理のちに移動
+global REC_MOVE_AFTER_RECORD
+global REC_MOVE_AFTER_RECORD_FINAL
+global REC_MOVE_AFTER_RECORD_RECORDING
+global REC_MOVE_AFTER_DECODE
+global REC_MOVE_AFTER_DECODE_FINAL
+global REC_MOVE_AFTER_DECODE_RECORDING
+global REC_MOVE_AFTER_DECODE_DECODE_QUE
+global REC_MOVE_AFTER_DECODE_DECODING
+global REC_MOVE_AFTER_ENCODE
+global REC_MOVE_AFTER_ENCODE_FINAL
+global REC_MOVE_AFTER_ENCODE_RECORDING
+global REC_MOVE_AFTER_ENCODE_DECODE_QUE
+global REC_MOVE_AFTER_ENCODE_DECODING
+global REC_MOVE_AFTER_ENCODE_ENCODE_QUE
+global REC_MOVE_AFTER_ENCODE_ENCODING
+global REC_MOVE_END
+
+#ここから自動で提起される処理。
+global REC_AUTO_SUGGEST_REC
+global REC_AUTO_SUGGEST_DECODE
+global REC_AUTO_SUGGEST_ENCODE
+global REC_AUTO_SUGGEST_AVI2MP4
+global REC_AUTO_SUGGEST_MKV2MP4
 global REC_BAYES_SUGGEST
 global REC_AUTO_KEYWORD
 REC_RESERVE = "res"
@@ -51,9 +75,32 @@ REC_CHANGING_CANTAINER = "changingcontainer"
 REC_AVI_TO_MKV = "avi2mkv"
 REC_AVI_TO_MP4 = "avi2mp4"
 REC_MKV_TO_MP4 = "mkv2mp4"
-REC_AUTO_SUGGEST = "auto_suggest"
+
+REC_MOVE_AFTER_RECORD = "move_rec"
+REC_MOVE_AFTER_RECORD_FINAL = "move_rec_final"
+REC_MOVE_AFTER_RECORD_RECORDING ="move_rec_recording"
+REC_MOVE_AFTER_DECODE = "move_dec"
+REC_MOVE_AFTER_DECODE_FINAL = "move_dec_final"
+REC_MOVE_AFTER_DECODE_RECORDING = "move_dec_recording"
+REC_MOVE_AFTER_DECODE_DECODE_QUE ="move_dec_que"
+REC_MOVE_AFTER_DECODE_DECODING = "move_dec_decoding"
+REC_MOVE_AFTER_ENCODE = "move_enc"
+REC_MOVE_AFTER_ENCODE_FINAL = "move_enc_final"
+REC_MOVE_AFTER_ENCODE_RECORDING = "move_enc_recording"
+REC_MOVE_AFTER_ENCODE_DECODE_QUE = "move_enc_decque"
+REC_MOVE_AFTER_ENCODE_DECODING = "move_enc_decoding"
+REC_MOVE_AFTER_ENCODE_ENCODE_QUE = "move_enc_encque"
+REC_MOVE_AFTER_ENCODE_ENCODING = "move_enc_encoding"
+REC_MOVE_END = "move_end"
+
+REC_AUTO_SUGGEST_REC = "auto_suggest_rec"
+REC_AUTO_SUGGEST_DECODE = "auto_suggest_dec"
+REC_AUTO_SUGGEST_ENCODE = "auto_suggest_enc"
+REC_AUTO_SUGGEST_AVI2MP4 = "auto_suggest_a24"
+REC_AUTO_SUGGEST_MKV2MP4 = "auto_suggest_m24"
 REC_AUTO_KEYWORD = "auto_keyword"
 REC_BAYES_SUGGEST ="bayes_suggest"
+
 def recreserv(title, chtxt, btime, etime, opt):#optにはa(アニメ)d(副音声)v(xvid)
     rec_reckey("res", title, chtxt, btime, etime, opt)
 def auto_keyreserv(keyword, chtxt, btime, etime, deltatime, opt):
index 55604c4..972bb09 100644 (file)
@@ -7,6 +7,7 @@ import os
 import re
 import sys
 import time
+import shutil
 
 import auto_rec
 import chdb
@@ -20,6 +21,7 @@ import tv2avi
 import tv2mkv
 import tv2mp4
 recpath = configreader.getpath('recpath')
+movepath = configreader.getpath('move_destpath')
 path = str(os.path.dirname(os.path.abspath(__file__))) + "/"
 def task():
     """
@@ -353,7 +355,7 @@ def task():
                         btimet = btt.strftime("%Y-%m-%d %H:%M:%S")
                         etimet = ett.strftime("%Y-%m-%d %H:%M:%S")
                         try:
-                            recdb.rec_reckey(recdb.REC_AUTO_SUGGEST, titlet, chtxtt, btimet, etimet, opt)
+                            recdb.rec_reckey(recdb.REC_AUTO_SUGGEST_REC, titlet, chtxtt, btimet, etimet, opt)
                         except Exception, inst:
                             print type(inst)
                             print inst
@@ -368,6 +370,338 @@ def task():
                 except Exception, inst:
                     print type(inst)
                     print inst
+        elif task["type"] == recdb.REC_MOVE_AFTER_RECORD:#"res,"+chtxt+","+title+","+btime+","+etime+","+opt
+            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(recdb.REC_MOVE_AFTER_RECORD, title, chtxt, btime)
+                                recdb.rec_reckey(recdb.REC_MOVE_AFTER_RECORD_FINAL, 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 task["type"] == recdb.REC_MOVE_AFTER_DECODE:#"res,"+chtxt+","+title+","+btime+","+etime+","+opt
+            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(recdb.REC_MOVE_AFTER_DECODE, title, chtxt, btime)
+                                recdb.rec_reckey(recdb.REC_MOVE_AFTER_DECODE_FINAL, 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 task["type"] == recdb.REC_MOVE_AFTER_ENCODE:#"res,"+chtxt+","+title+","+btime+","+etime+","+opt
+            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(recdb.REC_MOVE_AFTER_ENCODE, title, chtxt, btime)
+                                recdb.rec_reckey(recdb.REC_MOVE_AFTER_ENCODE_FINAL, 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 task["type"] == recdb.REC_MOVE_AFTER_RECORD_FINAL:#"rec,"+chtxt+","+title+","+btime+","+etime+","+opt
+            print dt
+            if dt < 6 * 60 and dt > 0:
+                recdb.del_reckey(recdb.REC_MOVE_AFTER_RECORD_FINAL, title, chtxt, btime)
+                recdb.rec_reckey(recdb.REC_MOVE_AFTER_RECORD_RECORDING, 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(recdb.REC_MOVE_AFTER_RECORD_RECORDING, title, chtxt, btime)
+                    shutil.copy(os.path.join(recpath,title+".ts.b25"),os.path.join(movepath,title+".ts.b25"))
+                    sys.exit()
+        elif task["type"] == recdb.REC_MOVE_AFTER_DECODE_FINAL:#"rec,"+chtxt+","+title+","+btime+","+etime+","+opt
+            print dt
+            if dt < 6 * 60 and dt > 0:
+                recdb.del_reckey(recdb.REC_MOVE_AFTER_DECODE_FINAL, title, chtxt, btime)
+                recdb.rec_reckey(recdb.REC_MOVE_AFTER_DECODE_RECORDING, 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(recdb.REC_MOVE_AFTER_DECODE_RECORDING, title, chtxt, btime)
+                    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(recdb.REC_MOVE_AFTER_DECODE_DECODE_QUE, ttitle, chtxt, btime, etime, opt)
+                    sys.exit()
+        elif task["type"] == recdb.REC_MOVE_AFTER_ENCODE_FINAL:#"rec,"+chtxt+","+title+","+btime+","+etime+","+opt
+            print dt
+            if dt < 6 * 60 and dt > 0:
+                recdb.del_reckey(recdb.REC_MOVE_AFTER_ENCODE_FINAL, title, chtxt, btime)
+                recdb.rec_reckey(recdb.REC_MOVE_AFTER_ENCODE_RECORDING, 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(recdb.REC_MOVE_AFTER_ENCODE_RECORDING, title, chtxt, btime)
+                    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(recdb.REC_MOVE_AFTER_DECODE_DECODE_QUE, ttitle, chtxt, btime, etime, opt)
+                    sys.exit()
+        elif task["type"] == recdb.REC_MOVE_AFTER_DECODE_DECODE_QUE:
+            if dt < 10 * 60:
+                b25num=b25num+1
+                pid = os.fork()
+                if pid != 0:#親プロセスの場合
+                    ""
+                else:
+                    if b25num>1:
+                        time.sleep(5*b25num)
+                    if status.getB25Decoding() < 2:
+                        pin = recpath + "/" + title
+                        recdb.del_reckey(recdb.REC_MOVE_AFTER_DECODE_DECODE_QUE, title, chtxt, btime)
+                        recdb.rec_reckey(recdb.REC_MOVE_AFTER_DECODE_DECODING, title, chtxt, btime, etime, opt)
+                        tv2avi.b252ts(pin, chtxt, btime, etime, opt)
+                        recdb.del_reckey(recdb.REC_MOVE_AFTER_DECODE_DECODING, title, chtxt, btime)
+                        if not os.access(recpath + "/" + title + ".ts", os.F_OK):
+                            recdb.del_reckey(recdb.REC_MOVE_AFTER_DECODE_DECODING, title, chtxt, btime)
+                            recdb.rec_reckey(recdb.REC_MISS_DECODE, title, chtxt, btime, etime, opt)
+                        bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
+                        et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
+                        dt = et-bt
+                        tnow = datetime.datetime.now()
+                        bt = tnow + datetime.timedelta(seconds=900)
+                        et = bt + dt
+                        btime = bt.strftime("%Y-%m-%d %H:%M:%S")
+                        etime = et.strftime("%Y-%m-%d %H:%M:%S")
+                        shutil.copy(os.path.join(recpath,title+".ts"),os.path.join(movepath,title+".ts"))
+                    else:
+                        recdb.del_reckey(recdb.REC_MOVE_AFTER_DECODE_DECODE_QUE, title, chtxt, btime)
+                        bt = bt + datetime.timedelta(seconds=600)
+                        et = et + 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(recdb.REC_MOVE_AFTER_DECODE_DECODE_QUE, title, chtxt, btime, etime, opt)
+                        sys.exit()
+        elif task["type"] == recdb.REC_MOVE_AFTER_ENCODE_DECODE_QUE:
+            if dt < 10 * 60:
+                b25num=b25num+1
+                pid = os.fork()
+                if pid != 0:#親プロセスの場合
+                    ""
+                else:
+                    if b25num>1:
+                        time.sleep(5*b25num)
+                    if status.getB25Decoding() < 2:
+                        pin = recpath + "/" + title
+                        recdb.del_reckey(recdb.REC_MOVE_AFTER_ENCODE_DECODE_QUE, title, chtxt, btime)
+                        recdb.rec_reckey(recdb.REC_MOVE_AFTER_ENCODE_DECODING, title, chtxt, btime, etime, opt)
+                        tv2avi.b252ts(pin, chtxt, btime, etime, opt)
+                        recdb.del_reckey(recdb.REC_MOVE_AFTER_DECODE_DECODING, title, chtxt, btime)
+                        if not os.access(recpath + "/" + title + ".ts", os.F_OK):
+                            recdb.del_reckey(recdb.REC_MOVE_AFTER_ENCODE_DECODING, title, chtxt, btime)
+                            recdb.rec_reckey(recdb.REC_MISS_DECODE, title, chtxt, btime, etime, opt)
+                        bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
+                        et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
+                        dt = et-bt
+                        tnow = datetime.datetime.now()
+                        bt = tnow + datetime.timedelta(seconds=900)
+                        et = bt + dt
+                        btime = bt.strftime("%Y-%m-%d %H:%M:%S")
+                        etime = et.strftime("%Y-%m-%d %H:%M:%S")
+                        recdb.rec_reckey(recdb.REC_MOVE_AFTER_ENCODE_ENCODE_QUE, title, chtxt, btime, etime, opt)
+                        #print checker.checkB25Decode(recpath + "/" + title + ".ts.b25", recpath + "/" + title + ".ts")
+                        if checker.checkB25Decode(recpath + "/" + title + ".ts.b25", recpath + "/" + title + ".ts") == 1:
+                            os.remove(recpath + "/" + title + ".ts.b25")
+                        sys.exit()
+                    else:
+                        recdb.del_reckey(recdb.REC_MOVE_AFTER_ENCODE_DECODE_QUE, title, chtxt, btime)
+                        bt = bt + datetime.timedelta(seconds=600)
+                        et = et + 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(recdb.REC_MOVE_AFTER_ENCODE_DECODE_QUE, title, chtxt, btime, etime, opt)
+                        sys.exit()
+        elif task["type"] == recdb.REC_MOVE_AFTER_ENCODE_ENCODE_QUE:
+            if dt < 10 * 60:
+                encodenum=encodenum+1
+                pid = os.fork()
+                if pid > 0:#親プロセスの場合
+                    ""
+                else:
+                    if encodenum>1:
+                        time.sleep(5*encodenum)
+                    if status.getEncoding() < int(configreader.getenv("enc_max")):
+                        print opt
+                        pin = recpath + "/" + title + ".ts"
+                        if re.search("d", opt):
+                            pin = recpath + "/" + title + ".sa.avi"
+                        if re.search("5", opt):
+                            pin = recpath + "/" + title + ".sa.avi"
+                        #pout = recpath + "/" + title + ".avi"
+                        pout = recpath + "/" + title + ".mp4"
+                        print [pin, pout, opt]
+                        print pin
+                        #print pin+":"+pout+":"+opt
+                        recdb.del_reckey(recdb.REC_MOVE_AFTER_ENCODE_ENCODE_QUE, title, chtxt, btime)
+                        recdb.rec_reckey(recdb.REC_MOVE_AFTER_ENCODE_ENCODING, title, chtxt, btime, etime, opt)
+                        #tv2mkv.ts2mkv(pin, pout, opt)
+                        tv2mp4.ts2mp4(pin, pout, opt)
+                        #tv2avi.ts2avi(pin, pout, opt)
+                        recdb.del_reckey(recdb.REC_MOVE_AFTER_ENCODE_ENCODING, title, chtxt, btime)
+                        recdb.rec_reckey(recdb.REC_FIN_LOCAL, title, chtxt, btime, etime, opt)
+                        shutil.copy(os.path.join(recpath,title+".mp4"),os.path.join(movepath,title+".mp4"))
+                        sys.exit()
+                    else:
+                        recdb.del_reckey(recdb.REC_ENCODE_QUE, title, chtxt, btime)
+                        bt = bt + datetime.timedelta(seconds=600)
+                        et = et + 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(recdb.REC_ENCODE_QUE, title, chtxt, btime, etime, opt)
+                        sys.exit()
     sys.exit()
 def search_keyword(key):
     tnow = datetime.datetime.now()
@@ -385,7 +719,7 @@ def search_keyword(key):
                 btimet = btt.strftime("%Y-%m-%d %H:%M:%S")
                 etimet = ett.strftime("%Y-%m-%d %H:%M:%S")
                 try:
-                    recdb.rec_reckey(recdb.REC_AUTO_SUGGEST, titlet, chtxtt, btimet, etimet,"")
+                    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