3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009-2010 Yukikaze
15 recordedpath=unicode(configreader.getpath("recorded"),'utf-8')
16 recpath=unicode(configreader.getpath("recpath"),'utf-8')
18 if __name__ == "__main__":
19 usage="usage: %prog read -h"
21 parser=optparse.OptionParser(usage=usage,version=version)
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)")
23 parser.add_option("-A","--Auto",action="store_true",dest="auto",default=False,help="auto classifying mode(not a test)")
24 parser.add_option("-D","--Delete",action="store_true",dest="delete",default=False,help="auto delete tempfile mode(not a test)")
25 parser.add_option("-e","--exec",action="store",type="string",dest="etitle",default="",metavar="TITLE",help="exec move(not a test)")
26 parser.add_option("-l","--list",action="store_true",dest="list",default=False,help="File listing mode(test for -A)")
27 parser.add_option("-t","--tssearch",action="store_true",dest="tssearch",default=False,help="Ts move auto search")
28 parser.add_option("-T","--Tsmove",action="store_true",dest="tsmove",default=False,help="Ts auto move.")
29 parser.add_option("-S","--SeriesNum",action="store",type="string",dest="seriespath",default="",metavar="TITLE",help="Search Series Number in the path.")
30 #parser.add_option("-f","--filenumlist",action="store_true",dest="filenumlist",default=False,help="Guess Program Number.")
32 (opts,args)=parser.parse_args(sys.argv)
33 if opts.ltitle!="":##-sの場合
34 ltitle=unicode(opts.ltitle,'utf-8')
35 sf=guess.searchFolder(ltitle, recordedpath)
37 recdblist.printutf8(os.path.join(sf, auto_move.get_move_dest_path(ltitle,recpath,sf,".mkv")+".mkv"))
40 recdblist.printutf8(os.path.join(sf, auto_move.get_move_dest_path(ltitle,recpath,sf,".mp4")+".mp4"))
42 elif opts.auto:##-A の場合
43 sa=auto_move.search_file(recpath, recordedpath, ".mkv")
45 recdblist.printutf8(u"自動推測実行中-MKV")
46 sf=guess.searchFolder(t,recordedpath)
48 recdblist.printutf8(u"移動先")
49 recdblist.printutf8(t+" : "+os.path.join(sf, auto_move.get_move_dest_path(t, recpath,sf,".mkv")+".mkv"))
50 recdblist.printutf8(u"実行中")
51 auto_move.execMove(t, recpath, recordedpath,".mkv",1)
53 recdblist.printutf8(t+" can't find matching folder")
54 sa=auto_move.search_file(recpath, recordedpath, ".mp4")
56 recdblist.printutf8(u"自動推測実行中-MP4")
57 sf=guess.searchFolder(t,recordedpath)
59 recdblist.printutf8(u"移動先")
60 recdblist.printutf8(t+" : "+os.path.join(sf, auto_move.get_move_dest_path(t, recpath,sf,".mp4")+".mp4"))
61 recdblist.printutf8(u"実行中")
62 auto_move.execMove(t, recpath, recordedpath,".mp4",1)
64 recdblist.printutf8(t+" can't find matching folder")
66 sa=auto_move.search_file(recpath, recordedpath,".mkv")
68 auto_move.execDelete(t, recpath)
69 sa=auto_move.search_file(recpath, recordedpath,".mp4")
71 auto_move.execDelete(t, recpath)
72 elif opts.list:##-lの場合
73 sa=auto_move.search_file(recpath, recordedpath,".mkv")
75 sf=guess.searchFolder(t,recordedpath)
77 recdblist.printutf8(t+u" : "+os.path.join(sf, auto_move.get_move_dest_path(t, recpath,sf,".mkv")+".mkv"))
78 sa=auto_move.search_file(recpath, recordedpath,".mp4")
80 sf=guess.searchFolder(t,recordedpath)
82 recdblist.printutf8(t+u" : "+os.path.join(sf, auto_move.get_move_dest_path(t, recpath,sf,".mp4")+".mp4"))
84 if os.path.exists(os.path.join(recpath, etitle+".mkv")):
85 auto_move.execMove(etitle,recpath, recordedpath,".mkv",1)
86 elif os.path.exists(os.path.join(recpath, etitle+".mp4")):
87 auto_move.execMove(etitle,recpath, recordedpath,".mp4",1)
88 elif opts.tssearch:## -tの場合
91 tsmovepath=unicode(configreader.getpath("ts_movepath"),'utf-8')
95 sa=auto_move.search_file(recpath, tsmovepath,".ts")
97 sf=guess.searchFolder(t,tsmovepath,700)
99 recdblist.printutf8(t+u" : "+os.path.join(sf, auto_move.get_move_dest_path(t, recpath,sf,".ts")+".ts"))
101 sa=auto_move.search_file(recpath, tsmovepath,".ts")
103 recdblist.printutf8(u"ts_movepathが設定されていません。/etc/rec10.confを設定してください。")
104 elif opts.tsmove:##-Tの場合
107 tsmovepath=unicode(configreader.getpath("ts_movepath"),'utf-8')
111 sa=auto_move.search_file(recpath, tsmovepath,".ts")
113 sf=guess.searchFolder(t,tsmovepath,700)
115 recdblist.printutf8(u"移動先")
116 recdblist.printutf8(t+" : "+os.path.join(sf, auto_move.get_move_dest_path(t, recpath,sf,".ts")+".ts"))
117 recdblist.printutf8(u"実行中")
118 auto_move.execMove(t, recpath, tsmovepath,".ts",0)
119 sa=auto_move.search_file(recpath, tsmovepath,".ts")
121 recdblist.printutf8(u"ts_movepathが設定されていません。/etc/rec10.confを設定してください。")
122 elif opts.seriespath!="":##-Sの場合##与えられたパスにシリーズがそろっているかを調べる。
123 ss=guess.detSeriesNum(opts.seriespath)
124 for sstitle, ssv in ss.iteritems():
129 for ssi,ssiv in ssv.iteritems():
137 for i in xrange(1,maxt+1,1):
141 recdblist.printutf8(sstitle+" "+str(maxt))
143 recdblist.printutf8(u"**"+sstitle+" |"+str(maxt)+"| "+nuke)