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("-f","--filenumlist",action="store_true",dest="filenumlist",default=False,help="Guess Program Number.")
\r
32 (opts,args)=parser.parse_args(sys.argv)
\r
33 if opts.ltitle!="":##-sの場合
\r
34 ltitle=unicode(opts.ltitle,'utf-8')
\r
35 sf=guess.searchFolder(ltitle, recordedpath)
\r
37 recdblist.printutf8(os.path.join(sf, auto_move.getMoveDestpath(ltitle,recpath,sf,".mkv")+".mkv"),verbose_level=100)
\r
40 recdblist.printutf8(os.path.join(sf, auto_move.getMoveDestpath(ltitle,recpath,sf,".mp4")+".mp4"),verbose_level=100)
\r
42 elif opts.auto:##-A の場合
\r
43 sa=auto_move.searchFile(recpath, recordedpath, ".mkv")
\r
45 recdblist.printutf8(u"自動推測実行中-MKV",verbose_level=100)
\r
46 sf=guess.searchFolder(t,recordedpath)
\r
48 recdblist.printutf8(u"移動先",verbose_level=100)
\r
49 recdblist.printutf8(t+" : "+os.path.join(sf, auto_move.getMoveDestpath(t, recpath,sf,".mkv")+".mkv"),verbose_level=100)
\r
50 recdblist.printutf8(u"実行中",verbose_level=100)
\r
51 auto_move.execMove(t, recpath, recordedpath,".mkv",1)
\r
53 recdblist.printutf8(t+" can't find matching folder",verbose_level=100)
\r
54 sa=auto_move.searchFile(recpath, recordedpath, ".mp4")
\r
56 recdblist.printutf8(u"自動推測実行中-MP4",verbose_level=100)
\r
57 sf=guess.searchFolder(t,recordedpath)
\r
59 recdblist.printutf8(u"移動先",verbose_level=100)
\r
60 recdblist.printutf8(t+" : "+os.path.join(sf, auto_move.getMoveDestpath(t, recpath,sf,".mp4")+".mp4"),verbose_level=100)
\r
61 recdblist.printutf8(u"実行中",verbose_level=100)
\r
62 auto_move.execMove(t, recpath, recordedpath,".mp4",1)
\r
64 recdblist.printutf8(t+" can't find matching folder",verbose_level=100)
\r
65 elif opts.delete:##-Dの場合
\r
66 sa=auto_move.searchFile(recpath, recordedpath,".mkv")
\r
68 auto_move.execDelete(t, recpath)
\r
69 sa=auto_move.searchFile(recpath, recordedpath,".mp4")
\r
71 auto_move.execDelete(t, recpath)
\r
72 elif opts.list:##-lの場合
\r
73 sa=auto_move.searchFile(recpath, recordedpath,".mkv")
\r
75 sf=guess.searchFolder(t,recordedpath)
\r
77 recdblist.printutf8(t+u" : "+os.path.join(sf, auto_move.getMoveDestpath(t, recpath,sf,".mkv")+".mkv"),verbose_level=100)
\r
78 sa=auto_move.searchFile(recpath, recordedpath,".mp4")
\r
80 sf=guess.searchFolder(t,recordedpath)
\r
82 recdblist.printutf8(t+u" : "+os.path.join(sf, auto_move.getMoveDestpath(t, recpath,sf,".mp4")+".mp4"),verbose_level=100)
\r
83 elif opts.etitle!="":
\r
84 if os.path.exists(os.path.join(recpath, etitle+".mkv")):
\r
85 auto_move.execMove(etitle,recpath, recordedpath,".mkv",1)
\r
86 elif os.path.exists(os.path.join(recpath, etitle+".mp4")):
\r
87 auto_move.execMove(etitle,recpath, recordedpath,".mp4",1)
\r
88 elif opts.tssearch:## -tの場合
\r
91 tsmovepath=unicode(configreader.getConfPath("ts_movepath"),'utf-8')
\r
95 sa=auto_move.searchFile(recpath, tsmovepath,".ts")
\r
97 sf=guess.searchFolder(t,tsmovepath,700)
\r
99 recdblist.printutf8(t+u" : "+os.path.join(sf, auto_move.getMoveDestpath(t, recpath,sf,".ts")+".ts"))
\r
101 sa=auto_move.searchFile(recpath, tsmovepath,".ts")
\r
103 recdblist.printutf8(u"ts_movepathが設定されていません。/etc/rec10.confを設定してください。",verbose_level=100)
\r
104 elif opts.tsmove:##-Tの場合
\r
107 tsmovepath=unicode(configreader.getConfPath("ts_movepath"),'utf-8')
\r
111 sa=auto_move.searchFile(recpath, tsmovepath,".ts")
\r
113 sf=guess.searchFolder(t,tsmovepath,700)
\r
115 recdblist.printutf8(u"移動先",verbose_level=100)
\r
116 recdblist.printutf8(t+" : "+os.path.join(sf, auto_move.getMoveDestpath(t, recpath,sf,".ts")+".ts"),verbose_level=100)
\r
117 recdblist.printutf8(u"実行中",verbose_level=100)
\r
118 auto_move.execMove(t, recpath, tsmovepath,".ts",0)
\r
119 sa=auto_move.searchFile(recpath, tsmovepath,".ts")
\r
121 recdblist.printutf8(u"ts_movepathが設定されていません。/etc/rec10.confを設定してください。",verbose_level=100)
\r
122 elif opts.seriespath!="":##-Sの場合##与えられたパスにシリーズがそろっているかを調べる。
\r
123 ss=guess.detSeriesNum(opts.seriespath)
\r
124 for sstitle, ssv in ss.iteritems():
\r
129 for ssi,ssiv in ssv.iteritems():
\r
137 for i in xrange(1,maxt+1,1):
\r
138 if alr.count(i)==0:
\r
139 nuke=nuke+str(i)+","
\r
141 recdblist.printutf8(sstitle+" "+str(maxt))
\r
143 recdblist.printutf8(u"**"+sstitle+" |"+str(maxt)+"| "+nuke)
\r