OSDN Git Service

add logo search.
[rec10/rec10-git.git] / rec10 / trunk / src / dbMySQL.py
index b34a078..de26606 100644 (file)
@@ -97,23 +97,26 @@ class DB_MySQL:
             updatetime DATETIME,\
             status TINYINT,\
             visible TINYINT DEFAULT 1,\
-            ADD logo1 BLOB,\
-            ADD logo2 BLOB,\
-            ADD logo3 BLOB,\
-            ADD logo4 BLOB,\
-            ADD logo5 BLOB\
+            logo1 BLOB,\
+            logo2 BLOB,\
+            logo3 BLOB,\
+            logo4 BLOB,\
+            logo5 BLOB,\
+            logoupdate DATETIME,\
+            logostatus TINYINT DEFAULT 2,\
+            scanupdate DATETIME\
             )')
         except Exception, inst:
             if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationalError and inst[0]==1050)):
                 recdblist.addCommonlogEX("Error", "new_epg_ch (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
 
         self.close_db(db)
-    def add_epg_ch(self, bctype, chtxt, ch, csch, updatetime):
+    def add_epg_ch(self, bctype, chtxt, ch, csch, updatetime,logoupdate,scanupdate):
         db = self.connect_db()
         db[1].execute('\
-        INSERT INTO epg_ch \
-        VALUES (%s,%s,%s,%s,"",%s,%s,%s)', \
-                      (bctype, chtxt, ch, csch, updatetime, "1","1"))
+        INSERT INTO epg_ch (bctype,chtxt,ch,csch,chname,updatetime,status,visible,logoupdate,scanupdate)\
+        VALUES (%s,%s,%s,%s,"",%s,%s,%s,%s,%s)', \
+                      (bctype, chtxt, ch, csch, updatetime, "1","1",logoupdate,scanupdate))
         self.close_db(db)
     def delete_all_epg_ch(self):
         db = self.connect_db()
@@ -123,7 +126,7 @@ class DB_MySQL:
     def select_by_chtxt_epg_ch(self, chtxt):
         db = self.connect_db()
         dbexe = db[1].execute("\
-        SELECT bctype,chtxt,ch,csch,updatetime,chname,status,visible \
+        SELECT bctype,chtxt,ch,csch,updatetime,chname,status,visible,logoupdate,scanupdate \
         FROM epg_ch \
         WHERE chtxt LIKE %s", \
                               (chtxt,))
@@ -135,12 +138,14 @@ class DB_MySQL:
         for dl in dls:
             r = list(dl)
             r[4] = r[4].strftime("%Y-%m-%d %H:%M:%S")
+            r[8] = r[8].strftime("%Y-%m-%d %H:%M:%S")
+            r[9] = r[9].strftime("%Y-%m-%d %H:%M:%S")
             ret.append(r)
         return ret
     def select_by_bctype_epg_ch(self, bctype):
         db = self.connect_db()
         dbexe = db[1].execute("\
-        SELECT bctype,chtxt,ch,csch,updatetime,status,chname,status,visible \
+        SELECT bctype,chtxt,ch,csch,updatetime,status,chname,status,visible,logoupdate,scanupdate \
         FROM epg_ch \
         WHERE bctype = %s", \
                               (bctype,))
@@ -153,6 +158,8 @@ class DB_MySQL:
             #recdblist.printutf8(dl)
             r = list(dl)
             r[4] = r[4].strftime("%Y-%m-%d %H:%M:%S")
+            r[9] = r[9].strftime("%Y-%m-%d %H:%M:%S")
+            r[10] = r[10].strftime("%Y-%m-%d %H:%M:%S")
             r[5] = str(r[5])
             ret.append(r)
         return ret
@@ -160,7 +167,7 @@ class DB_MySQL:
         db = self.connect_db()
         dbexe = db[1].execute("\
         SELECT \
-        bctype,chtxt,ch,csch,updatetime,chname,status,visible \
+        bctype,chtxt,ch,csch,updatetime,chname,status,visible,logoupdate,scanupdate \
         FROM epg_ch \
         WHERE ch = %s", \
                               (ch,))
@@ -172,13 +179,15 @@ class DB_MySQL:
         for dl in dls:
             r = list(dl)
             r[4] = r[4].strftime("%Y-%m-%d %H:%M:%S")
+            r[8] = r[8].strftime("%Y-%m-%d %H:%M:%S")
+            r[9] = r[9].strftime("%Y-%m-%d %H:%M:%S")
             ret.append(r)
         return ret
     def select_by_csch_epg_ch(self, csch):
         db = self.connect_db()
         dbexe = db[1].execute("\
         SELECT \
-        bctype,chtxt,ch,csch,updatetime,chname,status,visible \
+        bctype,chtxt,ch,csch,updatetime,chname,status,visible,logoupdate,scanupdate \
         FROM epg_ch \
         WHERE csch = %s", \
                               (csch,))
@@ -190,12 +199,14 @@ class DB_MySQL:
         for dl in dls:
             r = list(dl)
             r[4] = r[4].strftime("%Y-%m-%d %H:%M:%S")
+            r[8] = r[8].strftime("%Y-%m-%d %H:%M:%S")
+            r[9] = r[9].strftime("%Y-%m-%d %H:%M:%S")
             ret.append(r)
         return ret
     def select_all_epg_ch(self):
         db = self.connect_db()
         dbexe = db[1].execute("\
-        SELECT bctype,chtxt,ch,csch,updatetime,chname,status,visible \
+        SELECT bctype,chtxt,ch,csch,updatetime,chname,status,visible,logoupdate,scanupdate \
         FROM epg_ch \
         ")
         ret = []
@@ -206,6 +217,8 @@ class DB_MySQL:
         for dl in dls:
             r = list(dl)
             r[4] = r[4].strftime("%Y-%m-%d %H:%M:%S")
+            r[8] = r[8].strftime("%Y-%m-%d %H:%M:%S")
+            r[9] = r[9].strftime("%Y-%m-%d %H:%M:%S")
             ret.append(r)
         return ret
     def change_visible_epg_ch(self,chtxt,visible):
@@ -213,7 +226,7 @@ class DB_MySQL:
         db[1].execute("\
         UPDATE epg_ch SET visible=%s WHERE chtxt=%s",(visible,chtxt))
         self.close_db(db)
-    def change_visible_epg_ch(self,chtxt,logonum,logodata):
+    def change_logodata_epg_ch(self,chtxt,logonum,logodata):
         db = self.connect_db()
         db[1].execute("\
         UPDATE epg_ch SET logo"+str(logonum)+"=%s WHERE chtxt=%s",(logodata,chtxt))
@@ -247,6 +260,24 @@ class DB_MySQL:
             ret = db[1].fetchall()
         self.close_db(db)
         return ret
+    def select_get_updatelogo_epg_ch(self, dhour):
+        db = self.connect_db()
+        dbexe = db[1].execute("SELECT bctype,chtxt,logostatus FROM epg_ch \
+        WHERE (\
+        ( \
+        updatetime < DATE_SUB(now(),INTERVAL " + dhour + " HOUR) \
+        AND \
+        logostatus = 1 \
+        ) \
+        OR \
+        logostatus > 1 )\
+        ORDER BY status DESC")
+        ret = []
+        #recdblist.printutf8(dbexe)
+        if dbexe > 0:
+            ret = db[1].fetchall()
+        self.close_db(db)
+        return ret
     def update_by_bctype_epg_ch(self, bctype):
         db = self.connect_db()
         db[1].execute("\
@@ -256,6 +287,7 @@ class DB_MySQL:
         status = 1 \
         WHERE bctype = %s", (bctype,))
         self.close_db(db)
+
     def update_by_bctype_and_chtxt_epg_ch(self, bctype, chtxt):
         db = self.connect_db()
         db[1].execute("\
@@ -276,14 +308,26 @@ class DB_MySQL:
                       (status, bctype)\
                       )
         self.close_db(db)
-    def update_chname_by_chtxt_epg_ch(self,chtxt,chname):
+    def update_status_by_bctype_epg_ch(self, bctype, status):
         db = self.connect_db()
         db[1].execute("\
         UPDATE epg_ch \
         SET \
-        chname=%s \
-        WHERE chtxt = %s", \
-                      (chname, chtxt)\
+        status=%s , \
+        updatetime=now() \
+        WHERE bctype = %s", \
+                      (status, bctype)\
+                      )
+        self.close_db(db)
+    def update_logostatus_by_bctype_epg_ch(self,bctype,logostatus):
+        db = self.connect_db()
+        db[1].execute("\
+        UPDATE epg_ch \
+        SET \
+        logostatus=%s , \
+        logoupdate=now() \
+        WHERE bctype = %s", \
+                      (logostatus, bctype)\
                       )
         self.close_db(db)
     def add_auto_proc_tmp(self,type,title,chtxt):
@@ -1255,20 +1299,13 @@ vim         ")
         db = self.connect_db()
         self.drop_in_settings()
         self.new_in_settings()
+        self.new_epg_ch()
         try:
             db[1].execute("\
-            ALTER TABLE epg_ch ADD logo0 BLOB,\
-            ADD logo1 BLOB,\
-            ADD logo2 BLOB,\
-            ADD logo3 BLOB,\
-            ADD logo4 BLOB,\
-            ADD logo5 BLOB\
+            ALTER TABLE timeline ADD epgcategory VARCHAR(100)\
             ")
         except:
             ""
-        db[1].execute("\
-        ALTER TABLE timeline ADD epgcategory VARCHAR(100)\
-        ")
         self.close_db(db)
-        self.change_installed_in_status()#チャンネルスキャンをさせる
+        #self.change_installed_in_status()#チャンネルスキャンをさせる
         self.change_version_in_status("101")
\ No newline at end of file