OSDN Git Service

fix new move function.
authorgn64_jp <gn64_jp@4e526526-5e11-4fc0-8910-f8fd03428081>
Sat, 28 Nov 2009 07:12:23 +0000 (07:12 +0000)
committergn64_jp <gn64_jp@4e526526-5e11-4fc0-8910-f8fd03428081>
Sat, 28 Nov 2009 07:12:23 +0000 (07:12 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/rec10@280 4e526526-5e11-4fc0-8910-f8fd03428081

rec10/trunk/src/auto_rec.py
rec10/trunk/src/dbMySQL.py
rec10/trunk/src/epgdb.py
rec10/trunk/src/rec10 [new file with mode: 0644]
rec10/trunk/src/recdblist.py
rec10/trunk/src/timerec.py
rec10/trunk/src/tv2avi.py
rec10/trunk/src/tv2ts.py
rec10/trunk/src/xml2db.py

index 51460f5..c268916 100644 (file)
@@ -69,10 +69,14 @@ def calc_key(chtxt,title,desc):
         pp=get_db_key(key,chtxt)
         pp2=get_db_key(key,"ALL")
         if len(pp)>3:
+            tarec=0
+            taall=0
+            if len(pp2)>3:
+                tarec=pp2[2]
+                taall=pp2[3]
             trec=pp[2]
             tall=pp[3]
-            tarec=pp2[2]
-            taall=pp2[3]
+            
             tnum=tnum+1
             p=(1000*trec+5)/(1000*tall+5)
             p=p*p*100
index f579c13..f5d343b 100644 (file)
@@ -32,7 +32,7 @@ class DB_MySQL:
             (\
             id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,\
             type VARCHAR(40),\
-            chtxt VARCHAR(20),\
+            chtxt VARCHAR(40),\
             title VARCHAR(100),\
             btime DATETIME,\
             etime DATETIME,\
@@ -75,7 +75,7 @@ class DB_MySQL:
             (\
             bctype VARCHAR(15),\
             ontv VARCHAR(30) PRIMARY KEY,\
-            chtxt VARCHAR(15),\
+            chtxt VARCHAR(20),\
             ch VARCHAR(20),\
             csch VARCHAR(20),\
             chname VARCHAR(100),\
@@ -747,7 +747,7 @@ class DB_MySQL:
             CREATE TABLE auto_timeline_keyword \
             (\
             id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,\
-            chtxt VARCHAR(20),\
+            chtxt VARCHAR(40),\
             title VARCHAR(100),\
             btime DATETIME,\
             etime DATETIME,\
@@ -778,7 +778,7 @@ class DB_MySQL:
             CREATE TABLE auto_timeline_bayes \
             (\
             id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,\
-            chtxt VARCHAR(20),\
+            chtxt VARCHAR(40),\
             title VARCHAR(100),\
             btime DATETIME,\
             etime DATETIME,\
index 5af809a..224d232 100644 (file)
@@ -78,7 +78,7 @@ def searchtime2(titletxt, timet, deltatime, chtxt):
         if p > 0:
             recdblist.printutf8(title + ":" + str(p) + u"点")
     ret = one
-    recdblist.printutf8(ret)
+    print ret
     return ret
 def searchtime_auto(keytxt, timet, deltatime):
     time = datetime.datetime.strptime(timet, "%Y-%m-%d %H:%M:%S")
diff --git a/rec10/trunk/src/rec10 b/rec10/trunk/src/rec10
new file mode 100644 (file)
index 0000000..3a801ec
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+SELF_DIR='dirname $0'
+cd ${SELF_DIR}
+export LANG="ja_JP.UTF-8" && python2.6 ./rec10d.py
\ No newline at end of file
index a46835e..6a93f9e 100644 (file)
@@ -25,21 +25,7 @@ global REC_MKV_TO_MP4
 global REC_CHANGING_CANTAINER
 
 #ここから処理のちに移動
-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
 
 #ここから自動で提起される処理。
@@ -68,21 +54,6 @@ REC_AVI_TO_MKV = "convert_avi_mkv"
 REC_AVI_TO_MP4 = "convert_avi_mp4"
 REC_MKV_TO_MP4 = "convert_mkv_mp4"
 
-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"
index 85775ec..b192c0c 100644 (file)
@@ -9,7 +9,6 @@ import re
 import sys
 import time
 import shutil
-import traceback
 
 import auto_rec
 import auto_process
@@ -37,7 +36,6 @@ def task():
     recdb.delete_old_auto_keyword("1")
     tasks = recdb.getnow("2")
     inum = recdb.countRecNow_minutes("10")
-    #pyprint traceback.format_exc()
     recdblist.printutf8(u"rec10処理開始"+ datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
     recdblist.printutf8(u"直近録画予約件数:" + str(inum) + u"BS/CS録画中件数:" + str(status.getBSCSRecording()) + u"TE録画中件数:" + str(status.getTERecording()) )
     encodenum=0
@@ -330,12 +328,6 @@ def type_reserve(typetxt,chtxt,title,bt,et,opt):
     typetxtfinal=""
     if typetxt==recdblist.REC_RESERVE:
         typetxtfinal=recdblist.REC_FINAL_RESERVE
-    elif typetxt==recdblist.REC_MOVE_AFTER_DECODE:
-        typetxtfinal=recdblist.REC_MOVE_AFTER_DECODE_FINAL
-    elif typetxt==recdblist.REC_MOVE_AFTER_RECORD:
-        typetxtfinal=recdblist.REC_MOVE_AFTER_RECORD_FINAL
-    elif typetxt==recdblist.REC_MOVE_AFTER_ENCODE:
-        typetxtfinal=recdblist.REC_MOVE_AFTER_ENCODE_FINAL
     tnow = datetime.datetime.now()
     dtt = bt-tnow
     dt = dtt.days * 24 * 60 * 60 + dtt.seconds
@@ -391,15 +383,6 @@ def type_final(typetxt,chtxt,title,bt,et,opt):
     if typetxt==recdblist.REC_FINAL_RESERVE:
         typetxting=recdblist.REC_TS_RECORDING
         typetxtdecque=recdblist.REC_TS_DECODE_QUE
-    elif typetxt==recdblist.REC_MOVE_AFTER_DECODE_FINAL:
-        typetxting=recdblist.REC_MOVE_AFTER_DECODE_RECORDING
-        typetxtdecque=recdblist.REC_MOVE_AFTER_DECODE_DECODE_QUE
-    elif typetxt==recdblist.REC_MOVE_AFTER_RECORD_FINAL:
-        typetxting=recdblist.REC_MOVE_AFTER_RECORD_RECORDING
-        typetxtdecque=""
-    elif typetxt==recdblist.REC_MOVE_AFTER_ENCODE_FINAL:
-        typetxting=recdblist.REC_MOVE_AFTER_ENCODE_RECORDING
-        typetxtdecque=recdblist.REC_MOVE_AFTER_ENCODE_DECODE_QUE
     tnow = datetime.datetime.now()
     dtt = bt-tnow
     dt = dtt.days * 24 * 60 * 60 + dtt.seconds
@@ -423,7 +406,7 @@ def type_final(typetxt,chtxt,title,bt,et,opt):
             ttitle=title+"_"+datetime.datetime.now().strftime("%Y%m%d%H%M")
         tv2avi.timetv2b25(recpath + "/" + ttitle + ".avi", chtxt, btime, etime, opt)
         recdb.del_reckey(typetxting, title, chtxt, btime)
-        if typetxtdecque != "":
+        if not re.search("R", opt):
             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")
@@ -432,7 +415,7 @@ def type_final(typetxt,chtxt,title,bt,et,opt):
             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(typetxtdecque, ttitle, chtxt, btime, etime, opt)
+            recdb.rec_reckey(recdblist.REC_MOVE_END, ttitle, chtxt, btime, etime, opt)
         else:
             shutil.copy(os.path.join(recpath,title+".ts.b25"), os.path.join(movepath,title+".ts.b25"))
         sys.exit()
@@ -513,14 +496,6 @@ def type_decode_que(typetxt,chtxt,title,bt,et,opt):
         typetxting=recdblist.REC_TS_DECODING
         typetxtmiss=recdblist.REC_MISS_DECODE
         typetxtencque=recdblist.REC_ENCODE_QUE
-    elif typetxt== recdblist.REC_MOVE_AFTER_DECODE_DECODE_QUE:
-        typetxting=recdblist.REC_MOVE_AFTER_DECODE_DECODING
-        typetxtmiss=recdblist.REC_MISS_DECODE
-        typetxtencque=""
-    elif typetxt== recdblist.REC_MOVE_AFTER_ENCODE_DECODE_QUE:
-        typetxting=recdblist.REC_MOVE_AFTER_ENCODE_DECODING
-        typetxtmiss=recdblist.REC_MISS_DECODE
-        typetxtencque=recdblist.REC_MOVE_AFTER_ENCODE_ENCODE_QUE
     tnow = datetime.datetime.now()
     dtt = bt-tnow
     dt = dtt.days * 24 * 60 * 60 + dtt.seconds
@@ -537,13 +512,13 @@ def type_decode_que(typetxt,chtxt,title,bt,et,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
-            if not typetxtencque=="":
+            if not re.search("D", opt):
                 tnow = datetime.datetime.now()
                 bt = tnow + datetime.timedelta(seconds=600)
                 et = bt + dt
                 btime = bt.strftime("%Y-%m-%d %H:%M:%S")
                 etime = et.strftime("%Y-%m-%d %H:%M:%S")
-                recdb.rec_reckey(typetxtencque, title, chtxt, btime, etime, opt)
+                recdb.rec_reckey(recdblist.REC_MOVE_END, title, chtxt, btime, etime, opt)
             else:
                 if opt.rfind("d")>=0:
                     shutil.copy(os.path.join(recpath,title+".sa.avi"),os.path.join(movepath,title+".sa.avi"))
@@ -575,9 +550,6 @@ def type_encode_que(typetxt,chtxt,title,bt,et,opt):
     if typetxt==recdblist.REC_ENCODE_QUE:
         typetxting=recdblist.REC_ENCODE_LOCAL
         typetxtfin=recdblist.REC_FIN_LOCAL
-    elif typetxt==recdblist.REC_MOVE_AFTER_ENCODE_ENCODE_QUE:
-        typetxting=recdblist.REC_ENCODE_LOCAL
-        typetxtfin=recdblist.REC_MOVE_END
     if dt < 10 * 60:
         if status.getEncoding() < int(configreader.getenv("enc_max")):
             recdblist.printutf8(opt)
@@ -596,8 +568,9 @@ def type_encode_que(typetxt,chtxt,title,bt,et,opt):
             tv2mp4.ts2mp4(pin, pout, opt)
             #tv2avi.ts2avi(pin, pout, opt)
             recdb.del_reckey(typetxting, title, chtxt, btime)
-            if typetxtfin==recdblist.REC_MOVE_END:
+            if re.search("R", opt):
                 shutil.copy(os.path.join(recpath,title+".mp4"), os.path.join(movepath,title+".mp4"))
+                recdb.rec_reckey(recdblist.REC_MOVE_END, title, chtxt, btime, etime, opt)
             recdb.rec_reckey(typetxtfin, title, chtxt, btime, etime, opt)
             sys.exit()
         else:
index da2d077..a4539ad 100644 (file)
@@ -144,8 +144,10 @@ def ts2avi(pin, pout, opt):
     #status.setEncoding(status.getEncoding() + 1)
     try:
         ts2x264.ts2x264(pin, pout, opt)
-    except:
-        ""
+    except Exception, inst:
+        print "error occures in tv2avi.py tv2avi"
+        print type(inst)
+        print inst
     status.changeEncoding(-1)
     #status.setEncoding(status.getEncoding()-1)
 def tv2avi(pout, chtxt, btime, etime, opt):
index 3773297..53d55ba 100644 (file)
@@ -27,7 +27,12 @@ def tv2ts(pout, ch, csch, time):
         status.changeBSCSRecording(1)
     else:
         status.changeTERecording(1)
-    tv2b25ts(pout + ".b25", ch, time)
+    try:
+        tv2b25ts(pout + ".b25", ch, time)
+    except Exception, inst:
+        print "error occures in tv2ts.py tv2ts"
+        print type(inst)
+        print inst
     if len(ch) > 2:#BS/CSは100とかCS??とかなので3文字以上
         status.changeBSCSRecording(-1)
     else:
@@ -76,14 +81,19 @@ def tv2b25ts(pout, ch, time):
         status.changeBSCSRecording(1)
     else:
         status.changeTERecording(1)
-    doexe = exe + ' ' + ch + ' ' + time + ' \'' + pout + '\''
-    recdblist.printutf8(doexe)
-    txt=u"####recpt1-log####\n"
-    txt = txt + unicode(commands.getoutput(doexe.encode('utf-8')),'utf-8')
-    logo=pout.replace(".ts.b25",".log")
-    f=open(logo,'w')
-    f.write(txt.encode('utf-8'))
-    f.close()
+    try:
+        doexe = exe + ' ' + ch + ' ' + time + ' \'' + pout + '\''
+        recdblist.printutf8(doexe)
+        txt=u"####recpt1-log####\n"
+        txt = txt + unicode(commands.getoutput(doexe.encode('utf-8')),'utf-8')
+        logo=pout.replace(".ts.b25",".log")
+        f=open(logo,'w')
+        f.write(txt.encode('utf-8'))
+        f.close()
+    except Exception, inst:
+        print "error occures in tv2ts.py tv2b25ts"
+        print type(inst)
+        print inst
     if len(ch) > 2:#BS/CSは100とかCS??とかなので3文字以上
         status.changeBSCSRecording(-1)
     else:
index 5c377dc..2100d71 100644 (file)
@@ -97,7 +97,8 @@ def end_element(name):
                     bayes[tch['chtxt']]=bt2
                     tvlists.append([ubctype, uch, ustart, ustop, utitle, udesc,ulongdesc,ucategory])
                     if auto_rec.calc_key(tch['chtxt'], utitle, udesc+" "+ulongdesc):
-                        recdb.add_auto_bayes(utitle, tch['chtxt'], ustart,ustop)
+                        recdb.add_auto_bayes(tch['chtxt'],utitle, ustart,ustop)
+
             xmldate['title'] = ""
             xmldate['desc'] = ""
             xmldate['longdesc'] = ""