OSDN Git Service

classify.py : add a mode that stores data in rec10 db.
authorLong.inus <long.inus@hotmail.co.jp>
Sat, 27 Apr 2013 15:48:22 +0000 (00:48 +0900)
committerLong.inus <long.inus@hotmail.co.jp>
Sat, 27 Apr 2013 15:49:28 +0000 (00:49 +0900)
rec10/classify.py
rec10/dbMySQL.py

index a496f1b..c8525ec 100644 (file)
@@ -12,6 +12,7 @@ import configreader
 import recdblist
 import auto_move
 import guess
+import rec10d
 recordedpath=unicode(configreader.getConfPath("recorded"),'utf-8')
 recpath=unicode(configreader.getConfPath("recpath"),'utf-8')
 
@@ -28,6 +29,7 @@ if __name__ == "__main__":
     parser.add_option("-T","--Tsmove",action="store_true",dest="tsmove",default=False,help="Ts auto move.")
     parser.add_option("-S","--SeriesNum",action="store",type="string",dest="seriespath",default="",metavar="TITLE",help="Search Series Number in the path.")
     parser.add_option("-m","--manual",action="store_true",dest="manual",default=False,help="manual classifying mode asking for y/n(not a test)")
+    parser.add_option("-r","--rec10",action="store_true",dest="rec10",default=False,help="save moving plan in SQL table")
     #parser.add_option("-f","--filenumlist",action="store_true",dest="filenumlist",default=False,help="Guess Program Number.")
 
     (opts,args)=parser.parse_args(sys.argv)
@@ -81,6 +83,15 @@ if __name__ == "__main__":
                     recdblist.printutf8(u"FIXME:not implemented",verbose_level=100)
             else:
                 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(frompath, topath)
     elif opts.delete:##-Dの場合
         sa=auto_move.searchFile(recpath, recordedpath,".mkv")
         for t in sa:
index cce2e86..f2c4a88 100644 (file)
@@ -1233,6 +1233,34 @@ vim         ")
         WHERE \
         btime < DATE_SUB(now(),INTERVAL " + dhour + " HOUR )")
         self.close_db(db)
+    def new_auto_classify(self):
+        db = self.connect_db()
+        try:
+            db[1].execute('\
+            CREATE TABLE auto_classify \
+            (\
+            frompath VARCHAR(1024),\
+            topath VARCHAR(1024),\
+            do BOOLEAN\
+            )')
+        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_auto_classify (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
+    def add_auto_classify(self, frompath="", topath=""):
+        db = self.connect_db()
+        db[1].execute('\
+        INSERT IGNORE into auto_classify \
+        (frompath,topath,do) \
+        values (%s,%s,0)', \
+                      (frompath, topath))
+        self.close_db(db)
+    def delete_old_auto_classify(self, frompath):
+        db = self.connect_db()
+        db[1].execute("\
+        DELETE FROM auto_classify \
+        WHERE \
+        frompath == %s", (frompath))
+        self.close_db(db)
     def update_db_to93(self):
         db = self.connect_db()
         self.drop_in_settings()