OSDN Git Service

convert CRLF to LF
[rec10/rec10-git.git] / rec10 / trunk / src / auto_process.py
index 5523768..fabee05 100644 (file)
-#!/usr/bin/python\r
-# coding: UTF-8\r
-# Rec10 TS Recording Tools\r
-# Copyright (C) 2009-2011 Yukikaze\r
-import os\r
-import glob\r
-import time\r
-import datetime\r
-import commands\r
-import re\r
-import os.path\r
-\r
-import chdb\r
-import status\r
-import configreader\r
-import recdblist\r
-import rec10d\r
-import tv2mp4\r
-import epgdb\r
-def updateToMP4(path):\r
-    """\r
-    !現在未使用!\r
-    録画一時フォルダ内mp4ファイルを検索\r
-    """\r
-    avilist = glob.glob(path + "/*.avi")\r
-    mkvlist = glob.glob(path+"/*.mkv")\r
-    avilist=avilist+mkvlist\r
-    for avif in avilist:\r
-        if avif.rfind("sa.avi")==-1:\r
-            dir = os.path.split(avif)[0]\r
-            title = os.path.split(avif)[1]\r
-            title = title.replace(".avi", "")\r
-            title = title.replace(".mkv", "")\r
-            avipath = os.path.join(dir, title + ".avi")\r
-            mkvpath = os.path.join(dir, title + ".mkv")\r
-            mp4path = os.path.join(dir, title + ".mp4")\r
-            if not os.path.exists(mp4path):\r
-                if os.path.exists(avipath):\r
-                    avidtime = int(time.time()-os.path.getmtime(avipath))\r
-                    if avidtime>300:\r
-                        if os.path.exists(mkvpath):\r
-                            mkvdtime = int(time.time()-os.path.getmtime(mkvpath))\r
-                            if mkvdtime>300:\r
-                                recdblist.printutf8(mkvpath+":"+mp4path)\r
-                                tv2mp4.mkv2mp4(mkvpath,mp4path)\r
-                            else:\r
-                                recdblist.printutf8(avipath+":"+mp4path)\r
-                                tv2mp4.avi2mp4(avipath,mp4path)\r
-                        else:\r
-                            recdblist.printutf8(avipath+":"+mp4path)\r
-                            tv2mp4.avi2mp4(avipath,mp4path)\r
-                else:\r
-                    if not os.path.exists(avipath):\r
-                        if os.path.exists(mkvpath):\r
-                            mkvdtime = int(time.time()-os.path.getmtime(mkvpath))\r
-                            if mkvdtime>300:\r
-                                recdblist.printutf8(mkvpath+":"+mp4path)\r
-                                tv2mp4.mkv2mp4(mkvpath,mp4path)\r
-def autoCheck(path):\r
-    avilist = glob.glob(path + "/*.avi")\r
-    mkvlist = glob.glob(path+"/*.mkv")\r
-    mp4list = glob.glob(path+"/*.mp4")\r
-    tslist = glob.glob(path+"/*.ts")\r
-    b25list = glob.glob(path+"/*.ts.b25")\r
-    filelist=avilist+mkvlist+tslist+b25list+mp4list\r
-    add=[]\r
-    tbtime=datetime.datetime.now()+datetime.timedelta(seconds=60)\r
-    tbtime2=datetime.datetime.now()+datetime.timedelta(seconds=1200)\r
-    for fn in filelist:\r
-        if os.path.exists(fn):\r
-            if fn.rfind("sa.avi")==-1 and fn.rfind(".120.avi")==-1 and os.path.getsize(fn)>1*1000*1000:\r
-                dir = os.path.split(fn)[0]\r
-                file = os.path.split(fn)[1]\r
-                title = os.path.splitext(file)[0]\r
-                title = unicode(title,'utf-8',errors='replace')\r
-                ext = os.path.splitext(file)[1]\r
-                if ext == ".b25":\r
-                    title=title.replace(".ts","")\r
-                dbs=rec10d.rec10db.select_by_name_time_timeline(title,tbtime,tbtime2)\r
-                if len(dbs)==0:\r
-                    proc=checkProcess(dir, title)\r
-                    chtxtt=rec10d.rec10db.select_chtxt_by_title_timeline_log(title)\r
-                    nchtxt=""\r
-                    if chtxtt!=None:\r
-                        nchtxt=chtxtt\r
-                    if proc=="b25":\r
-                        add.append([recdblist.REC_AUTO_SUGGEST_DECODE,title,nchtxt])\r
-                    elif proc=="ts":\r
-                        add.append([recdblist.REC_AUTO_SUGGEST_ENCODE,title,nchtxt])\r
-                    elif proc =="264":\r
-                        add.append([recdblist.REC_AUTO_SUGGEST_AVI2FP,title,nchtxt])\r
-                    #elif proc =="mp4":\r
-                    #    add.append([recdblist.REC_AUTO_SUGGEST_AP2FP,title,nchtxt])\r
-        #print add\r
-    if len(add)>0:\r
-        rec10d.rec10db.new_auto_proc()\r
-        for a in add:\r
-            rec10d.rec10db.add_auto_proc(a[0],a[1],a[2])\r
-        time.sleep(1)\r
-"""\r
-    処理がどの段階まで言ったのかを調査し返す。\r
-    return\r
-    recording\r
-    b25\r
-    b25decoding\r
-    tssplitting\r
-    ts\r
-    encoding\r
-    avi\r
-    mp4making\r
-    mp4\r
-"""\r
-def checkProcess(path,title):\r
-    path1 = os.path.join(path,title+".mkv")\r
-    if os.path.exists(path1):\r
-        if int(time.time()-os.path.getmtime(path1))>300:\r
-            return "mkv"\r
-        else:\r
-            return "mkvmaking"\r
-    elif os.path.exists(os.path.join(path,title+".mp4")):\r
-        if int(time.time()-os.path.getmtime(os.path.join(path,title+".mp4")))>300:\r
-            return "mp4"\r
-        else:\r
-            return "mp4making"\r
-    elif os.path.exists(os.path.join(path,title+".264")):\r
-        if int(time.time()-os.path.getmtime(os.path.join(path,title+".264")))>300:\r
-            return "264"\r
-        else:\r
-            return "encoding"\r
-    elif os.path.exists(os.path.join(path,title+".ts.log")):\r
-        if int(time.time()-os.path.getmtime(os.path.join(path,title+".ts")))<300:\r
-            return "encoding"\r
-        else:\r
-            return "ts"\r
-    elif os.path.exists(os.path.join(path,title+".ts")):\r
-        if int(time.time()-os.path.getmtime(os.path.join(path,title+".ts")))>300:\r
-            return "ts"\r
-        else:\r
-            return "tssplitting"\r
-    elif os.path.exists(os.path.join(path,title+".sa.avi")):\r
-        if int(time.time()-os.path.getmtime(os.path.join(path,title+".sa.avi")))>300:\r
-            return "ts"\r
-        else:\r
-            return "tssplitting"\r
-    elif os.path.exists(os.path.join(path,title+".ts.b25")):\r
-        if int(time.time()-os.path.getmtime(os.path.join(path,title+".ts.b25")))>300:\r
-            return "b25"\r
-        else:\r
-            return "recording"\r
-def update_all_timeline_epg():\r
-    now=datetime.datetime.now()\r
-    et=now+datetime.timedelta(days=7)\r
-    update_timeline_epg(now.strftime("%Y-%m-%d %H:%M:%S"), et.strftime("%Y-%m-%d %H:%M:%S"))\r
-def update_timeline_epg(btime,etime):\r
-    update_timeline_epg_schedule(btime,etime)\r
-    update_timeline_dup(btime,etime)\r
-def update_timeline_epg_schedule(btime,etime):\r
-    dbl=rec10d.rec10db.select_bytime_all_timeline(btime, etime)\r
-    #print dbl\r
-    for db in dbl:\r
-        ret=[]\r
-        #[chtxtt, title, btime, etime,exp,longexp,category]\r
-        if db['type']==recdblist.REC_KEYWORD or db['type']==recdblist.REC_KEYWORD_EVERY_SOME_DAYS:\r
-            ret=epgdb.searchTime(db['title'], db['btime'], db['deltatime'], db['chtxt'])\r
-            if len(ret)>4 and len(ret[2])>18:\r
-                rec10d.rec10db.update_epg_timeline(db['type'], db['chtxt'], db['title'], db['btime'], ret[2],ret[3],ret[1],ret[4],ret[6])\r
-                if not (db['btime'] == ret[2] and  db['etime']==ret[3]):\r
-                    rec10d.rec10db.update_status_change_timeline(db['type'], db['chtxt'], db['title'], db['btime'], "1")\r
-                else:\r
-                    rec10d.rec10db.update_status_change_timeline(db['type'], db['chtxt'], db['title'], db['btime'], "0")\r
-            else:\r
-                rec10d.rec10db.update_status_change_timeline(db['type'], db['chtxt'], db['title'], db['btime'], "1")\r
-        elif db['type']==recdblist.REC_RESERVE or db['type']==recdblist.REC_FINAL_RESERVE :\r
-            ret=epgdb.searchTime(db['title'], db['btime'],"5", db['chtxt'])\r
-            if len(ret)>4 and len(ret[2])>18:\r
-                rec10d.rec10db.update_epg_timeline(db['type'], db['chtxt'], db['title'], db['btime'], ret[2],ret[3],ret[1],ret[4],ret[6])\r
-                if not (db['btime'] == ret[2] and  db['etime']==ret[3]):\r
-                    rec10d.rec10db.update_status_change_timeline(db['type'], db['chtxt'], db['title'], db['btime'], "1")\r
-                else:\r
-                    rec10d.rec10db.update_status_change_timeline(db['type'], db['chtxt'], db['title'], db['btime'], "0")\r
-            else:\r
-                rec10d.rec10db.update_status_change_timeline(db['type'], db['chtxt'], db['title'], db['btime'], "1")\r
-def update_timeline_dup(epgbtime,epgetime):\r
-    dbl=rec10d.rec10db.select_byepgtime_all_timeline(epgbtime, epgetime)\r
-    for db in dbl:\r
-        if db['type']==recdblist.REC_KEYWORD or db['type']==recdblist.REC_KEYWORD_EVERY_SOME_DAYS:\r
-            dbn=epgdb.countEpgSchedule(db['epgbtime'], db['epgetime'])\r
-            try:\r
-                bctypet=chdb.searchCHFromChtxt(db['chtxt'])['bctype']\r
-                if bctypet.find("cs") > -1 or bctypet.find("bs") > -1 :\r
-                    if dbn[1]>status.getRecordingMax()[1]:\r
-                        rec10d.rec10db.update_status_dup_timeline(db['type'], db['chtxt'], db['title'], db['btime'], "1")\r
-                    else:\r
-                        rec10d.rec10db.update_status_dup_timeline(db['type'], db['chtxt'], db['title'], db['btime'], "0")\r
-                else:\r
-                    if dbn[0]>status.getRecordingMax()[0]:\r
-                        rec10d.rec10db.update_status_dup_timeline(db['type'], db['chtxt'], db['title'], db['btime'], "1")\r
-                    else:\r
-                        rec10d.rec10db.update_status_dup_timeline(db['type'], db['chtxt'], db['title'], db['btime'], "0")\r
-            except:\r
-                ""\r
-def killDeadEncode(path):\r
-    rawlist = glob.glob(path + "/*.264")\r
-    for fn in rawlist:\r
-        if int(time.time()-os.path.getmtime(fn))>3000:\r
-            m2vpath=unicode(fn.replace(".264",".m2v"),'utf-8')\r
-            x264path=os.path.split(fn)[1]\r
-            folderpath=unicode(os.path.split(fn)[0],'utf-8')\r
-            x264path=re.sub("\\[","[",x264path)\r
-            x264path=re.sub("\[","\\\[",x264path)\r
-            x264path=re.sub("\\]","]",x264path)\r
-            x264path=re.sub("]","\\]",x264path)\r
-            tspath=unicode(x264path.replace(".264",".ts"),'utf-8')\r
-            m2vpath=unicode(x264path.replace(".264",".m2v"),'utf-8')\r
-            x264path=unicode(x264path,'utf-8')\r
-            os.environ['LANG']="ja_JP.UTF-8"\r
-            ktmp=[]\r
-            ktmp.append(u"ps auxww | grep \""+folderpath+"\" | grep \""+x264path+u"\" | egrep -v grep | egrep -v \"sh -c\" | grep x264 | awk '{print $2}'")\r
-            ktmp.append(u"ps auxww | grep \""+folderpath+"\" | grep \""+tspath+u"\" | egrep -v grep | egrep -v \"sh -c\" | grep mencoder | awk '{print $2}'")\r
-            ktmp.append(u"ps auxww | grep \""+folderpath+"\" | grep \""+m2vpath+u"\" | egrep -v grep | egrep -v \"sh -c\" | grep ffmpeg | awk '{print $2}'")\r
-            recdblist.printutf8(u"エンコード処理異常終了タスク終了")\r
-            for istr in ktmp:\r
-                recdblist.printutf8(istr)\r
-                ktmt=commands.getoutput(istr.encode('utf-8'))\r
-                #print ktmt\r
-                #print len(ktmt)\r
-                if len(ktmt)>0:\r
-                    #print ktmt\r
-                    if len(ktmt[0])>0:\r
-                        ktmt=ktmt[0]\r
-                    #print ktmt\r
-                try:\r
-                    if int(ktmt)>0:\r
-                        ktmp=u"kill -9 `"+istr+u"`"\r
-                        recdblist.printutf8(ktmp)\r
-                        #print ktmp\r
-                        os.system(ktmp.encode('utf-8'))\r
-                except:\r
-                    ""\r
-def deleteTmpFile(path,title,ext):\r
-    level= 0##0:b25 1:ts(del tsmix and ts.b25) 5:x264(del 2 and so on) 10:mp4/mkv\r
-    smsize= 0\r
-    if re.search(".ts",ext):\r
-        level= 1\r
-        smsize = 100*1000*1000\r
-    elif re.search(".264",ext):\r
-        level= 5\r
-        smsize = 10*1000*1000\r
-    elif re.search(".mp4",ext):\r
-        level = 10\r
-        smsize = 10*1000*1000\r
-    elif re.search(".mkv",ext):\r
-        level = 15\r
-        smsize = 10*1000*1000\r
-    dp=[]\r
-    if level > 0 :\r
-        if os.path.exists(os.path.join(path,title+".ts")) and os.path.exists(os.path.join(path,title+".ts.b25")):\r
-            if os.path.getsize(os.path.join(path,title+".ts"))*12>os.path.getsize(os.path.join(path,title+".ts.b25")):\r
-                dp.append(os.path.join(path,title+".ts.b25"))\r
-            elif os.path.getsize(os.path.join(path,title+".ts"))>200*1000*1000:\r
-                dp.append(os.path.join(path,title+".ts.b25"))\r
-    if level > 4 :\r
-        if configreader.getConfEnv("remove_ts")=="1":\r
-            dp.append(os.path.join(path,title+".ts"))\r
-    if level > 9 :\r
-        dp.append(os.path.join(path,title+".avi"))\r
-        dp.append(os.path.join(path,title+".264"))\r
-        dp.append(os.path.join(path,title+".120.avi"))\r
-        dp.append(os.path.join(path,title+".noodml.avi"))\r
-        dp.append(os.path.join(path,title+".aac"))\r
-        dp.append(os.path.join(path,title+".m2v"))\r
-        dp.append(os.path.join(path,title+"_1.aac"))\r
-        dp.append(os.path.join(path,title+"_2.aac"))\r
-        dp.append(os.path.join(path,title+"_1.mp3"))\r
-        dp.append(os.path.join(path,title+"_2.mp3"))\r
-        dp.append(os.path.join(path,title+".srt"))\r
-    if level > 14 :\r
-        dp.append(os.path.join(path,title+".mp4"))\r
-    if os.path.exists(os.path.join(path,title+ext)):\r
-        if os.path.getsize(os.path.join(path,title+ext))>smsize:\r
-            for ip in dp:\r
-                try:\r
-                    os.remove(ip)\r
-                except:\r
-                    ""\r
+#!/usr/bin/python
+# coding: UTF-8
+# Rec10 TS Recording Tools
+# Copyright (C) 2009-2011 Yukikaze
+import os
+import glob
+import time
+import datetime
+import commands
+import re
+import os.path
+
+import chdb
+import status
+import configreader
+import recdblist
+import rec10d
+import tv2mp4
+import epgdb
+def updateToMP4(path):
+    """
+    !現在未使用!
+    録画一時フォルダ内mp4ファイルを検索
+    """
+    avilist = glob.glob(path + "/*.avi")
+    mkvlist = glob.glob(path+"/*.mkv")
+    avilist=avilist+mkvlist
+    for avif in avilist:
+        if avif.rfind("sa.avi")==-1:
+            dir = os.path.split(avif)[0]
+            title = os.path.split(avif)[1]
+            title = title.replace(".avi", "")
+            title = title.replace(".mkv", "")
+            avipath = os.path.join(dir, title + ".avi")
+            mkvpath = os.path.join(dir, title + ".mkv")
+            mp4path = os.path.join(dir, title + ".mp4")
+            if not os.path.exists(mp4path):
+                if os.path.exists(avipath):
+                    avidtime = int(time.time()-os.path.getmtime(avipath))
+                    if avidtime>300:
+                        if os.path.exists(mkvpath):
+                            mkvdtime = int(time.time()-os.path.getmtime(mkvpath))
+                            if mkvdtime>300:
+                                recdblist.printutf8(mkvpath+":"+mp4path)
+                                tv2mp4.mkv2mp4(mkvpath,mp4path)
+                            else:
+                                recdblist.printutf8(avipath+":"+mp4path)
+                                tv2mp4.avi2mp4(avipath,mp4path)
+                        else:
+                            recdblist.printutf8(avipath+":"+mp4path)
+                            tv2mp4.avi2mp4(avipath,mp4path)
+                else:
+                    if not os.path.exists(avipath):
+                        if os.path.exists(mkvpath):
+                            mkvdtime = int(time.time()-os.path.getmtime(mkvpath))
+                            if mkvdtime>300:
+                                recdblist.printutf8(mkvpath+":"+mp4path)
+                                tv2mp4.mkv2mp4(mkvpath,mp4path)
+def autoCheck(path):
+    avilist = glob.glob(path + "/*.avi")
+    mkvlist = glob.glob(path+"/*.mkv")
+    mp4list = glob.glob(path+"/*.mp4")
+    tslist = glob.glob(path+"/*.ts")
+    b25list = glob.glob(path+"/*.ts.b25")
+    filelist=avilist+mkvlist+tslist+b25list+mp4list
+    add=[]
+    tbtime=datetime.datetime.now()+datetime.timedelta(seconds=60)
+    tbtime2=datetime.datetime.now()+datetime.timedelta(seconds=1200)
+    for fn in filelist:
+        if os.path.exists(fn):
+            if fn.rfind("sa.avi")==-1 and fn.rfind(".120.avi")==-1 and os.path.getsize(fn)>1*1000*1000:
+                dir = os.path.split(fn)[0]
+                file = os.path.split(fn)[1]
+                title = os.path.splitext(file)[0]
+                title = unicode(title,'utf-8',errors='replace')
+                ext = os.path.splitext(file)[1]
+                if ext == ".b25":
+                    title=title.replace(".ts","")
+                dbs=rec10d.rec10db.select_by_name_time_timeline(title,tbtime,tbtime2)
+                if len(dbs)==0:
+                    proc=checkProcess(dir, title)
+                    chtxtt=rec10d.rec10db.select_chtxt_by_title_timeline_log(title)
+                    nchtxt=""
+                    if chtxtt!=None:
+                        nchtxt=chtxtt
+                    if proc=="b25":
+                        add.append([recdblist.REC_AUTO_SUGGEST_DECODE,title,nchtxt])
+                    elif proc=="ts":
+                        add.append([recdblist.REC_AUTO_SUGGEST_ENCODE,title,nchtxt])
+                    elif proc =="264":
+                        add.append([recdblist.REC_AUTO_SUGGEST_AVI2FP,title,nchtxt])
+                    #elif proc =="mp4":
+                    #    add.append([recdblist.REC_AUTO_SUGGEST_AP2FP,title,nchtxt])
+        #print add
+    if len(add)>0:
+        rec10d.rec10db.new_auto_proc()
+        for a in add:
+            rec10d.rec10db.add_auto_proc(a[0],a[1],a[2])
+        time.sleep(1)
+"""
+    処理がどの段階まで言ったのかを調査し返す。
+    return
+    recording
+    b25
+    b25decoding
+    tssplitting
+    ts
+    encoding
+    avi
+    mp4making
+    mp4
+"""
+def checkProcess(path,title):
+    path1 = os.path.join(path,title+".mkv")
+    if os.path.exists(path1):
+        if int(time.time()-os.path.getmtime(path1))>300:
+            return "mkv"
+        else:
+            return "mkvmaking"
+    elif os.path.exists(os.path.join(path,title+".mp4")):
+        if int(time.time()-os.path.getmtime(os.path.join(path,title+".mp4")))>300:
+            return "mp4"
+        else:
+            return "mp4making"
+    elif os.path.exists(os.path.join(path,title+".264")):
+        if int(time.time()-os.path.getmtime(os.path.join(path,title+".264")))>300:
+            return "264"
+        else:
+            return "encoding"
+    elif os.path.exists(os.path.join(path,title+".ts.log")):
+        if int(time.time()-os.path.getmtime(os.path.join(path,title+".ts")))<300:
+            return "encoding"
+        else:
+            return "ts"
+    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"
+def update_all_timeline_epg():
+    now=datetime.datetime.now()
+    et=now+datetime.timedelta(days=7)
+    update_timeline_epg(now.strftime("%Y-%m-%d %H:%M:%S"), et.strftime("%Y-%m-%d %H:%M:%S"))
+def update_timeline_epg(btime,etime):
+    update_timeline_epg_schedule(btime,etime)
+    update_timeline_dup(btime,etime)
+def update_timeline_epg_schedule(btime,etime):
+    dbl=rec10d.rec10db.select_bytime_all_timeline(btime, etime)
+    #print dbl
+    for db in dbl:
+        ret=[]
+        #[chtxtt, title, btime, etime,exp,longexp,category]
+        if db['type']==recdblist.REC_KEYWORD or db['type']==recdblist.REC_KEYWORD_EVERY_SOME_DAYS:
+            ret=epgdb.searchTime(db['title'], db['btime'], db['deltatime'], db['chtxt'])
+            if len(ret)>4 and len(ret[2])>18:
+                rec10d.rec10db.update_epg_timeline(db['type'], db['chtxt'], db['title'], db['btime'], ret[2],ret[3],ret[1],ret[4],ret[6])
+                if not (db['btime'] == ret[2] and  db['etime']==ret[3]):
+                    rec10d.rec10db.update_status_change_timeline(db['type'], db['chtxt'], db['title'], db['btime'], "1")
+                else:
+                    rec10d.rec10db.update_status_change_timeline(db['type'], db['chtxt'], db['title'], db['btime'], "0")
+            else:
+                rec10d.rec10db.update_status_change_timeline(db['type'], db['chtxt'], db['title'], db['btime'], "1")
+        elif db['type']==recdblist.REC_RESERVE or db['type']==recdblist.REC_FINAL_RESERVE :
+            ret=epgdb.searchTime(db['title'], db['btime'],"5", db['chtxt'])
+            if len(ret)>4 and len(ret[2])>18:
+                rec10d.rec10db.update_epg_timeline(db['type'], db['chtxt'], db['title'], db['btime'], ret[2],ret[3],ret[1],ret[4],ret[6])
+                if not (db['btime'] == ret[2] and  db['etime']==ret[3]):
+                    rec10d.rec10db.update_status_change_timeline(db['type'], db['chtxt'], db['title'], db['btime'], "1")
+                else:
+                    rec10d.rec10db.update_status_change_timeline(db['type'], db['chtxt'], db['title'], db['btime'], "0")
+            else:
+                rec10d.rec10db.update_status_change_timeline(db['type'], db['chtxt'], db['title'], db['btime'], "1")
+def update_timeline_dup(epgbtime,epgetime):
+    dbl=rec10d.rec10db.select_byepgtime_all_timeline(epgbtime, epgetime)
+    for db in dbl:
+        if db['type']==recdblist.REC_KEYWORD or db['type']==recdblist.REC_KEYWORD_EVERY_SOME_DAYS:
+            dbn=epgdb.countEpgSchedule(db['epgbtime'], db['epgetime'])
+            try:
+                bctypet=chdb.searchCHFromChtxt(db['chtxt'])['bctype']
+                if bctypet.find("cs") > -1 or bctypet.find("bs") > -1 :
+                    if dbn[1]>status.getRecordingMax()[1]:
+                        rec10d.rec10db.update_status_dup_timeline(db['type'], db['chtxt'], db['title'], db['btime'], "1")
+                    else:
+                        rec10d.rec10db.update_status_dup_timeline(db['type'], db['chtxt'], db['title'], db['btime'], "0")
+                else:
+                    if dbn[0]>status.getRecordingMax()[0]:
+                        rec10d.rec10db.update_status_dup_timeline(db['type'], db['chtxt'], db['title'], db['btime'], "1")
+                    else:
+                        rec10d.rec10db.update_status_dup_timeline(db['type'], db['chtxt'], db['title'], db['btime'], "0")
+            except:
+                ""
+def killDeadEncode(path):
+    rawlist = glob.glob(path + "/*.264")
+    for fn in rawlist:
+        if int(time.time()-os.path.getmtime(fn))>3000:
+            m2vpath=unicode(fn.replace(".264",".m2v"),'utf-8')
+            x264path=os.path.split(fn)[1]
+            folderpath=unicode(os.path.split(fn)[0],'utf-8')
+            x264path=re.sub("\\[","[",x264path)
+            x264path=re.sub("\[","\\\[",x264path)
+            x264path=re.sub("\\]","]",x264path)
+            x264path=re.sub("]","\\]",x264path)
+            tspath=unicode(x264path.replace(".264",".ts"),'utf-8')
+            m2vpath=unicode(x264path.replace(".264",".m2v"),'utf-8')
+            x264path=unicode(x264path,'utf-8')
+            os.environ['LANG']="ja_JP.UTF-8"
+            ktmp=[]
+            ktmp.append(u"ps auxww | grep \""+folderpath+"\" | grep \""+x264path+u"\" | egrep -v grep | egrep -v \"sh -c\" | grep x264 | awk '{print $2}'")
+            ktmp.append(u"ps auxww | grep \""+folderpath+"\" | grep \""+tspath+u"\" | egrep -v grep | egrep -v \"sh -c\" | grep mencoder | awk '{print $2}'")
+            ktmp.append(u"ps auxww | grep \""+folderpath+"\" | grep \""+m2vpath+u"\" | egrep -v grep | egrep -v \"sh -c\" | grep ffmpeg | awk '{print $2}'")
+            recdblist.printutf8(u"エンコード処理異常終了タスク終了")
+            for istr in ktmp:
+                recdblist.printutf8(istr)
+                ktmt=commands.getoutput(istr.encode('utf-8'))
+                #print ktmt
+                #print len(ktmt)
+                if len(ktmt)>0:
+                    #print ktmt
+                    if len(ktmt[0])>0:
+                        ktmt=ktmt[0]
+                    #print ktmt
+                try:
+                    if int(ktmt)>0:
+                        ktmp=u"kill -9 `"+istr+u"`"
+                        recdblist.printutf8(ktmp)
+                        #print ktmp
+                        os.system(ktmp.encode('utf-8'))
+                except:
+                    ""
+def deleteTmpFile(path,title,ext):
+    level= 0##0:b25 1:ts(del tsmix and ts.b25) 5:x264(del 2 and so on) 10:mp4/mkv
+    smsize= 0
+    if re.search(".ts",ext):
+        level= 1
+        smsize = 100*1000*1000
+    elif re.search(".264",ext):
+        level= 5
+        smsize = 10*1000*1000
+    elif re.search(".mp4",ext):
+        level = 10
+        smsize = 10*1000*1000
+    elif re.search(".mkv",ext):
+        level = 15
+        smsize = 10*1000*1000
+    dp=[]
+    if level > 0 :
+        if os.path.exists(os.path.join(path,title+".ts")) and os.path.exists(os.path.join(path,title+".ts.b25")):
+            if os.path.getsize(os.path.join(path,title+".ts"))*12>os.path.getsize(os.path.join(path,title+".ts.b25")):
+                dp.append(os.path.join(path,title+".ts.b25"))
+            elif os.path.getsize(os.path.join(path,title+".ts"))>200*1000*1000:
+                dp.append(os.path.join(path,title+".ts.b25"))
+    if level > 4 :
+        if configreader.getConfEnv("remove_ts")=="1":
+            dp.append(os.path.join(path,title+".ts"))
+    if level > 9 :
+        dp.append(os.path.join(path,title+".avi"))
+        dp.append(os.path.join(path,title+".264"))
+        dp.append(os.path.join(path,title+".120.avi"))
+        dp.append(os.path.join(path,title+".noodml.avi"))
+        dp.append(os.path.join(path,title+".aac"))
+        dp.append(os.path.join(path,title+".m2v"))
+        dp.append(os.path.join(path,title+"_1.aac"))
+        dp.append(os.path.join(path,title+"_2.aac"))
+        dp.append(os.path.join(path,title+"_1.mp3"))
+        dp.append(os.path.join(path,title+"_2.mp3"))
+        dp.append(os.path.join(path,title+".srt"))
+    if level > 14 :
+        dp.append(os.path.join(path,title+".mp4"))
+    if os.path.exists(os.path.join(path,title+ext)):
+        if os.path.getsize(os.path.join(path,title+ext))>smsize:
+            for ip in dp:
+                try:
+                    os.remove(ip)
+                except:
+                    ""