OSDN Git Service

implement config in /etc/rec10.conf.
authorgn64_jp <gn64_jp@4e526526-5e11-4fc0-8910-f8fd03428081>
Sun, 22 Nov 2009 12:37:58 +0000 (12:37 +0000)
committergn64_jp <gn64_jp@4e526526-5e11-4fc0-8910-f8fd03428081>
Sun, 22 Nov 2009 12:37:58 +0000 (12:37 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/rec10@234 4e526526-5e11-4fc0-8910-f8fd03428081

rec10/trunk/src/configreader.py
rec10/trunk/src/timerec.py

index 50ed2ac..68b2794 100644 (file)
@@ -4,10 +4,18 @@
 # Copyright (C) 2009 Yukikaze
 import ConfigParser
 import os
+import os.path
 mypath = str(os.path.dirname(os.path.abspath(__file__))) + "/"
 confp = ConfigParser.SafeConfigParser()
 Conf = 'config.ini'
-confp.read(mypath + Conf)
+confpath=""
+if os.path.exists(os.path.join(mypath,Conf)):
+    confpath=os.path.join(mypath,Conf)
+elif os.path.exists(os.path.join("/etc","rec10.conf")):
+    confpath=os.path.join("/etc","rec10.conf")
+elif os.path.exists(os.path.join("/etc/rec10","config.ini")):
+    confpath=os.path.join("/etc/rec10","config.ini")
+confp.read(confpath)
 def getpath(string):
     global confp
     return confp.get('path', string)
index b74c998..cf3a1d2 100644 (file)
@@ -4,6 +4,7 @@
 # Copyright (C) 2009 Yukikaze
 import datetime
 import os
+import os.path
 import re
 import sys
 import time
@@ -743,4 +744,121 @@ def search_keyword(key):
                     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
+                    print inst
+def type_reserve(chtxt,title,bt,et,opt):
+    chtxtnow=chtxt
+    chtxtfinal=""
+    if chtxt==recdb.REC_RESERVE:
+        chtxtfinal=recdb.REC_FINAL_RESERVE
+    elif chtxt==recdb.REC_MOVE_AFTER_DECODE:
+        chtxtfinal=recdb.REC_MOVE_AFTER_DECODE_FINAL
+    elif chtxt==recdb.REC_MOVE_AFTER_RECORD:
+        chtxtfinal=recdb.REC_MOVE_AFTER_RECORD_FINAL
+    elif chtxt==recdb.REC_MOVE_AFTER_ENCODE:
+        chtxtfinal=recdb.REC_MOVE_AFTER_ENCODE_FINAL
+    tnow = datetime.datetime.now()
+    dtt = bt-tnow
+    dt = dtt.days * 24 * 60 * 60 + dtt.seconds
+    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(chtxtnow, title, chtxt, btime)
+                        recdb.rec_reckey(chtxtfinal, 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 dt <= 20 * 60:
+        try:
+            recdb.del_reckey(chtxtnow, title, chtxt, btime)
+            recdb.rec_reckey(chtxtfinal, title, chtxt, btime, etime, opt)
+        except Exception, inst:
+            print type(inst)
+            print inst
+def type_final(chtxt,title,bt,et,opt):
+    chtxtnow=chtxt
+    chtxting=""
+    chtxtdecque=""
+    if chtxtnow==recdb.REC_FINAL_RESERVE:
+        chtxting=recdb.REC_TS_RECORDING
+        chtxtdecque=recdb.REC_TS_DECODE_QUE
+    elif chtxtnow==recdb.REC_MOVE_AFTER_DECODE_FINAL:
+        chtxting=recdb.REC_MOVE_AFTER_DECODE_RECORDING
+        chtxtdecque=recdb.REC_MOVE_AFTER_DECODE_DECODE_QUE
+    elif chtxtnow==recdb.REC_MOVE_AFTER_RECORD_FINAL
+        chtxting=recdb.REC_MOVE_AFTER_RECORD_RECORDING
+        chtxtdecque=""
+    elif chtxtnow==recdb.REC_MOVE_AFTER_ENCODE_FINAL:
+        chtxting=recdb.REC_MOVE_AFTER_ENCODE_RECORDING
+        chtxtdecque=recdb.REC_MOVE_AFTER_ENCODE_DECODE_QUE
+    tnow = datetime.datetime.now()
+    dtt = bt-tnow
+    dt = dtt.days * 24 * 60 * 60 + dtt.seconds
+    print dt
+    if dt < 6 * 60 and dt > 0:
+        recdb.del_reckey(chtxtnow, title, chtxt, btime)
+        recdb.rec_reckey(chtxting, 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(chtxting, title, chtxt, btime)
+            if chtxtdecque != "":
+                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(chtxtdecque, ttitle, chtxt, btime, etime, opt)
+            else:
+                shutil.copy(os.path.join(recpath,title+".ts.b25"), os.path.join(movepath,title+".ts.b25"))
+            sys.exit()
\ No newline at end of file