OSDN Git Service

fix encoding process.
authorgn64_jp <gn64_jp@4e526526-5e11-4fc0-8910-f8fd03428081>
Mon, 30 Nov 2009 09:04:24 +0000 (09:04 +0000)
committergn64_jp <gn64_jp@4e526526-5e11-4fc0-8910-f8fd03428081>
Mon, 30 Nov 2009 09:04:24 +0000 (09:04 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/rec10@286 4e526526-5e11-4fc0-8910-f8fd03428081

rec10/trunk/src/classify.py
rec10/trunk/src/rec10
rec10/trunk/src/timerec.py

index 60ba905..a4624a8 100644 (file)
@@ -5,7 +5,6 @@
 
 __author__="yukikaze"
 __date__ ="$2009/09/14 17:38:25$"
-
 import glob
 import n_gram
 import os
@@ -18,8 +17,8 @@ import shutil
 
 import configreader
 import recdblist
-recordedpath=configreader.getpath("recorded")
-recpath=configreader.getpath("recpath")
+recordedpath=unicode(configreader.getpath("recorded"),'utf-8')
+recpath=unicode(configreader.getpath("recpath"),'utf-8')
 def search_b25(path):
     """
     録画フォルダを検索し、各QUEの実行状況を表示する
@@ -113,7 +112,7 @@ def search_mp4(temppath,recpath):
 def veryfySize(path):
     #vsize=[297,497,596,1196]#SD 30m 1h 1.5h 2h
     vsize=[245,275,295,591,830]
-    vsize=vsize+[325,449,560,590,602,690,860,1237]
+    vsize=vsize+[325,449,560,590,602,690,805,860,1014,1138,1237]
     #vsize=vsize+[458,916]#HD 30m 1h
     #vsize=vsize+[381,895,447]
     ret = 0
@@ -129,25 +128,31 @@ def searchFolder(title,path):
     lfpath=[]
     ngram=[]
     for ft in folderpath:
-        fullpath=os.path.join(path, ft)
+        fullpath=os.path.join(path.encode('utf-8'), ft)
         if os.path.isdir(fullpath):
             lfpath.append(fullpath)
             ftt=os.listdir(fullpath)
             if len(ftt)>0:
                 for ft2 in ftt:
-                    folderpath.append(os.path.join(fullpath, ft2))
+                    try:
+                        folderpath.append(os.path.join(fullpath, ft2))
+                    except Exception, inst:
+                        #print type(inst)
+                        #print inst
+                        ""
         else:
             lfpath.append(fullpath)
     for dirp in lfpath:
         cmpp=""
         appp=""
+        ntitle=title
         if os.path.isdir(dirp):
             cmpp=os.path.dirname(dirp)
             appp=dirp
         else:
             cmpp=os.path.basename(dirp)
             appp=os.path.dirname(dirp)
-        p=n_gram.trigram(title.decode("utf-8"),cmpp.decode("utf-8"))
+        p=n_gram.trigram(ntitle,cmpp)
         if p>0:
             ngram.append((p,appp))
     ngram=list(set(ngram))
@@ -266,8 +271,11 @@ if __name__ == "__main__":
     parser.add_option("-l","--list",action="store_true",dest="list",default=False,help="File listing mode(test for -a)")
     (opts,args)=parser.parse_args(sys.argv)
     if opts.ltitle!="":
-        sf=searchFolder(opts.ltitle, recordedpath)
-        recdblist.printutf8(os.path.join(sf, destNameMP4(opts.ltitle,recpath,sf)+".mp4"))
+        #print opts.ltitle
+        ltitle=unicode(opts.ltitle,'utf-8')
+        sf=searchFolder(ltitle, recordedpath)
+        recdblist.printutf8(os.path.join(sf, destNameMP4(ltitle,recpath,sf)+".mp4"))
+        #print os.path.join(sf, destNameMP4(ltitle,recpath,sf)+".mp4")
     elif opts.auto:
         sa=search_mp4(recpath, recordedpath)
         for t in sa:
@@ -285,7 +293,8 @@ if __name__ == "__main__":
         for t in sa:
             sf=searchFolder(t,recordedpath)
             if sf!="":
-                recdblist.printutf8(t+" : "+os.path.join(sf, destNameMP4(t, recpath,sf)+".mp4"))
+                recdblist.printutf8(t+u" : "+os.path.join(sf, destNameMP4(t, recpath,sf)+".mp4"))
     elif opts.etitle!="":
-        execMove(opts.etitle,recpath, recordedpath)
+        etitle=unicode(opts.etitle,'utf-8')
+        execMove(etitle,recpath, recordedpath)
 
index 3a801ec..b7ce394 100644 (file)
@@ -1,4 +1,4 @@
 #!/bin/sh
-SELF_DIR='dirname $0'
+SELF_DIR=`dirname $0`
 cd ${SELF_DIR}
 export LANG="ja_JP.UTF-8" && python2.6 ./rec10d.py
\ No newline at end of file
index 42ae827..8e56200 100644 (file)
@@ -44,7 +44,7 @@ def task():
     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)
@@ -342,11 +342,8 @@ def type_final(typetxt,chtxt,title,bt,et,opt):
     dt = dtt.days * 24 * 60 * 60 + dtt.seconds
     print dt
     if dt < 6 * 60 and dt > 0:
+        newtitle=title
         recdb.del_reckey(typetxtnow, title, chtxt, btime)
-        recdb.rec_reckey(typetxting, title, chtxt, btime, etime, opt)
-        recdblist.printutf8(u"録画開始 "+title+" "+btime+" "+etime)
-        ttitle=title
-        #recdblist.printutf8(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"))
@@ -356,9 +353,11 @@ def type_final(typetxt,chtxt,title,bt,et,opt):
         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)
+        if re.search("N", opt) or tcheck>0:
+            newtitle=newtitle+u"_"+bt.strftime("%Y%m%d%H%M")
+        recdb.rec_reckey(typetxting, newtitle, chtxt, btime, etime, opt)
+        recdblist.printutf8(u"録画開始 "+newtitle+" "+btime+" "+etime)
+        tv2avi.timetv2b25(recpath + "/" + newtitle + ".avi", chtxt, btime, etime, opt)
         recdb.del_reckey(typetxting, title, chtxt, btime)
         if not re.search("R", opt):
             tnow = datetime.datetime.now()
@@ -524,7 +523,7 @@ 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 re.search("R", opt):
+            if re.search("E", 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)