OSDN Git Service

fix " unusable bug.
authorgn64_jp <gn64_jp@4e526526-5e11-4fc0-8910-f8fd03428081>
Fri, 31 Jul 2009 09:10:50 +0000 (09:10 +0000)
committergn64_jp <gn64_jp@4e526526-5e11-4fc0-8910-f8fd03428081>
Fri, 31 Jul 2009 09:10:50 +0000 (09:10 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/rec10@82 4e526526-5e11-4fc0-8910-f8fd03428081

rec10/trunk/src/chdata.py
rec10/trunk/src/epgdb.py
rec10/trunk/src/status.py
rec10/trunk/src/timerec.py
rec10/trunk/src/tv2ts.py
rec10/trunk/src/xml2db.py
rec10/trunk/src/zenhan.py

index 16f912a..5f044bc 100644 (file)
@@ -50,6 +50,29 @@ def chadd(bctype, ontv, chtxt, ch, csch, station, station_name):#すべて文字
 #chadd('放送種別','ontvコード(ontvのサイトなどで調べられる)','略称(何でもよい)','チャンネル(物理チャンネル)','CS放送の場合の内訳','iEPGデジタルのstation','iEPGのstation')
 #iEPGDigitalはテレビ王国のサイトでiEPGはサイトによってまちまちのようなので自分の使うサイトに即したものにしてください
 #指定しない場合はnoneなどにしておけば動作はします(自動でチャンネルを設定する部分が動かないためチャンネルをRec10WEBから指定する必要があります。)
+
+
+#地上波の設定 東京都(筆者は東京で受信していないため正しいかどうか分かりません)
+#chadd('te26', '0442.ontvjapan.com', 'nhk-k', '26', '0', 'DFS00408', 'NHK教育')
+#chadd('te27', '0432.ontvjapan.com', 'nhk-s', '27', '0', 'DFS00400', 'NHK総合')
+#chadd('te25', '0404.ontvjapan.com', 'nittere', '25', '0', 'DFS00410', '日本テレビ')
+#chadd('te22', '0405.ontvjapan.com', 'tbs', '22', '0', 'DFS00418', 'TBS')
+#chadd('te23', '0406.ontvjapan.com', 'tokyo', '23', '0', 'DFS00430', 'テレビ東京')
+#chadd('te21', '0407.ontvjapan.com', 'fuji', '21', '0', 'DFS00420', 'フジテレビ')
+#chadd('te24', '0420.ontvjapan.com', 'asahi', '24', '0', 'DFS0428', 'テレビ朝日')
+#chadd('te20', '0420.ontvjapan.com', 'tokyomx', '20', '0', 'DFS00112', '東京MX')#よくわかりません
+#
+#地上波の設定 愛知県向け
+chadd('te13', '0442.ontvjapan.com', 'nhk-k', '13', '0', 'DFS00C08', 'NHK教育')
+chadd('te20', '0432.ontvjapan.com', 'nhk-s', '20', '0', 'DFS08400', 'NHK総合')
+chadd('te22', '0404.ontvjapan.com', 'me-tere', '22', '0', 'DFS00C20', '名古屋テレビ')
+chadd('te18', '0405.ontvjapan.com', 'cbc', '18', '0', 'DFS00C18', '中京テレビ')
+chadd('te21', '0406.ontvjapan.com', 'toukai', '21', '0', 'DFS00C10', '東海テレビ')
+chadd('te19', '0407.ontvjapan.com', 'chukyo', '19', '0', 'DFS00C28', '中京テレビ')
+chadd('te23', '0420.ontvjapan.com', 'aichi', '23', '0', 'DFS08430', 'テレビ愛知')
+
+
+
 #CS放送(スカパーe2)主に基本パックには言ってるものを中心に
 chadd('cs', '1204.ontvjapan.com', 'natiogeo', 'CS6', '343', 'CSDT343', 'none')
 chadd('cs', '1070.ontvjapan.com', 'bbc', 'CS12', '353', 'CSDT353', 'BBCワールド')
@@ -84,13 +107,4 @@ chadd('bs', '3007.ontvjapan.com', 'bs-japan', '171', '0', 'BSDT171', 'BSジ
 chadd('bs', '3008.ontvjapan.com', 'bs-fuji', '181', '0', 'BSDT181', 'BSフジ')
 chadd('bs', '3013.ontvjapan.com', 'bs-11', '211', '0', 'BSDT211', '')
 
-#地上波の設定 愛知県向け
-chadd('te13', '0442.ontvjapan.com', 'nhk-k', '13', '0', 'DFS00C08', 'NHK教育')
-chadd('te20', '0432.ontvjapan.com', 'nhk-s', '20', '0', 'DFS08400', 'NHK総合')
-chadd('te22', '0404.ontvjapan.com', 'me-tere', '22', '0', 'DFS00C20', '名古屋テレビ')
-chadd('te18', '0405.ontvjapan.com', 'cbc', '18', '0', 'DFS00C18', '中京テレビ')
-chadd('te21', '0406.ontvjapan.com', 'toukai', '21', '0', 'DFS00C10', '東海テレビ')
-chadd('te19', '0407.ontvjapan.com', 'chukyo', '19', '0', 'DFS00C28', '中京テレビ')
-chadd('te23', '0420.ontvjapan.com', 'aichi', '23', '0', 'DFS08430', 'テレビ愛知')
-
 
index 4aa55a1..562e2df 100644 (file)
@@ -105,24 +105,6 @@ def searchtime2(titletxt,timet,deltatime,chtxt):
     one={}
     tempt=0
     for chtxtt, title, start, stop in db.execute(dbexe):
-        """btime=start.replace(" +0900","")
-        btime=btime[0:4]+"-"+btime[4:6]+"-"+btime[6:8]+" "+btime[8:10]+":"+btime[10:12]+":00"
-        etime=stop.replace(" +0900","")
-        etime=etime[0:4]+"-"+etime[4:6]+"-"+etime[6:8]+" "+etime[8:10]+":"+etime[10:12]+":00"
-        bt=datetime.datetime.strptime(btime,"%Y-%m-%d %H:%M:%S")
-        t=datetime.datetime.strptime(time,"%Y-%m-%d %H:%M:%S")
-        try:
-            chtxt=chdb.ontvsearch(ch)['chtxt']
-        except:
-            chtxt="Unknown"
-            #print ch
-        dt=bt-t
-        dt=dt.days*24*60*60+dt.seconds
-        dt=abs(dt)
-        if dt<deltatime*60*60:
-            ret.append(chtxt+","+title.encode('utf-8')+","+btime+","+etime)
-
-            """
         ret=[]
         p=n_gram.bigram(titletxt,title)
         btime=start
index 3fad143..2aff23c 100755 (executable)
@@ -3,7 +3,7 @@
 # Rec10 TS Recording Tools
 # Copyright (C) 2009 Yukikaze
 import os
-import re
+import ConfigParser
 path=os.path.dirname(os.path.abspath(__file__))+"/"
 
 def getEncoding():
@@ -21,13 +21,13 @@ def getStatusDate():
     f.close()
     return lines
 def getStatusNum(datastr):
+    ini=ConfigParser.SafeConfigParser()
+    ini.read(path+'status')
     t=0
-    for line in getStatusDate():
-        if re.search(datastr+"=",line):
-            line=line.replace(datastr+"=","")
-            line=line.replace(" ","")
-            t=int(line)
-            break
+    try:
+        t=int(ini.get('tasknum',datastr))
+    except:
+        ""
     return t
 def setTERecording(tasknum):
     setData('terec',tasknum)
@@ -36,18 +36,10 @@ def getBSCSRecording():
 def setBSCSRecording(tasknum):
     setData('bscsrec',tasknum)
 def setData(datastr,tasknum):
-    s=""
-    if tasknum<0:
-        tasknum=0
-    writeb=0
-    for line in getStatusDate():
-        if not re.search(datastr+'=',line):
-            s=s+line
-        else:
-            s = s + datastr+'='+str(tasknum)+"\n"
-            writeb=1
-    if writeb==0:
-        s = s + datastr+'='+str(tasknum)+"\n"
-    f = open(path+'status', 'w') # 書き込みモードで開く
-    f.write(s) # 引数の文字列をファイルに書き込む
-    f.close() # ファイルを閉じる
+    ini=ConfigParser.SafeConfigParser()
+    ini.read(path+'status')
+    ini.set('tasknum',datastr,str(tasknum))
+    f=open(path+'status','w')
+    ini.write(f)
+    f.close
+    
index 64ed3c3..caac8f5 100644 (file)
@@ -135,9 +135,11 @@ def task():
                         tnow2=datetime.datetime.now()
                         dtt2=et-tnow
                         dt2=dtt2.days*24*60*60+dtt2.seconds
-                        if dt2>0:
+                        """if dt2>0:
                             title="rt-"+title
                             tv2avi.timetv2avi(recpath+"/"+title+".avi",chtxt,btime,etime,opt)
+                        
+                            """
                         if not os.access(recpath+"/"+title+".ts", os.F_OK):
                             recdb.del_reckey(recdb.REC_TS_DECODING, title, chtxt, btime)
                             recdb.rec_reckey(recdb.REC_MISS_DECODE, title, chtxt, btime, etime, opt)
index 6c0ea62..565b9e2 100644 (file)
@@ -5,9 +5,6 @@ import os
 import shutil
 import commands
 import configreader
-#import japanesenkf
-import random
-import base64
 #import re
 #import glob
 import time
@@ -35,20 +32,8 @@ def tv2tsmix(pout,ch,time):
         except:
             ""
 def tv2ts(pout,ch,csch,time):
-    #print "1"+pout
-    #print "2"+temp[0]
-    #print "3"+temp[1]
-    #tv2tsmix(temp[0]+"mix."+temp[1],ch,time)
-    #tsmix2ts(temp[0]+"mix."+temp[1],pout,csch)
-    #os.remove(temp[0]+"mix."+temp[1])
-    temp=pout.split(".")
     ext=os.path.splitext(pout)[1]#ext=".なんたら"
-    #t=base64.b16encode(pout)
-    #t=t[0:30]
     t=hashlib.md5(pout).hexdigest()
-    #m.update(pout)
-    #t=m.hexdigest()
-    #t=str(random.randint(10000,90000))
     tempt=os.path.split(pout)
     path=tempt[0]
     if len(ch)>2:#BS/CSは100とかCS??とかなので3文字以上
@@ -70,21 +55,12 @@ def tv2ts(pout,ch,csch,time):
             ""
 
 def b252ts(pout,ch,csch):
-    temp=pout.split(".")
     ext=os.path.splitext(pout)[1]#ext=".なんたら"
-    #m=hashlib.md5
-    #m.update(pout)
-    #t=m.hexdigest()
     t=hashlib.md5(pout).hexdigest()
-    #t=base64.b16encode(pout)
-    #t=t[0:30]
-    #t=str(random.randint(10000,90000))
     tempt=os.path.split(pout)
     path=tempt[0]
-    #tv2b25ts(pout+".b25",ch,time)
     b252tsmix(pout+".b25",path+"/"+t+ext)
     tsmix2ts(path+"/"+t+ext,pout,csch)
-    #os.remove(path+"/"+t+"."+temp[1])
     if os.access(pout, os.F_OK):
         try:
             os.remove(path+"/"+t+ext)
@@ -93,36 +69,22 @@ def b252ts(pout,ch,csch):
 
 def tv2b25ts(pout,ch,time):
     exe=configreader.getpath('recpt1')
-    #print exe+' '+ch
     doexe=exe+' '+ch+' '+time+' \''+pout+'\''
-    #print doexe
     os.system(doexe)
 def tv2b25ts_b25(pout,ch,time):
     exe=configreader.getpath('recpt1')
-    #print exe+' '+ch
     doexe=exe+' --b25 '+ch+' '+time+' \''+pout+'\''
-    #print doexe
     os.system(doexe)
 def b252tsmix(pin,pout):
-    #print "t1"
     exe=configreader.getpath('b25')
     doexe=exe.encode('utf-8')+u' \''+pin.encode('utf-8')+u'\' \''+pout.encode('utf-8')+u'\''
-    #print doexe
     doexe="/usr/bin/nice -n 17 "+doexe
     txt=commands.getoutput(doexe)
-
-    #os.system(doexe)
-    #print "t2"
 def tsmix2ts(pin,pout,csch):#csch=0ならcsの処理をしない
     wine=configreader.getpath('wine')
     exe=configreader.getpath('splitt')
     if csch == "0":
         time.sleep(1)
-        #mvexe="mv \'"+outpath+"\' \'"+pout+"\'"
-        #print mvexe
-        #print outpath
-        #os.rename(outpath,pout)
-        #i=0
         shutil.move(pin.encode('utf-8'),pout.encode('utf-8'))
     else:
         csopt='-CS'+str(csch)+" "
index cebfb10..b30add2 100644 (file)
@@ -4,6 +4,7 @@
 # Copyright (C) 2009 Yukikaze
 #import sys
 #import os
+import zenhan
 import xml.parsers.expat
 import sqlite3
 #import xml.sax as sax
@@ -49,27 +50,21 @@ def createDB(path):
         db.execute('create table ch (bctype TEXT,channel TEXT NOT NULL,display TEXT)')
     except:
         test=""
-    #db.commit()
-    #db.close()
-    #return db
-def writetvDB(datetv):#tvdateは(放送種別,チャンネル,start,stop,title,desc)の形式
+def writetvDB(bctype,channel,start,stop,title,desc):#tvdateは(放送種別,チャンネル,start,stop,title,desc)の形式
     global db
-    #db=sqlite3.connect(fpath)
-    #print datetv
-    db.execute('insert into tv values '+datetv)
-    #db.commit
-    #return db
-    #db.commit()
-    #db.close()
+    try:
+        db.execute('insert into tv values (?,?,?,?,?,?)',(bctype,channel,start,stop,title,desc))
+    except:
+        print "xml2db-error(writetvDB):"+"'insert into tv values '"+title
+def writetvDB_bef(datetv):#tvdateは(放送種別,チャンネル,start,stop,title,desc)の形式
+    global db
+    try:
+        db.execute('insert into tv values '+datetv)
+    except:
+        print "xml2db-error(writetvDB):"+"'insert into tv values '"+datetv
 def writechDB(datech):#tvdateは(チャンネル,display)の形式
     global db
-    #db=sqlite3.connect(fpath)
-    #print datech
     db.execute('insert into ch values '+datech)
-    #db.commit
-    #return db
-    #db.commit()
-    #db.close()
 def parseDocument(p,xmlfile):
     f=open(xmlfile,'r')
     p.ParseFile(f)
@@ -84,7 +79,7 @@ def end_element(name):
     global flags,lastflag,xmldate,db
     if flags[name]==1: 
         if name=="channel":
-            xmld="(\'"+bctype+"\',\'"+xmldate['channel:id']+"\',\'"+xmldate['display-name']+"\')"
+            xmld="(\""+bctype+"\",\""+xmldate['channel:id']+"\",\""+xmldate['display-name']+"\")"
             xmld=unicode(xmld)
             writechDB(xmld)
             xmldate['channel:id']=""
@@ -92,10 +87,13 @@ def end_element(name):
             #xmldate={}
             #print xmld
         elif name=="programme":
-            
-            xmld="(\'"+bctype+"\',\'"+xmldate['programme:channel']+"\',\'"+xmldate['programme:start'].replace(" +0900","")+"\',\'"+xmldate['programme:stop'].replace(" +0900","")+"\',\'"+xmldate['title'].replace(",","-")+"\',\'"+xmldate['desc']+"\')"
-            xmld=unicode(xmld)
-            writetvDB(xmld)
+            ubctype=unicode(bctype)
+            uch=unicode(xmldate['programme:channel'])
+            ustart=unicode(xmldate['programme:start'].replace(" +0900",""))
+            ustop=unicode(xmldate['programme:stop'].replace(" +0900",""))
+            utitle=unicode(xmldate['title'].replace(",","-"))
+            udesc=unicode(xmldate['desc'])
+            writetvDB(ubctype,uch,ustart,ustop,utitle,udesc)
             #print xmld
             xmldate['title']=""
             xmldate['desc']=""
@@ -109,27 +107,22 @@ def end_element(name):
             db.commit()
             db.close()
     flags[name]=0
-def char_data(date):
+def char_data(data):
     global flags,lastflag,xmldate
-    #string=str(date)
-    date=date.replace("\n","")
-    #date=date.replace(" ","")
-    #date=date.replace("(","[")
-    #date=date.replace(")","]")
-    #date=date.replace("(","[")
-    #date=date.replace(")","]")
-    date=date.replace("\"","")
-    date=date.replace("\'","")
-    date=date.encode('utf-8')
-    #date=string
+    data=data.replace("\n","")
+    data=data.replace("  ","")
+    data=data.replace("\"","")
+    data=data.replace("\'","")
+    try:
+        datat=zenhan.toHankaku(data)
+    except:
+        datat=data
+    data=datat.encode('utf-8')
     if xmldate.has_key(lastflag):
-        if xmldate[lastflag]!=date:
-            xmldate[lastflag]+=date
+        if xmldate[lastflag]!=data:
+            xmldate[lastflag]+=data
     else:
-        xmldate[lastflag]=date
-    #if lastflag=='category':
-    #print date
-    #print xmldate
+        xmldate[lastflag]=data
 
 
 
index d5f5c96..9c9c26e 100644 (file)
@@ -7,8 +7,8 @@ global z_ascii
 global h_ascii
 global z_number
 global h_number
-z_ascii=u"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz !”#$%&’()*+,−./:;<=>?@[¥]^_‘{|}〜"
-h_ascii=u"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz !\"#$%&'()*+,-./:;<=>?@[\]^_`{|}~"
+z_ascii=u"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz !”#$%&’()*+,−./:;<=>?@[¥]^_‘{|}〜 "
+h_ascii=u"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz !\"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ "
 z_number=u"0123456789"
 h_number=u"0123456789"
 def toHankaku(str):