+++ /dev/null
-#!/usr/bin/python\r
-# coding: UTF-8\r
-# Rec10 TS Recording Tools\r
-# Copyright (C) 2009-2011 Yukikaze\r
-\r
-import os\r
-import os.path\r
-import optparse\r
-import sys\r
-\r
-import configreader\r
-import recdblist\r
-import auto_move\r
-import guess\r
-recordedpath=unicode(configreader.getConfPath("recorded"),'utf-8')\r
-recpath=unicode(configreader.getConfPath("recpath"),'utf-8')\r
-\r
-if __name__ == "__main__":\r
- usage="usage: %prog read -h"\r
- version="%prog 0.9.4"\r
- parser=optparse.OptionParser(usage=usage,version=version)\r
- 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
- parser.add_option("-A","--Auto",action="store_true",dest="auto",default=False,help="auto classifying mode(not a test)")\r
- parser.add_option("-D","--Delete",action="store_true",dest="delete",default=False,help="auto delete tempfile mode(not a test)")\r
- parser.add_option("-e","--exec",action="store",type="string",dest="etitle",default="",metavar="TITLE",help="exec move(not a test)")\r
- parser.add_option("-l","--list",action="store_true",dest="list",default=False,help="File listing mode(test for -A)")\r
- parser.add_option("-t","--tssearch",action="store_true",dest="tssearch",default=False,help="Ts move auto search")\r
- parser.add_option("-T","--Tsmove",action="store_true",dest="tsmove",default=False,help="Ts auto move.")\r
- parser.add_option("-S","--SeriesNum",action="store",type="string",dest="seriespath",default="",metavar="TITLE",help="Search Series Number in the path.")\r
- #parser.add_option("-f","--filenumlist",action="store_true",dest="filenumlist",default=False,help="Guess Program Number.")\r
-\r
- (opts,args)=parser.parse_args(sys.argv)\r
- if opts.ltitle!="":##-sの場合\r
- ltitle=unicode(opts.ltitle,'utf-8')\r
- sf=guess.searchFolder(ltitle, recordedpath)\r
- print "###MKV###"\r
- recdblist.printutf8(os.path.join(sf, auto_move.getMoveDestpath(ltitle,recpath,sf,".mkv")+".mkv"),verbose_level=100)\r
- print "\n"\r
- print "###MP4###"\r
- recdblist.printutf8(os.path.join(sf, auto_move.getMoveDestpath(ltitle,recpath,sf,".mp4")+".mp4"),verbose_level=100)\r
- print "\n"\r
- elif opts.auto:##-A の場合\r
- sa=auto_move.searchFile(recpath, recordedpath, ".mkv")\r
- for t in sa:\r
- recdblist.printutf8(u"自動推測実行中-MKV",verbose_level=100)\r
- sf=guess.searchFolder(t,recordedpath)\r
- if sf!="":\r
- recdblist.printutf8(u"移動先",verbose_level=100)\r
- recdblist.printutf8(t+" : "+os.path.join(sf, auto_move.getMoveDestpath(t, recpath,sf,".mkv")+".mkv"),verbose_level=100)\r
- recdblist.printutf8(u"実行中",verbose_level=100)\r
- auto_move.execMove(t, recpath, recordedpath,".mkv",1)\r
- else:\r
- recdblist.printutf8(t+" can't find matching folder",verbose_level=100)\r
- sa=auto_move.searchFile(recpath, recordedpath, ".mp4")\r
- for t in sa:\r
- recdblist.printutf8(u"自動推測実行中-MP4",verbose_level=100)\r
- sf=guess.searchFolder(t,recordedpath)\r
- if sf!="":\r
- recdblist.printutf8(u"移動先",verbose_level=100)\r
- recdblist.printutf8(t+" : "+os.path.join(sf, auto_move.getMoveDestpath(t, recpath,sf,".mp4")+".mp4"),verbose_level=100)\r
- recdblist.printutf8(u"実行中",verbose_level=100)\r
- auto_move.execMove(t, recpath, recordedpath,".mp4",1)\r
- else:\r
- recdblist.printutf8(t+" can't find matching folder",verbose_level=100)\r
- elif opts.delete:##-Dの場合\r
- sa=auto_move.searchFile(recpath, recordedpath,".mkv")\r
- for t in sa:\r
- auto_move.execDelete(t, recpath)\r
- sa=auto_move.searchFile(recpath, recordedpath,".mp4")\r
- for t in sa:\r
- auto_move.execDelete(t, recpath)\r
- elif opts.list:##-lの場合\r
- sa=auto_move.searchFile(recpath, recordedpath,".mkv")\r
- for t in sa:\r
- sf=guess.searchFolder(t,recordedpath)\r
- if sf!="":\r
- recdblist.printutf8(t+u" : "+os.path.join(sf, auto_move.getMoveDestpath(t, recpath,sf,".mkv")+".mkv"),verbose_level=100)\r
- sa=auto_move.searchFile(recpath, recordedpath,".mp4")\r
- for t in sa:\r
- sf=guess.searchFolder(t,recordedpath)\r
- if sf!="":\r
- recdblist.printutf8(t+u" : "+os.path.join(sf, auto_move.getMoveDestpath(t, recpath,sf,".mp4")+".mp4"),verbose_level=100)\r
- elif opts.etitle!="":\r
- if os.path.exists(os.path.join(recpath, etitle+".mkv")):\r
- auto_move.execMove(etitle,recpath, recordedpath,".mkv",1)\r
- elif os.path.exists(os.path.join(recpath, etitle+".mp4")):\r
- auto_move.execMove(etitle,recpath, recordedpath,".mp4",1)\r
- elif opts.tssearch:## -tの場合\r
- tsmovepath=""\r
- try:\r
- tsmovepath=unicode(configreader.getConfPath("ts_movepath"),'utf-8')\r
- except:\r
- ""\r
- if tsmovepath!="":\r
- sa=auto_move.searchFile(recpath, tsmovepath,".ts")\r
- for t in sa:\r
- sf=guess.searchFolder(t,tsmovepath,700)\r
- if sf!="":\r
- recdblist.printutf8(t+u" : "+os.path.join(sf, auto_move.getMoveDestpath(t, recpath,sf,".ts")+".ts"))\r
- print "\n"\r
- sa=auto_move.searchFile(recpath, tsmovepath,".ts")\r
- else:\r
- recdblist.printutf8(u"ts_movepathが設定されていません。/etc/rec10.confを設定してください。",verbose_level=100)\r
- elif opts.tsmove:##-Tの場合\r
- tsmovepath=""\r
- try:\r
- tsmovepath=unicode(configreader.getConfPath("ts_movepath"),'utf-8')\r
- except:\r
- ""\r
- if tsmovepath!="":\r
- sa=auto_move.searchFile(recpath, tsmovepath,".ts")\r
- for t in sa:\r
- sf=guess.searchFolder(t,tsmovepath,700)\r
- if sf!="":\r
- recdblist.printutf8(u"移動先",verbose_level=100)\r
- recdblist.printutf8(t+" : "+os.path.join(sf, auto_move.getMoveDestpath(t, recpath,sf,".ts")+".ts"),verbose_level=100)\r
- recdblist.printutf8(u"実行中",verbose_level=100)\r
- auto_move.execMove(t, recpath, tsmovepath,".ts",0)\r
- sa=auto_move.searchFile(recpath, tsmovepath,".ts")\r
- else:\r
- recdblist.printutf8(u"ts_movepathが設定されていません。/etc/rec10.confを設定してください。",verbose_level=100)\r
- elif opts.seriespath!="":##-Sの場合##与えられたパスにシリーズがそろっているかを調べる。\r
- ss=guess.detSeriesNum(opts.seriespath)\r
- for sstitle, ssv in ss.iteritems():\r
- if len(ssv)>0:\r
- maxt=0\r
- bt=0\r
- alr=[]\r
- for ssi,ssiv in ssv.iteritems():\r
- alr.append(ssi)\r
- if maxt<ssi:\r
- maxt=ssi\r
- alr=list(set(alr))\r
- alr.sort()\r
- alr.reverse()\r
- nuke=""\r
- for i in xrange(1,maxt+1,1):\r
- if alr.count(i)==0:\r
- nuke=nuke+str(i)+","\r
- if len(nuke)==0:\r
- recdblist.printutf8(sstitle+" "+str(maxt))\r
- else:\r
- recdblist.printutf8(u"**"+sstitle+" |"+str(maxt)+"| "+nuke)\r