OSDN Git Service

convert CRLF to LF
[rec10/rec10-git.git] / rec10 / trunk / src / classify.py
index 6dfab35..a496f1b 100644 (file)
@@ -1,7 +1,7 @@
 #!/usr/bin/python
 # coding: UTF-8
 # Rec10 TS Recording Tools
-# Copyright (C) 2009-2010 Yukikaze
+# Copyright (C) 2009-2011 Yukikaze
 
 import os
 import os.path
@@ -12,8 +12,8 @@ import configreader
 import recdblist
 import auto_move
 import guess
-recordedpath=unicode(configreader.getpath("recorded"),'utf-8')
-recpath=unicode(configreader.getpath("recpath"),'utf-8')
+recordedpath=unicode(configreader.getConfPath("recorded"),'utf-8')
+recpath=unicode(configreader.getConfPath("recpath"),'utf-8')
 
 if __name__ == "__main__":
     usage="usage: %prog read -h"
@@ -27,6 +27,7 @@ if __name__ == "__main__":
     parser.add_option("-t","--tssearch",action="store_true",dest="tssearch",default=False,help="Ts move auto search")
     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("-f","--filenumlist",action="store_true",dest="filenumlist",default=False,help="Guess Program Number.")
 
     (opts,args)=parser.parse_args(sys.argv)
@@ -34,52 +35,70 @@ if __name__ == "__main__":
         ltitle=unicode(opts.ltitle,'utf-8')
         sf=guess.searchFolder(ltitle, recordedpath)
         print "###MKV###"
-        recdblist.printutf8(os.path.join(sf, auto_move.get_move_dest_path(ltitle,recpath,sf,".mkv")+".mkv"),verbose_level=100)
+        recdblist.printutf8(os.path.join(sf, auto_move.getMoveDestpath(ltitle,recpath,sf,".mkv")+".mkv"),verbose_level=100)
         print "\n"
         print "###MP4###"
-        recdblist.printutf8(os.path.join(sf, auto_move.get_move_dest_path(ltitle,recpath,sf,".mp4")+".mp4"),verbose_level=100)
+        recdblist.printutf8(os.path.join(sf, auto_move.getMoveDestpath(ltitle,recpath,sf,".mp4")+".mp4"),verbose_level=100)
         print "\n"
     elif opts.auto:##-A の場合
-        sa=auto_move.search_file(recpath, recordedpath, ".mkv")
+        sa=auto_move.searchFile(recpath, recordedpath, ".mkv")
         for t in sa:
             recdblist.printutf8(u"自動推測実行中-MKV",verbose_level=100)
             sf=guess.searchFolder(t,recordedpath)
             if sf!="":
                 recdblist.printutf8(u"移動先",verbose_level=100)
-                recdblist.printutf8(t+" : "+os.path.join(sf, auto_move.get_move_dest_path(t, recpath,sf,".mkv")+".mkv"),verbose_level=100)
+                recdblist.printutf8(t+" : "+os.path.join(sf, auto_move.getMoveDestpath(t, recpath,sf,".mkv")+".mkv"),verbose_level=100)
                 recdblist.printutf8(u"実行中",verbose_level=100)
                 auto_move.execMove(t, recpath, recordedpath,".mkv",1)
             else:
                 recdblist.printutf8(t+" can't find matching folder",verbose_level=100)
-        sa=auto_move.search_file(recpath, recordedpath, ".mp4")
+        sa=auto_move.searchFile(recpath, recordedpath, ".mp4")
         for t in sa:
             recdblist.printutf8(u"自動推測実行中-MP4",verbose_level=100)
-            sf=guess.searchFolder(t,recordedpath)
+            sf=guess.searchFolder(t,recordedpath,200)
             if sf!="":
                 recdblist.printutf8(u"移動先",verbose_level=100)
-                recdblist.printutf8(t+" : "+os.path.join(sf, auto_move.get_move_dest_path(t, recpath,sf,".mp4")+".mp4"),verbose_level=100)
+                recdblist.printutf8(t+" : "+os.path.join(sf, auto_move.getMoveDestpath(t, recpath,sf,".mp4")+".mp4"),verbose_level=100)
                 recdblist.printutf8(u"実行中",verbose_level=100)
                 auto_move.execMove(t, recpath, recordedpath,".mp4",1)
             else:
                 recdblist.printutf8(t+" can't find matching folder",verbose_level=100)
+    elif opts.manual:##-m の場合
+        # mkv無視します
+        sa=auto_move.searchFile(recpath, recordedpath, ".mp4")
+        for t in sa:
+            sf=guess.searchFolder(t,recordedpath,200)
+            if sf!="":
+                recdblist.printutf8(u"○候補:"+os.path.join(sf, auto_move.getMoveDestpath(t, recpath,sf,".mp4")+".mp4"),verbose_level=100)
+                ans = raw_input("移動しますか? (y/n/h)")
+                if ans == 'y':
+                    recdblist.printutf8(u"移動を実行します",verbose_level=100)
+                    auto_move.execMove(t, recpath, recordedpath,".mp4",1)
+                elif ans == 'n':
+                    recdblist.printutf8(u"移動を中止します",verbose_level=100)
+                elif ans == 'h':
+                    recdblist.printutf8(u"移動のヒント",verbose_level=100)
+                    recdblist.printutf8(u"FIXME:not implemented",verbose_level=100)
+            else:
+                recdblist.printutf8(u"×不明:"+t,verbose_level=100)
     elif opts.delete:##-Dの場合
