3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009 Yukikaze
7 __date__ ="$2009/09/14 17:38:25$"
18 recordedpath=configreader.getpath("recorded")
19 recpath=configreader.getpath("recpath")
22 録画フォルダを検索し、各QUEの実行状況を表示する
24 b25list = glob.glob(path + "/*.b25")
26 ##b25f is title.ts.b25 avi is title.avi
27 dir = os.path.split(b25f)[0]
28 title = os.path.split(b25f)[1]
29 title = title.replace(".ts.b25", "")
30 avipath = os.path.join(dir, title + ".avi")
31 tspath = os.path.join(dir, title + ".ts")
32 b25f = b25f.replace(".ts.b25", ".avi")
34 if os.path.isfile(tspath):##tsファイルが存在している
35 dtime = time.time()-os.path.getmtime(tspath)
38 if os.path.getsize(tspath) > 1 * 1000 * 1000:##最終更新から22分以上経過かつ1MB以上
44 if os.path.isfile(avipath):##tsファイルが存在している
45 dtime = time.time()-os.path.getmtime(avipath)
48 if os.path.getsize(avipath) > 1 * 1000 * 1000:##最終更新から22分以上経過かつ1MB以上
54 print title + ":" + mode
55 def search_avi(temppath,recpath):
56 avilist = glob.glob(temppath + "/*.avi")
59 ##b25f is title.ts.b25 avi is title.avi
60 dir = os.path.split(avif)[0]
61 title = os.path.split(avif)[1]
62 title = title.replace(".avi", "")
63 avipath = os.path.join(dir, title + ".avi")
64 tspath = os.path.join(dir, title + ".ts")
65 b25path = os.path.join(dir, title + ".ts.b25")
66 b25logpath = os.path.join(dir, title + ".ts.b25.log")
67 sapath = os.path.join(dir, title + ".sa.avi")
68 dtime = time.time()-os.path.getmtime(avipath)
70 #print title+str(dtime)
72 if veryfySize(avipath):
73 sf=searchFolder(title,recpath)
75 ret.append([title,sf])
78 vsize=[297,596,458,916]
81 if os.path.getsize(path)>(size-5)*1024*1024 and os.path.getsize(path)<(size+5)*1024*1024:
84 def searchFolder(title,path):
85 folderpath=os.listdir(path)
89 fullpath=os.path.join(path, ft)
90 if os.path.isdir(fullpath):
91 lfpath.append(fullpath)
92 ftt=os.listdir(fullpath)
95 folderpath.append(os.path.join(fullpath, ft2))
97 lfpath.append(fullpath)
101 if os.path.isdir(dirp):
102 cmpp=os.path.dirname(dirp)
105 cmpp=os.path.basename(dirp)
106 appp=os.path.dirname(dirp)
107 p=n_gram.trigram(title.decode("utf-8"),cmpp.decode("utf-8"))
109 ngram.append((p,appp))
110 ngram=list(set(ngram))
120 def execMove(title,temppath,recpath):
122 def detName(title,temppath,recpath):
123 dstpath=os.path.join(recpath,title+".avi")
124 srcpath=os.path.join(temppath,title+".avi")
126 if os.path.exists(dstpath):
127 gmtime=time.gmtime(os.path.getmtime(srcpath))
128 times=time.strftime("%y%m%d",gmtime)
129 title=title+"_"+times
131 if __name__ == "__main__":
132 usage="usage: %prog [-l Title] [-a]"
133 version="%prog 0.7.0alpha"
134 parser=optparse.OptionParser(usage=usage,version=version)
135 parser.add_option("-s","--search",action="store",type="string",dest="ltitle",default="",metavar="TITLE",help="test to search where the title should be contained.")
136 parser.add_option("-a",action="store_true",dest="auto",default=False,help="auto disposing mode")
137 parser.add_option("-l","--list",action="store_true",dest="list",default=False,help="File listing mode")
138 (opts,args)=parser.parse_args(sys.argv)
140 searchFolder(opts.ltitle, "/home/ftpusr/ftp4/録画終了/")
144 sa=search_avi(recpath, recordedpath)
146 print s[0]+" : "+os.path.join(s[1], detName(s[0], recpath,s[1])+".avi")