fix extraction of .vob files.

This commit is contained in:
clinton-hall 2014-09-12 12:46:10 +09:30
parent c18dc596c2
commit 02eaf8208c

View file

@ -517,10 +517,10 @@ def ripISO(item, newDir, name, bitbucket):
result = call(cmd, stdout=bitbucket, stderr=bitbucket) result = call(cmd, stdout=bitbucket, stderr=bitbucket)
if os.path.isdir(os.path.join(temp_iso, 'VIDEO_TS')): if os.path.isdir(os.path.join(temp_iso, 'VIDEO_TS')):
vtsPath = os.path.join(temp_iso, 'VIDEO_TS') vtsPath = os.path.join(temp_iso, 'VIDEO_TS')
newFiles.extend(combineVTS(vtsPath, newDir, name)) newFiles.extend(combineVTS(vtsPath, newDir, name, bitbucket))
else: else:
logger.error("No VIDEO_TS folder found in .iso file %s" % (item), "TRANSCODER") logger.error("No VIDEO_TS folder found in .iso file %s" % (item), "TRANSCODER")
return [failure_dir] newFiles = [failure_dir]
except: except:
logger.error("Failed to mount .iso file %s" % (item), "TRANSCODER") logger.error("Failed to mount .iso file %s" % (item), "TRANSCODER")
return [failure_dir] return [failure_dir]
@ -530,52 +530,39 @@ def ripISO(item, newDir, name, bitbucket):
else: else:
cmd = ['umount', temp_iso] cmd = ['umount', temp_iso]
try: try:
logger.debug("Attempting to unmount .iso file" % (item), "TRANSCODER") logger.debug("Attempting to unmount .iso file %s" % (item), "TRANSCODER")
print_cmd(cmd) print_cmd(cmd)
result = call(cmd, stdout=bitbucket, stderr=bitbucket) result = call(cmd, stdout=bitbucket, stderr=bitbucket)
if not platform.system() == 'Windows': if not platform.system() == 'Windows':
os.unlink(temp_iso) os.unlink(temp_iso)
except: except:
logger.error("Failed to unmount .iso file" % (item), "TRANSCODER") logger.error("Failed to unmount .iso file %s" % (item), "TRANSCODER")
return newFiles return newFiles
def combineVTS(vtsPath, newDir, name, bitbucket): def combineVTS(vtsPath, newDir, name, bitbucket):
newFiles = [] newFiles = []
failure_dir = '/this/is/not/real' failure_dir = '/this/is/not/real'
for n in range(99): for n in range(99):
if platform.system() == 'Windows': files = []
cmd = ['copy', '/b']
else:
cmd = ['cat']
cmd2 = []
m = 1 m = 1
while True: while True:
if os.path.isfile(os.path.join(vtsPath, 'VTS_0%s_%s.VOB' % (str(n+1), str(m)))): if os.path.isfile(os.path.join(vtsPath, 'VTS_0%s_%s.VOB' % (str(n+1), str(m)))):
cmd.append(os.path.join(vtsPath, 'VTS_0%s_%s.VOB' % (str(n+1), str(m)))) files.append(os.path.join(vtsPath, 'VTS_0%s_%s.VOB' % (str(n+1), str(m))))
m += 1 m += 1
else: else:
break break
if not cmd2: if not files:
break break
elif platform.system() == 'Windows': logger.debug("Attempting to extract video track %s from disk image" % (str(n+1)), "TRANSCODER")
for e in cmd2:
cmd.append(e)
cmd.append('+')
cmd.pop()
else:
cmd.extend(cmd2)
logger.debug("Attempting to extract video track %s from disk image" % (str(n)), "TRANSCODER")
newfile = os.path.join(newDir, '%s.cd%s.vob' % (name, str(n+1))) newfile = os.path.join(newDir, '%s.cd%s.vob' % (name, str(n+1)))
if platform.system() == 'Windows':
cmd.append(newfile)
else:
cmd.extend(['>', newfile])
try: try:
print_cmd(cmd) f = open(newfile, "wb")
result = call(cmd, stdout=bitbucket, stderr=bitbucket) for file in files:
shutil.copyfileobj(open(file, 'rb'), f)
f.close()
newFiles.append(newfile) newFiles.append(newfile)
except: except:
logger.debug("Failed to extract video track %s from disk image" % (str(n)), "TRANSCODER") logger.debug("Failed to extract video track %s from disk image" % (str(n+1)), "TRANSCODER")
return [failure_dir] return [failure_dir]
return newFiles return newFiles
@ -605,7 +592,7 @@ def Transcode_directory(dirName):
List, remList, newList, success = processList(List, newDir, movieName, bitbucket) List, remList, newList, success = processList(List, newDir, movieName, bitbucket)
if not success: if not success:
bitbucket.close() bitbucket.close()
return final_result, dirName return 1, dirName
for file in List: for file in List:
if os.path.splitext(file)[1] in nzbtomedia.IGNOREEXTENSIONS: if os.path.splitext(file)[1] in nzbtomedia.IGNOREEXTENSIONS: