From 3eb045690f6357dc4879711d9edb1856b72a0576 Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Fri, 1 Aug 2014 18:17:04 +0930 Subject: [PATCH] move external subs after transcoding. --- nzbtomedia/transcoder/transcoder.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/nzbtomedia/transcoder/transcoder.py b/nzbtomedia/transcoder/transcoder.py index a6b386f0..383d8814 100644 --- a/nzbtomedia/transcoder/transcoder.py +++ b/nzbtomedia/transcoder/transcoder.py @@ -460,14 +460,6 @@ def Transcode_directory(dirName): # transcoding files may remove the original file, so make sure to extract subtitles first if nzbtomedia.SEXTRACT: extract_subs(file, newfilePath, bitbucket) - if nzbtomedia.SUBSDIR: - for sub in get_subs(file): - name = os.path.splitext(os.path.split(file)[1])[0] - subname = os.path.split(sub)[1] - newname = os.path.splitext(os.path.split(newfilePath)[1])[0] - newpath = os.path.join(nzbtomedia.SUBSDIR, subname.replace(name, newname)) - if not os.path.isfile(newpath): - os.rename(sub, newpath) try: # Try to remove the file that we're transcoding to just in case. (ffmpeg will return an error if it already exists for some reason) os.remove(newfilePath) @@ -488,6 +480,15 @@ def Transcode_directory(dirName): except: logger.error("Transcoding of video %s has failed" % (file)) + if nzbtomedia.SUBSDIR: + for sub in get_subs(file): + name = os.path.splitext(os.path.split(file)[1])[0] + subname = os.path.split(sub)[1] + newname = os.path.splitext(os.path.split(newfilePath)[1])[0] + newpath = os.path.join(nzbtomedia.SUBSDIR, subname.replace(name, newname)) + if not os.path.isfile(newpath): + os.rename(sub, newpath) + if result == 0: try: shutil.copymode(file, newfilePath)