X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=rec10%2Ftrunk%2Fsrc%2Ftv2mp4.py;h=2275dfc49b59e3c8c071f501d355c756d98d6881;hb=454e1e617a5a37b0915e1c44ae810adf68c76c2f;hp=e13037d9ae1c30f6d3fdc5da557f5114fe23cb15;hpb=c9410a29782606f2782cc1778d6832728b06f96c;p=rec10%2Frec10-git.git diff --git a/rec10/trunk/src/tv2mp4.py b/rec10/trunk/src/tv2mp4.py index e13037d..2275dfc 100644 --- a/rec10/trunk/src/tv2mp4.py +++ b/rec10/trunk/src/tv2mp4.py @@ -4,17 +4,19 @@ # Copyright (C) 2009-2010 Yukikaze import commands import shutil -import tv2avi +import auto_process import os import re import os.path import string import base64 import time +import subprocess + +import tv2avi import recdblist import configreader import status -import subprocess import tv2audio def ts2mp4(pin, pout, opt): @@ -57,13 +59,11 @@ def raw2mp4(pin,pout,opt): if status.getSettings_auto_del_tmp()==1: if os.path.exists(pout): if re.search(opt,"MW8") or re.search(opt,"MW9"): - if os.path.getsize(pout)>50*1000*1000: - deltitle(dir,title) + auto_process.deltmpfile(dir, title, ".mp4") elif re.search(opt,"8") or re.search(opt,"9"): "" else: - if os.path.getsize(pout)>100*1000*1000: - deltitle(dir,title) + auto_process.deltmpfile(dir, title, ".mp4") def mkv2mp4(pin,pout): exeb = configreader.getpath(u"mkvextract") exe = configreader.getpath(u"mp4Box") @@ -95,9 +95,7 @@ def mkv2mp4(pin,pout): time.sleep(10) if status.getSettings_auto_del_tmp()==1: if os.path.exists(pout): - if os.path.getsize(pout)>100*1000*1000: - deltitle(dir,title) - + auto_process.deltmpfile(dir, title, ".mp4") def addCaption(pts,pmp4):##字幕の追加を試みる。 wineexe=configreader.getpath("wine") pincap=pts.replace(".ts",".srt") @@ -118,10 +116,11 @@ def addCaption(pts,pmp4):##字幕の追加を試みる。 logt=unicode(p0.communicate()[0], "UTF-8") recdblist.addlog(pts,e0, u"Captionログ-コマンド") recdblist.addlog(pts,logt, u"Captionログ-詳細") - if os.path.getsize(pincap)>1000: - exe = configreader.getpath("mp4box") - e1s=exe +u" -add \""+pincap+"\" \""+pmp4+"\"" - addmp4(pincap,pmp4,e1s) + if os.path.exists(pincap): + if os.path.getsize(pincap)>1000: + exe = configreader.getpath("mp4box") + e1s=exe +u" -add \""+pincap+"\" \""+pmp4+"\"" + addmp4(pincap,pmp4,e1s) def addAudio(pts,pmp4,opt):#オプションに応じた音声の追加を行う exe = configreader.getpath("mp4box") if re.search("d",opt) or re.search("5",opt):#二カ国語放送/5.1ch放送の場合 @@ -197,9 +196,14 @@ def addmp4(padd,pout,cmd):#without video recdblist.addlog(pout, cmdn, u"MP4Box追加ログ-コマンド") recdblist.addlog(pout, txt, u"MP4Box追加ログ-詳細") time.sleep(5) - os.remove(ptoutb) shutil.move(ptadd,padd) - shutil.move(ptout,pout) + if os.path.exists(ptout): + shutil.move(ptout,pout) + os.remove(ptoutb) + else: + txtt=padd+u"のインポートエラー" + recdblist.addlog(pout, txtt, u"MP4Box追加ログ-コマンド") + shutil.move(ptoutb,pout) time.sleep(5) def execcomd(cmd): txt="" @@ -209,31 +213,4 @@ def execcomd(cmd): txt=txt+unicode(txt2,"utf-8")+"\n" except: "" - return txt - -def deltitle(path,title): - dp=[] - dp.append(os.path.join(path,title+".avi")) - dp.append(os.path.join(path,title+".264")) - dp.append(os.path.join(path,title+".120.avi")) - dp.append(os.path.join(path,title+".noodml.avi")) - dp.append(os.path.join(path,title+".aac")) - dp.append(os.path.join(path,title+".m2v")) - dp.append(os.path.join(path,title+"_1.aac")) - dp.append(os.path.join(path,title+"_2.aac")) - dp.append(os.path.join(path,title+"_1.mp3")) - dp.append(os.path.join(path,title+"_2.mp3")) - dp.append(os.path.join(path,title+".srt")) - if configreader.getenv("remove_ts")=="1": - dp.append(os.path.join(path,title+".ts")) - if os.path.exists(os.path.join(path,title+".ts"))and os.path.exists(os.path.join(path,title+".ts.b25")): - if os.path.getsize(os.path.join(path,title+".ts"))*10>os.path.getsize(os.path.join(path,title+".ts.b25")): - if os.path.getsize(os.path.join(path,title+".ts"))>1000*1000*100: - dp.append(os.path.join(path,title+".ts.b25")) - if os.path.exists(os.path.join(path,title+".mp4")): - if os.path.getsize(os.path.join(path,title+".mp4"))>1000*1000*10: - for ip in dp: - try: - os.remove(ip) - except: - "" + return txt \ No newline at end of file