OSDN Git Service

fix many bugs(thanks long.inus).
authorgn64_jp <gn64_jp@4e526526-5e11-4fc0-8910-f8fd03428081>
Sun, 22 Nov 2009 16:01:52 +0000 (16:01 +0000)
committergn64_jp <gn64_jp@4e526526-5e11-4fc0-8910-f8fd03428081>
Sun, 22 Nov 2009 16:01:52 +0000 (16:01 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/rec10@237 4e526526-5e11-4fc0-8910-f8fd03428081

rec10/trunk/src/chdata.py
rec10/trunk/src/dbMySQL.py
rec10/trunk/src/epgdb.py
rec10/trunk/src/timerec.py

index 98af554..be228c4 100644 (file)
@@ -26,15 +26,20 @@ def chadd(bctype, ontv, chtxt, ch, csch):#すべて文字列
 #chadd('放送種別','ontvコード(ontvのサイトなどで調べられる)','略称(何でもよい)','チャンネル(物理チャンネル)','CS放送の場合の内訳')
 
 #地上波の設定 東京都(筆者は東京で受信していないため正しいかどうか分かりません)
-#chadd('te26', '0442.ontvjapan.com', 'nhk-k', '26', '0')
-#chadd('te27', '0432.ontvjapan.com', 'nhk-s', '27', '0')
-#chadd('te25', '0404.ontvjapan.com', 'nittere', '25', '0')
-#chadd('te22', '0405.ontvjapan.com', 'tbs', '22', '0')
-#chadd('te23', '0406.ontvjapan.com', 'tokyo', '23', '0')
-#chadd('te21', '0407.ontvjapan.com', 'fuji', '21', '0')
-#chadd('te24', '0420.ontvjapan.com', 'asahi', '24', '0')
-#chadd('te20', '0420.ontvjapan.com', 'tokyomx', '20', '0')#よくわかりません
-#
+#chadd('te27', '0031.ontvjapan.com', 'nhk-s',   '27', '0')
+#chadd('te26', '0041.ontvjapan.com', 'nhk-k',   '26', '0')
+#chadd('te25', '0004.ontvjapan.com', 'nittere', '25', '0')
+#chadd('te22', '0005.ontvjapan.com', 'tbs',     '22', '0')
+#chadd('te21', '0006.ontvjapan.com', 'fuji',    '21', '0')
+#chadd('te24', '0007.ontvjapan.com', 'asahi',   '24', '0')
+#chadd('te23', '0008.ontvjapan.com', 'tokyo',   '23', '0')
+##chadd('te', '0009.ontvjapan.com', 'tvk',     '', '0')
+##chadd('te', '0010.ontvjapan.com', 'chiba',   '', '0')
+##chadd('te', '0011.ontvjapan.com', 'gunma',   '', '0')
+##chadd('te', '0012.ontvjapan.com', 'tama',    '', '0')
+#chadd('te28', '0013.ontvjapan.com', 'housou',  '28', '0')
+#chadd('te20', '0016.ontvjapan.com', 'mxtv',    '20', '0')
+##chadd('te', '0018.ontvjapan.com', 'tochigi', '', '0')
 #地上波の設定 愛知県向け
 chadd('te13', '0442.ontvjapan.com', 'nhk-k', '13', '0')
 chadd('te20', '0432.ontvjapan.com', 'nhk-s', '20', '0')
index dec6be7..50ce5bc 100644 (file)
@@ -642,7 +642,7 @@ class DB_MySQL:
         add_rec_num=str(add_rec_num)
         add_all_num=str(add_all_num)
         db[1].execute("\
-        UPDATE bayeskey SET ratio_rec=ratio_rec+%s,ratio_all=ratio_all+%s WHERE keychar=\"NUM\" AND chtxt=%s",\
+        UPDATE bayeskey SET ratio_rec=CONVERT(ratio_rec+%s,DECIMAL(32,14)),ratio_all=CONVERT(ratio_all+%s,DECIMAL(32,14)) WHERE keychar=\"NUM\" AND chtxt=%s",\
         (add_rec_num,add_all_num,chtxt))
         self.close_db(db)
     def change_bayeskey(self,key,chtxt,new_ratio_rec,new_ratio_all):
@@ -658,7 +658,7 @@ class DB_MySQL:
         newnum=str(newnum)
         db = self.connect_db()
         db[1].execute("\
-        UPDATE bayeskey SET ratio_all=ratio_all*%s/(%s+%s) WHERE chtxt=%s AND NOT (keychar=\"NUM\")",(beforenum,newnum,beforenum,chtxt)\
+        UPDATE bayeskey SET ratio_all=CONVERT(ratio_all*%s/(%s+%s),DECIMAL(32,14)) WHERE chtxt=%s AND NOT (keychar=\"NUM\")",(beforenum,newnum,beforenum,chtxt)\
         )
         self.close_db(db)
     def change_ratio_all_bayeskey(self,key,chtxt,beforenum,addnum):
@@ -668,7 +668,7 @@ class DB_MySQL:
         db[1].execute("INSERT INTO bayeskey (keychar,chtxt,ratio_rec,ratio_all) \
         VALUES (%s,%s,%s,%s)\
         ON DUPLICATE KEY UPDATE \
-        ratio_all=(ratio_all*%s+%s)/%s",(key,chtxt,"0",str(Decimal(addnum)/beforenumf),beforenum,chtxt,key))
+        ratio_all=CONVERT((ratio_all*%s+%s)/%s,DECIMAL(32,14))",(key,chtxt,"0",str(Decimal(addnum)/beforenumf),beforenum,chtxt,key))
         self.close_db(db)
     def change_multi_ratio_all_bayeskey(self,chtxt,beforenum,list):
         """
@@ -682,14 +682,14 @@ class DB_MySQL:
             db[1].execute("INSERT INTO bayeskey (keychar,chtxt,ratio_rec,ratio_all) \
             VALUES (%s,%s,%s,%s)\
             ON DUPLICATE KEY UPDATE \
-            ratio_all=(ratio_all*%s+%s)/%s",retl)
+            ratio_all=CONVERT((ratio_all*%s+%s)/%s,DECIMAL(32,14))",retl)
         self.close_db(db)
     def change_ratio_rec_reduce_bayeskey(self,chtxt,beforenum,newnum):
         beforenum=str(beforenum)
         newnum=str(newnum)
         db = self.connect_db()
         db[1].execute("\
-        UPDATE bayeskey SET ratio_rec=ratio_rec*%s/(%s+%s) WHERE chtxt=%s AND NOT (keychar=\"NUM\")",(beforenum,newnum,beforenum,chtxt)\
+        UPDATE bayeskey SET ratio_rec=CONVERT(ratio_rec*%s/(%s+%s),DECIMAL(32,14)) WHERE chtxt=%s AND NOT (keychar=\"NUM\")",(beforenum,newnum,beforenum,chtxt)\
         )
         self.close_db(db)
     def change_ratio_rec_bayeskey(self,key,chtxt,beforenum,addnum):
@@ -699,7 +699,7 @@ class DB_MySQL:
         db[1].execute("INSERT INTO bayeskey (keychar,chtxt,ratio_rec,ratio_all) \
         VALUES (%s,%s,%s,%s)\
         ON DUPLICATE KEY UPDATE \
-        ratio_rec=(ratio_rec*%s+%s)/%s",(key,chtxt,str(Decimal(addnum)/beforenumf),"0",beforenum,chtxt,key))
+        ratio_rec=CONVERT((ratio_rec*%s+%s)/%s,DECIMAL(32,14))",(key,chtxt,str(Decimal(addnum)/beforenumf),"0",beforenum,chtxt,key))
         self.close_db(db)
     def change_multi_ratio_rec_bayeskey(self,chtxt,beforenum,list):#self,key,chtxt,beforenum,addnum):
         beforenumf=beforenum
@@ -710,7 +710,7 @@ class DB_MySQL:
             db[1].execute("INSERT INTO bayeskey (keychar,chtxt,ratio_rec,ratio_all) \
             VALUES (%s,%s,%s,%s)\
             ON DUPLICATE KEY UPDATE \
-            ratio_rec=(ratio_rec*%s+%s)/%s",retl)
+            ratio_rec=CONVERT((ratio_rec*%s+%s)/%s,DECIMAL(32,14))",retl)
         self.close_db(db)
     def select_by_key_bayeskey(self,key,chtxt):
         db = self.connect_db()
index 77e480e..e095542 100644 (file)
@@ -24,26 +24,26 @@ def update(chtxt):
     dt = tnow-lastup
     dt = dt.days * 24 * 60 + dt.seconds
     if dt > 2 * 60 * 60:
-        ts2epg.write(tmppath + chtxt + "epgdate.xml", chdb.chtxtsearch(chtxt)['ch'])
-        xml2db.xml2db(tmppath + chtxt + "epgdate.xml", chdb.chtxtsearch(chtxt)['bctype'])
+        ts2epg.write(tmppath + chtxt + "epgdata.xml", chdb.chtxtsearch(chtxt)['ch'])
+        xml2db.xml2db(tmppath + chtxt + "epgdata.xml", chdb.chtxtsearch(chtxt)['bctype'])
 def updatebc(bctype):
     bctypel = chdb.bctypesearch(bctype)
     print bctypel
     try:
-        ts2epg.write(tmppath + bctype + "epgdate.xml", chdb.bctypesearch(bctype)['ch'])
-        xml2db.xml2db(tmppath + bctype + "epgdate.xml", bctype)
-        shutil.copyfile(tmppath + bctype + "epgdate.xml", tmppath + bctype + "epgdate.bak.xml")
+        ts2epg.write(tmppath + bctype + "epgdata.xml", chdb.bctypesearch(bctype)['ch'])
+        xml2db.xml2db(tmppath + bctype + "epgdata.xml", bctype)
+        shutil.copyfile(tmppath + bctype + "epgdata.xml", tmppath + bctype + "epgdata.bak.xml")
         rec10d.rec10db.update_by_bctype_chdata(bctype)
     except Exception, inst:
         print type(inst)
         print inst
-        xml2db.xml2db(tmppath + bctype + "epgdate.bak.xml", bctype)
+        xml2db.xml2db(tmppath + bctype + "epgdata.bak.xml", bctype)
         rec10d.rec10db.update_status_by_bctype_chdata(bctype, "2")
 def updatebc_bak(bctype):
     """
     update epg data by .bak file
     """
-    xml2db.xml2db(tmppath + bctype + "epgdate.bak.xml", bctype)
+    xml2db.xml2db(tmppath + bctype + "epgdata.bak.xml", bctype)
 def searchtime2(titletxt, timet, deltatime, chtxt):
     time = datetime.datetime.strptime(timet, "%Y-%m-%d %H:%M:%S")
     ret = []
index 80561bc..cc908a3 100644 (file)
@@ -483,6 +483,9 @@ def type_keyword_every_day(type,chtxt,title,bt,et,opt,deltatime,deltaday):
 def type_decode_que(typetxt,chtxt,title,bt,et,opt):
     btime = bt.strftime("%Y-%m-%d %H:%M:%S")
     etime = et.strftime("%Y-%m-%d %H:%M:%S")
+    tnow = datetime.datetime.now()
+    dtt = bt-tnow
+    dt = dtt.days * 24 * 60 * 60 + dtt.seconds
     typetxtnow=typetxt
     typetxting=""
     typetxtmiss=""
@@ -541,9 +544,12 @@ def type_decode_que(typetxt,chtxt,title,bt,et,opt):
                 recdb.rec_reckey(typetxtnow, title, chtxt, btime, etime, opt)
             sys.exit()
 
-def type_encode_que():
+def type_encode_que(typetxt,chtxt,title,bt,et,opt):
     btime = bt.strftime("%Y-%m-%d %H:%M:%S")
     etime = et.strftime("%Y-%m-%d %H:%M:%S")
+    tnow = datetime.datetime.now()
+    dtt = bt-tnow
+    dt = dtt.days * 24 * 60 * 60 + dtt.seconds
     typetxtnow=typetxt
     typetxting=""
     typetxtfin=""