OSDN Git Service

epg-longexp fuction added.
[rec10/rec10-git.git] / rec10 / trunk / src / timerec.py
index 38da071..e9ca6e0 100644 (file)
@@ -18,6 +18,7 @@ import recdb
 import status
 import tv2avi
 import tv2mkv
+import tv2mp4
 recpath = configreader.getpath('recpath')
 path = str(os.path.dirname(os.path.abspath(__file__))) + "/"
 def task():
@@ -32,6 +33,14 @@ def task():
     print "inum:" + str(inum) + "bscsrec:" + str(status.getBSCSRecording()) + "terec:" + str(status.getTERecording()) 
     encodenum=0
     b25num=0
+    dnow=datetime.datetime.now()
+    if dnow.hour==12 and dnow.minute<5 :
+        pid = os.fork()
+        if pid != 0:
+            time.sleep(1)
+        else:
+            for k in recdb.get_key():
+                search_keyword(k)
     update = chdb.update()
     print update
     if len(update) > 0:
@@ -115,6 +124,7 @@ def task():
                                 recdb.rec_reckey(recdb.REC_FINAL_RESERVE, 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"
@@ -154,6 +164,7 @@ def task():
                         recdb.rec_reckey(recdb.REC_RESERVE, titlet, chtxtt, btimet, etimet, opt)
                         recdb.rec_reclog(titlet, chtxtt, btimet, etimet, opt, exp,longexp,category)
                         auto_rec.add_key(chtxt, titlet,exp+" "+longexp)
+                        auto_rec.add_key("ALL", titlet,exp+" "+longexp)
                         print "key "+title+" : "+titlet+" "+btimet+" "+etimet
                     except Exception, inst:
                         print "Error happened in REC_KEYWORD DB"
@@ -271,13 +282,14 @@ def task():
                         if re.search("5", opt):
                             pin = recpath + "/" + title + ".sa.avi"
                         #pout = recpath + "/" + title + ".avi"
-                        pout = recpath + "/" + title + ".mkv"
+                        pout = recpath + "/" + title + ".mp4"
                         print [pin, pout, opt]
                         print pin
                         #print pin+":"+pout+":"+opt
                         recdb.del_reckey(recdb.REC_ENCODE_QUE, title, chtxt, btime)
                         recdb.rec_reckey(recdb.REC_ENCODE_LOCAL, title, chtxt, btime, etime, opt)
-                        tv2mkv.ts2mkv(pin, pout, opt)
+                        #tv2mkv.ts2mkv(pin, pout, opt)
+                        tv2mp4.ts2mp4(pin, pout, opt)
                         #tv2avi.ts2avi(pin, pout, opt)
                         recdb.del_reckey(recdb.REC_ENCODE_LOCAL, title, chtxt, btime)
                         recdb.rec_reckey(recdb.REC_FIN_LOCAL, title, chtxt, btime, etime, opt)
@@ -301,6 +313,28 @@ def task():
                     tv2mkv.avi2mkv(os.path.join(recpath,title+".avi"),os.path.join(recpath,title+".mkv"))
                     recdb.del_reckey(recdb.REC_CHANGING_CANTAINER, title, chtxt, btime)
                     sys.exit()
+        elif task["type"] == recdb.REC_AVI_TO_MP4:
+            if dt < 10 * 60:
+                pid = os.fork()
+                if pid > 0:#親プロセスの場合
+                    ""
+                else:
+                    recdb.del_reckey(recdb.REC_AVI_TO_MP4, title, chtxt, btime)
+                    recdb.rec_reckey(recdb.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
+                    tv2mp4.avi2mp4(os.path.join(recpath,title+".avi"),os.path.join(recpath,title+".mp4"))
+                    recdb.del_reckey(recdb.REC_CHANGING_CANTAINER, title, chtxt, btime)
+                    sys.exit()
+        elif task["type"] == recdb.REC_MKV_TO_MP4:
+            if dt < 10 * 60:
+                pid = os.fork()
+                if pid > 0:#親プロセスの場合
+                    ""
+                else:
+                    recdb.del_reckey(recdb.REC_AVI_TO_MP4, title, chtxt, btime)
+                    recdb.rec_reckey(recdb.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
+                    tv2mp4.mkv2mp4(os.path.join(recpath,title+".mkv"),os.path.join(recpath,title+".mp4"))
+                    recdb.del_reckey(recdb.REC_CHANGING_CANTAINER, title, chtxt, btime)
+                    sys.exit()
         elif task["type"] == recdb.REC_AUTO_KEYWORD:#"key,"+chtxt+","+keyword+","+btime+","+deltatime+","+opt
             deltatime = "24"
             if dt < 90 * 60:
@@ -334,4 +368,24 @@ def task():
                 except Exception, inst:
                     print type(inst)
                     print inst
-    sys.exit()
\ No newline at end of file
+    sys.exit()
+def search_keyword(key):
+    tnow = datetime.datetime.now()
+    nows =tnow.strftime("%Y-%m-%d %H:%M:%S")
+    for k in key:
+        recdatum = epgdb.searchtime_auto(k.decode('utf-8'),nows, "144")
+        for recdata in recdatum:
+            if recdata[1] != "":
+                chtxtt = recdata[0]
+                titlet = recdata[1]
+                btimet = recdata[2]
+                etimet = recdata[3]
+                btt = datetime.datetime.strptime(btimet, "%Y-%m-%d %H:%M:%S")
+                ett = datetime.datetime.strptime(etimet, "%Y-%m-%d %H:%M:%S")
+                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)
+                except Exception, inst:
+                    print type(inst)
+                    print inst
\ No newline at end of file