-        sa=auto_move.search_file(recpath, recordedpath,".mkv")
+        sa=auto_move.searchFile(recpath, recordedpath,".mkv")
         for t in sa:
             auto_move.execDelete(t, recpath)
-        sa=auto_move.search_file(recpath, recordedpath,".mp4")
+        sa=auto_move.searchFile(recpath, recordedpath,".mp4")
         for t in sa:
             auto_move.execDelete(t, recpath)
     elif opts.list:##-lの場合
-        sa=auto_move.search_file(recpath, recordedpath,".mkv")
+        sa=auto_move.searchFile(recpath, recordedpath,".mkv")
         for t in sa:
             sf=guess.searchFolder(t,recordedpath)
             if sf!="":
-                recdblist.printutf8(t+u" : "+os.path.join(sf, auto_move.get_move_dest_path(t, recpath,sf,".mkv")+".mkv"),verbose_level=100)
-        sa=auto_move.search_file(recpath, recordedpath,".mp4")
+                recdblist.printutf8(t+u" : "+os.path.join(sf, auto_move.getMoveDestpath(t, recpath,sf,".mkv")+".mkv"),verbose_level=100)
+        sa=auto_move.searchFile(recpath, recordedpath,".mp4")
         for t in sa:
             sf=guess.searchFolder(t,recordedpath)
             if sf!="":
-                recdblist.printutf8(t+u" : "+os.path.join(sf, auto_move.get_move_dest_path(t, recpath,sf,".mp4")+".mp4"),verbose_level=100)
+                recdblist.printutf8(t+u" : "+os.path.join(sf, auto_move.getMoveDestpath(t, recpath,sf,".mp4")+".mp4"),verbose_level=100)
     elif opts.etitle!="":
         if os.path.exists(os.path.join(recpath, etitle+".mkv")):
             auto_move.execMove(etitle,recpath, recordedpath,".mkv",1)
@@ -88,35 +107,35 @@ if __name__ == "__main__":
     elif opts.tssearch:## -tの場合
         tsmovepath=""
         try:
-            tsmovepath=unicode(configreader.getpath("ts_movepath"),'utf-8')
+            tsmovepath=unicode(configreader.getConfPath("ts_movepath"),'utf-8')
         except:
             ""
         if tsmovepath!="":
-            sa=auto_move.search_file(recpath, tsmovepath,".ts")
+            sa=auto_move.searchFile(recpath, tsmovepath,".ts")
             for t in sa:
                 sf=guess.searchFolder(t,tsmovepath,700)
                 if sf!="":
-                    recdblist.printutf8(t+u" : "+os.path.join(sf, auto_move.get_move_dest_path(t, recpath,sf,".ts")+".ts"))
+                    recdblist.printutf8(t+u" : "+os.path.join(sf, auto_move.getMoveDestpath(t, recpath,sf,".ts")+".ts"))
                     print "\n"
-            sa=auto_move.search_file(recpath, tsmovepath,".ts")
+            sa=auto_move.searchFile(recpath, tsmovepath,".ts")
         else:
             recdblist.printutf8(u"ts_movepathが設定されていません。/etc/rec10.confを設定してください。",verbose_level=100)
     elif opts.tsmove:##-Tの場合
         tsmovepath=""
         try:
-            tsmovepath=unicode(configreader.getpath("ts_movepath"),'utf-8')
+            tsmovepath=unicode(configreader.getConfPath("ts_movepath"),'utf-8')
         except:
             ""
         if tsmovepath!="":
-            sa=auto_move.search_file(recpath, tsmovepath,".ts")
+            sa=auto_move.searchFile(recpath, tsmovepath,".ts")
             for t in sa:
                 sf=guess.searchFolder(t,tsmovepath,700)
                 if sf!="":
                     recdblist.printutf8(u"移動先",verbose_level=100)
-                    recdblist.printutf8(t+" : "+os.path.join(sf, auto_move.get_move_dest_path(t, recpath,sf,".ts")+".ts"),verbose_level=100)
+                    recdblist.printutf8(t+" : "+os.path.join(sf, auto_move.getMoveDestpath(t, recpath,sf,".ts")+".ts"),verbose_level=100)
                     recdblist.printutf8(u"実行中",verbose_level=100)
                     auto_move.execMove(t, recpath, tsmovepath,".ts",0)
-            sa=auto_move.search_file(recpath, tsmovepath,".ts")
+            sa=auto_move.searchFile(recpath, tsmovepath,".ts")
         else:
             recdblist.printutf8(u"ts_movepathが設定されていません。/etc/rec10.confを設定してください。",verbose_level=100)
     elif opts.seriespath!="":##-Sの場合##与えられたパスにシリーズがそろっているかを調べる。
@@ -141,5 +160,3 @@ if __name__ == "__main__":
                     recdblist.printutf8(sstitle+" "+str(maxt))
                 else:
                     recdblist.printutf8(u"**"+sstitle+" |"+str(maxt)+"| "+nuke)
-
-