OSDN Git Service

classify : fix DB.
authorgn64_jp <gn64@rec10.org>
Wed, 13 Nov 2013 04:26:13 +0000 (13:26 +0900)
committergn64_jp <gn64@rec10.org>
Wed, 13 Nov 2013 04:26:13 +0000 (13:26 +0900)
rec10/classify.py
rec10/dbMySQL.py

index 110b748..1b82830 100644 (file)
@@ -85,13 +85,6 @@ if __name__ == "__main__":
                 recdblist.printutf8(u"×不明:"+t,verbose_level=100)
     elif opts.rec10:##-r の場合
         # mkv無視します
-        sa=auto_move.searchFile(recpath, recordedpath, ".mp4")
-        for t in sa:
-            sf=guess.searchFolder(t,recordedpath,200)
-            if sf!="":
-                frompath = os.path.join(recpath, t + ".mp4")
-                topath = os.path.join(sf, auto_move.getMoveDestpath(t, recpath,sf,".mp4")+".mp4")
-                rec10d.rec10db.add_auto_classify(t,frompath, topath)
         dbl=rec10d.rec10db.select_move_auto_classify()
         if len(dbl)>0:
             for dbt in dbl:
@@ -100,6 +93,14 @@ if __name__ == "__main__":
                 #topath = dbt[2]
                 #t=os.path.splitext(os.path.split(frompath)[1])[0]
                 auto_move.execMove(t, recpath, recordedpath,".mp4",1)
+        rec10d.rec10db.delete_refresh_auto_classify()
+        sa=auto_move.searchFile(recpath, recordedpath, ".mp4")
+        for t in sa:
+            sf=guess.searchFolder(t,recordedpath,200)
+            if sf!="":
+                frompath = os.path.join(recpath, t + ".mp4")
+                topath = os.path.join(sf, auto_move.getMoveDestpath(t, recpath,sf,".mp4")+".mp4")
+                rec10d.rec10db.add_auto_classify(t,frompath, topath) 
     elif opts.delete:##-Dの場合
         sa=auto_move.searchFile(recpath, recordedpath,".mkv")
         for t in sa:
index 9f37bf5..7c862e0 100644 (file)
@@ -1244,7 +1244,8 @@ vim         ")
             title VARCHAR(1024),\
             frompath VARCHAR(1024),\
             topath VARCHAR(1024),\
-            do BOOLEAN\
+            do BOOLEAN,\
+            UNIQUE key (title),\
             )')
         except Exception, inst:
             if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationalError and inst[0]==1050)):
@@ -1257,6 +1258,12 @@ vim         ")
         values (%s,%s,%s,0)', \
                       (title,frompath, topath))
         self.close_db(db)
+    def delete_refresh_auto_classify(self):
+        db = self.connect_db()
+        db[1].execute("\
+        DROP TABLE auto_classify")
+        self.close_db(db)
+        self.new_auto_classify()
     def delete_old_auto_classify(self, frompath):
         db = self.connect_db()
         db[1].execute("\