mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-22 14:13:33 -07:00
Add Mounting of iso files as fall-back #1588
This commit is contained in:
parent
008768e479
commit
88190dca13
1 changed files with 44 additions and 4 deletions
|
@ -643,13 +643,46 @@ def process_list(it, new_dir, bitbucket):
|
||||||
return it, rem_list, new_list, success
|
return it, rem_list, new_list, success
|
||||||
|
|
||||||
|
|
||||||
|
def mount_iso(item, new_dir, bitbucket): #Currently only supports Linux Mount when permissions allow.
|
||||||
|
mount_point = os.path.join(os.path.dirname(os.path.abspath(item)),'temp')
|
||||||
|
make_dir(mount_point)
|
||||||
|
cmd = ['mount', '-o', 'loop', item, mount_point]
|
||||||
|
print_cmd(cmd)
|
||||||
|
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=bitbucket)
|
||||||
|
out, err = proc.communicate()
|
||||||
|
core.MOUNTED = mount_point # Allows us to verify this has been done and then cleanup.
|
||||||
|
for root, dirs, files in os.walk(mount_point):
|
||||||
|
for file in files:
|
||||||
|
full_path = os.path.join(root, file)
|
||||||
|
if re.match('.+VTS_[0-9][0-9]_[0-9].[Vv][Oo][Bb]', full_path) and '.vob' not in core.IGNOREEXTENSIONS:
|
||||||
|
logger.debug('Found VIDEO_TS image file: {0}'.format(full_path), 'TRANSCODER')
|
||||||
|
try:
|
||||||
|
vts_path = re.match('(.+VIDEO_TS)', full_path).groups()[0]
|
||||||
|
except Exception:
|
||||||
|
vts_path = os.path.split(full_path)[0]
|
||||||
|
return combine_vts(vts_path)
|
||||||
|
elif re.match('.+BDMV[/\\]SOURCE[/\\][0-9]+[0-9].[Mm][Tt][Ss]', full_path) and '.mts' not in core.IGNOREEXTENSIONS:
|
||||||
|
logger.debug('Found MTS image file: {0}'.format(full_path), 'TRANSCODER')
|
||||||
|
try:
|
||||||
|
mts_path = re.match('(.+BDMV[/\\]SOURCE)', full_path).groups()[0]
|
||||||
|
except Exception:
|
||||||
|
mts_path = os.path.split(full_path)[0]
|
||||||
|
return combine_mts(mts_path)
|
||||||
|
logger.error('No VIDEO_TS or BDMV/SOURCE folder found in image file {0}'.format(item), 'TRANSCODER')
|
||||||
|
return [] # If we got here, nothing matched our criteria
|
||||||
|
|
||||||
|
|
||||||
def rip_iso(item, new_dir, bitbucket):
|
def rip_iso(item, new_dir, bitbucket):
|
||||||
new_files = []
|
new_files = []
|
||||||
failure_dir = 'failure'
|
failure_dir = 'failure'
|
||||||
# Mount the ISO in your OS and call combineVTS.
|
# Mount the ISO in your OS and call combineVTS.
|
||||||
if not core.SEVENZIP:
|
if not core.SEVENZIP:
|
||||||
logger.error('No 7zip installed. Can\'t extract image file {0}'.format(item), 'TRANSCODER')
|
logger.debug('No 7zip installed. Attempting to mount image file {0}'.format(item), 'TRANSCODER')
|
||||||
new_files = [failure_dir]
|
try:
|
||||||
|
new_files = mount_iso(item, new_dir, bitbucket) # Currently only works for Linux.
|
||||||
|
except Exception:
|
||||||
|
logger.error('Failed to mount and extract from image file {0}'.format(item), 'TRANSCODER')
|
||||||
|
new_files = [failure_dir]
|
||||||
return new_files
|
return new_files
|
||||||
cmd = [core.SEVENZIP, 'l', item]
|
cmd = [core.SEVENZIP, 'l', item]
|
||||||
try:
|
try:
|
||||||
|
@ -714,8 +747,8 @@ def rip_iso(item, new_dir, bitbucket):
|
||||||
name = os.path.splitext(os.path.split(item)[1])[0]
|
name = os.path.splitext(os.path.split(item)[1])[0]
|
||||||
new_files.append({item: {'name': name, 'files': combined}})
|
new_files.append({item: {'name': name, 'files': combined}})
|
||||||
if not new_files:
|
if not new_files:
|
||||||
logger.error('No VIDEO_TS or BDMV/SOURCE folder found in image file {0}'.format(item), 'TRANSCODER')
|
logger.error('No VIDEO_TS or BDMV/SOURCE folder found in image file. Attempting to mount and scan {0}'.format(item), 'TRANSCODER')
|
||||||
new_files = [failure_dir]
|
new_files = mount_iso(item, new_dir, bitbucket)
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.error('Failed to extract from image file {0}'.format(item), 'TRANSCODER')
|
logger.error('Failed to extract from image file {0}'.format(item), 'TRANSCODER')
|
||||||
new_files = [failure_dir]
|
new_files = [failure_dir]
|
||||||
|
@ -871,6 +904,13 @@ def transcode_directory(dir_name):
|
||||||
logger.error('Transcoding of video to {0} failed with result {1}'.format(newfile_path, result))
|
logger.error('Transcoding of video to {0} failed with result {1}'.format(newfile_path, result))
|
||||||
# this will be 0 (successful) it all are successful, else will return a positive integer for failure.
|
# this will be 0 (successful) it all are successful, else will return a positive integer for failure.
|
||||||
final_result = final_result + result
|
final_result = final_result + result
|
||||||
|
if core.MOUNTED: # In case we mounted an .iso file, unmount here.
|
||||||
|
cmd = ['umount', core.MOUNTED] # currently for Linux only.
|
||||||
|
print_cmd(cmd)
|
||||||
|
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=bitbucket)
|
||||||
|
out, err = proc.communicate()
|
||||||
|
os.unlink(core.MOUNTED)
|
||||||
|
core.MOUNTED = None
|
||||||
if final_result == 0 and not core.DUPLICATE:
|
if final_result == 0 and not core.DUPLICATE:
|
||||||
for file in rem_list:
|
for file in rem_list:
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue