3 # Rec10 TS Recording Tools
\r
4 # Copyright (C) 2009-2011 Yukikaze
\r
15 recordedpath=unicode(configreader.getConfPath("recorded"),'utf-8')
\r
16 recpath=unicode(configreader.getConfPath("recpath"),'utf-8')
\r
18 if __name__ == "__main__":
\r
19 usage="usage: %prog read -h"
\r
20 version="%prog 0.9.4"
\r
21 parser=optparse.OptionParser(usage=usage,version=version)
\r
22 parser.add_option("-s","--search",action="store",type="string",dest="ltitle",default="",metavar="TITLE",help="test to search where the title should be contained(test for -e)")
\r
23 parser.add_option("-A","--Auto",action="store_true",dest="auto",default=False,help="auto classifying mode(not a test)")
\r
24 parser.add_option("-D","--Delete",action="store_true",dest="delete",default=False,help="auto delete tempfile mode(not a test)")
\r
25 parser.add_option("-e","--exec",action="store",type="string",dest="etitle",default="",metavar="TITLE",help="exec move(not a test)")
\r
26 parser.add_option("-l","--list",action="store_true",dest="list",default=False,help="File listing mode(test for -A)")
\r
27 parser.add_option("-t","--tssearch",action="store_true",dest="tssearch",default=False,help="Ts move auto search")
\r
28 parser.add_option("-T","--Tsmove",action="store_true",dest="tsmove",default=False,help="Ts auto move.")
\r
29 parser.add_option("-S","--SeriesNum",action="store",type="string",dest="seriespath",default="",metavar="TITLE",help="Search Series Number in the path.")
\r
30 parser.add_option("-m","--manual",action="store_true",dest="manual",default=False,help="manual classifying mode asking for y/n(not a test)")
\r
31 #parser.add_option("-f","--filenumlist",action="store_true",dest="filenumlist",default=False,help="Guess Program Number.")
\r
33 (opts,args)=parser.parse_args(sys.argv)
\r
34 if opts.ltitle!="":##-sの場合
\r
35 ltitle=unicode(opts.ltitle,'utf-8')
\r
36 sf=guess.searchFolder(ltitle, recordedpath)
\r
38 recdblist.printutf8(os.path.join(sf, auto_move.getMoveDestpath(ltitle,recpath,sf,".mkv")+".mkv"),verbose_level=100)
\r
41 recdblist.printutf8(os.path.join(sf, auto_move.getMoveDestpath(ltitle,recpath,sf,".mp4")+".mp4"),verbose_level=100)
\r
43 elif opts.auto:##-A の場合
\r
44 sa=auto_move.searchFile(recpath, recordedpath, ".mkv")
\r
46 recdblist.printutf8(u"自動推測実行中-MKV",verbose_level=100)
\r
47 sf=guess.searchFolder(t,recordedpath)
\r
49 recdblist.printutf8(u"移動先",verbose_level=100)
\r
50 recdblist.printutf8(t+" : "+os.path.join(sf, auto_move.getMoveDestpath(t, recpath,sf,".mkv")+".mkv"),verbose_level=100)
\r
51 recdblist.printutf8(u"実行中",verbose_level=100)
\r
52 auto_move.execMove(t, recpath, recordedpath,".mkv",1)
\r
54 recdblist.printutf8(t+" can't find matching folder",verbose_level=100)
\r
55 sa=auto_move.searchFile(recpath, recordedpath, ".mp4")
\r
57 recdblist.printutf8(u"自動推測実行中-MP4",verbose_level=100)
\r
58 sf=guess.searchFolder(t,recordedpath,200)
\r
60 recdblist.printutf8(u"移動先",verbose_level=100)
\r
61 recdblist.printutf8(t+" : "+os.path.join(sf, auto_move.getMoveDestpath(t, recpath,sf,".mp4")+".mp4"),verbose_level=100)
\r
62 recdblist.printutf8(u"実行中",verbose_level=100)
\r
63 auto_move.execMove(t, recpath, recordedpath,".mp4",1)
\r
65 recdblist.printutf8(t+" can't find matching folder",verbose_level=100)
\r
66 elif opts.manual:##-m の場合
\r
68 sa=auto_move.searchFile(recpath, recordedpath, ".mp4")
\r
70 sf=guess.searchFolder(t,recordedpath,200)
\r
72 recdblist.printutf8(u"○候補:"+os.path.join(sf, auto_move.getMoveDestpath(t, recpath,sf,".mp4")+".mp4"),verbose_level=100)
73 ans = raw_input("移動しますか? (y/n/h)")
75 recdblist.printutf8(u"移動を実行します",verbose_level=100)
\r
76 auto_move.execMove(t, recpath, recordedpath,".mp4",1)
78 recdblist.printutf8(u"移動を中止します",verbose_level=100)
\r
80 recdblist.printutf8(u"移動のヒント",verbose_level=100)
\r
81 recdblist.printutf8(u"FIXME:not implemented",verbose_level=100)
\r
83 recdblist.printutf8(u"×不明:"+t,verbose_level=100)
\r
84 elif opts.delete:##-Dの場合
\r
85 sa=auto_move.searchFile(recpath, recordedpath,".mkv")
\r
87 auto_move.execDelete(t, recpath)
\r
88 sa=auto_move.searchFile(recpath, recordedpath,".mp4")
\r
90 auto_move.execDelete(t, recpath)
\r
91 elif opts.list:##-lの場合
\r
92 sa=auto_move.searchFile(recpath, recordedpath,".mkv")
\r
94 sf=guess.searchFolder(t,recordedpath)
\r
96 recdblist.printutf8(t+u" : "+os.path.join(sf, auto_move.getMoveDestpath(t, recpath,sf,".mkv")+".mkv"),verbose_level=100)
\r
97 sa=auto_move.searchFile(recpath, recordedpath,".mp4")
\r
99 sf=guess.searchFolder(t,recordedpath)
\r
101 recdblist.printutf8(t+u" : "+os.path.join(sf, auto_move.getMoveDestpath(t, recpath,sf,".mp4")+".mp4"),verbose_level=100)
\r
102 elif opts.etitle!="":
\r
103 if os.path.exists(os.path.join(recpath, etitle+".mkv")):
\r
104 auto_move.execMove(etitle,recpath, recordedpath,".mkv",1)
\r
105 elif os.path.exists(os.path.join(recpath, etitle+".mp4")):
\r
106 auto_move.execMove(etitle,recpath, recordedpath,".mp4",1)
\r
107 elif opts.tssearch:## -tの場合
\r
110 tsmovepath=unicode(configreader.getConfPath("ts_movepath"),'utf-8')
\r
114 sa=auto_move.searchFile(recpath, tsmovepath,".ts")
\r
116 sf=guess.searchFolder(t,tsmovepath,700)
\r
118 recdblist.printutf8(t+u" : "+os.path.join(sf, auto_move.getMoveDestpath(t, recpath,sf,".ts")+".ts"))
\r
120 sa=auto_move.searchFile(recpath, tsmovepath,".ts")
\r
122 recdblist.printutf8(u"ts_movepathが設定されていません。/etc/rec10.confを設定してください。",verbose_level=100)
\r
123 elif opts.tsmove:##-Tの場合
\r
126 tsmovepath=unicode(configreader.getConfPath("ts_movepath"),'utf-8')
\r
130 sa=auto_move.searchFile(recpath, tsmovepath,".ts")
\r
132 sf=guess.searchFolder(t,tsmovepath,700)
\r
134 recdblist.printutf8(u"移動先",verbose_level=100)
\r
135 recdblist.printutf8(t+" : "+os.path.join(sf, auto_move.getMoveDestpath(t, recpath,sf,".ts")+".ts"),verbose_level=100)
\r
136 recdblist.printutf8(u"実行中",verbose_level=100)
\r
137 auto_move.execMove(t, recpath, tsmovepath,".ts",0)
\r
138 sa=auto_move.searchFile(recpath, tsmovepath,".ts")
\r
140 recdblist.printutf8(u"ts_movepathが設定されていません。/etc/rec10.confを設定してください。",verbose_level=100)
\r
141 elif opts.seriespath!="":##-Sの場合##与えられたパスにシリーズがそろっているかを調べる。
\r
142 ss=guess.detSeriesNum(opts.seriespath)
\r
143 for sstitle, ssv in ss.iteritems():
\r
148 for ssi,ssiv in ssv.iteritems():
\r
156 for i in xrange(1,maxt+1,1):
\r
157 if alr.count(i)==0:
\r
158 nuke=nuke+str(i)+","
\r
160 recdblist.printutf8(sstitle+" "+str(maxt))
\r
162 recdblist.printutf8(u"**"+sstitle+" |"+str(maxt)+"| "+nuke)
\r