mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-19 21:03:14 -07:00
parent
b3dc118b52
commit
f92f8f3952
1 changed files with 8 additions and 4 deletions
|
@ -28,11 +28,11 @@ def extract(file_path, output_destination):
|
||||||
wscriptlocation = os.path.join(os.environ['WINDIR'], 'system32', 'wscript.exe')
|
wscriptlocation = os.path.join(os.environ['WINDIR'], 'system32', 'wscript.exe')
|
||||||
invislocation = os.path.join(core.APP_ROOT, 'core', 'extractor', 'bin', 'invisible.vbs')
|
invislocation = os.path.join(core.APP_ROOT, 'core', 'extractor', 'bin', 'invisible.vbs')
|
||||||
cmd_7zip = [wscriptlocation, invislocation, str(core.SHOWEXTRACT), core.SEVENZIP, 'x', '-y']
|
cmd_7zip = [wscriptlocation, invislocation, str(core.SHOWEXTRACT), core.SEVENZIP, 'x', '-y']
|
||||||
ext_7zip = ['.rar', '.zip', '.tar.gz', 'tgz', '.tar.bz2', '.tbz', '.tar.lzma', '.tlz', '.7z', '.xz']
|
ext_7zip = ['.rar', '.zip', '.tar.gz', 'tgz', '.tar.bz2', '.tbz', '.tar.lzma', '.tlz', '.7z', '.xz', '.gz']
|
||||||
extract_commands = dict.fromkeys(ext_7zip, cmd_7zip)
|
extract_commands = dict.fromkeys(ext_7zip, cmd_7zip)
|
||||||
# Using unix
|
# Using unix
|
||||||
else:
|
else:
|
||||||
required_cmds = ['unrar', 'unzip', 'tar', 'unxz', 'unlzma', '7zr', 'bunzip2']
|
required_cmds = ['unrar', 'unzip', 'tar', 'unxz', 'unlzma', '7zr', 'bunzip2', 'gunzip']
|
||||||
# ## Possible future suport:
|
# ## Possible future suport:
|
||||||
# gunzip: gz (cmd will delete original archive)
|
# gunzip: gz (cmd will delete original archive)
|
||||||
# ## the following do not extract to dest dir
|
# ## the following do not extract to dest dir
|
||||||
|
@ -49,6 +49,7 @@ def extract(file_path, output_destination):
|
||||||
'.tar.lzma': ['tar', '--lzma', '-xf'], '.tlz': ['tar', '--lzma', '-xf'],
|
'.tar.lzma': ['tar', '--lzma', '-xf'], '.tlz': ['tar', '--lzma', '-xf'],
|
||||||
'.tar.xz': ['tar', '--xz', '-xf'], '.txz': ['tar', '--xz', '-xf'],
|
'.tar.xz': ['tar', '--xz', '-xf'], '.txz': ['tar', '--xz', '-xf'],
|
||||||
'.7z': ['7zr', 'x'],
|
'.7z': ['7zr', 'x'],
|
||||||
|
'.gz': ['gunzip'],
|
||||||
}
|
}
|
||||||
# Test command exists and if not, remove
|
# Test command exists and if not, remove
|
||||||
if not os.getenv('TR_TORRENT_DIR'):
|
if not os.getenv('TR_TORRENT_DIR'):
|
||||||
|
@ -82,6 +83,8 @@ def extract(file_path, output_destination):
|
||||||
# Check if this is a tar
|
# Check if this is a tar
|
||||||
if os.path.splitext(ext[0])[1] == '.tar':
|
if os.path.splitext(ext[0])[1] == '.tar':
|
||||||
cmd = extract_commands['.tar{ext}'.format(ext=ext[1])]
|
cmd = extract_commands['.tar{ext}'.format(ext=ext[1])]
|
||||||
|
else: # Try gunzip
|
||||||
|
cmd = extract_commands[ext[1]]
|
||||||
elif ext[1] in ('.1', '.01', '.001') and os.path.splitext(ext[0])[1] in ('.rar', '.zip', '.7z'):
|
elif ext[1] in ('.1', '.01', '.001') and os.path.splitext(ext[0])[1] in ('.rar', '.zip', '.7z'):
|
||||||
cmd = extract_commands[os.path.splitext(ext[0])[1]]
|
cmd = extract_commands[os.path.splitext(ext[0])[1]]
|
||||||
elif ext[1] in ('.cb7', '.cba', '.cbr', '.cbt', '.cbz'): # don't extract these comic book archives.
|
elif ext[1] in ('.cb7', '.cba', '.cbr', '.cbt', '.cbz'): # don't extract these comic book archives.
|
||||||
|
@ -128,6 +131,7 @@ def extract(file_path, output_destination):
|
||||||
else:
|
else:
|
||||||
cmd = core.NICENESS + cmd
|
cmd = core.NICENESS + cmd
|
||||||
cmd2 = cmd
|
cmd2 = cmd
|
||||||
|
if not 'gunzip' in cmd: #gunzip doesn't support password
|
||||||
cmd2.append('-p-') # don't prompt for password.
|
cmd2.append('-p-') # don't prompt for password.
|
||||||
p = Popen(cmd2, stdout=devnull, stderr=devnull, startupinfo=info) # should extract files fine.
|
p = Popen(cmd2, stdout=devnull, stderr=devnull, startupinfo=info) # should extract files fine.
|
||||||
res = p.wait()
|
res = p.wait()
|
||||||
|
@ -135,7 +139,7 @@ def extract(file_path, output_destination):
|
||||||
core.logger.info('EXTRACTOR: Extraction was successful for {file} to {destination}'.format
|
core.logger.info('EXTRACTOR: Extraction was successful for {file} to {destination}'.format
|
||||||
(file=file_path, destination=output_destination))
|
(file=file_path, destination=output_destination))
|
||||||
success = 1
|
success = 1
|
||||||
elif len(passwords) > 0:
|
elif len(passwords) > 0 and not 'gunzip' in cmd:
|
||||||
core.logger.info('EXTRACTOR: Attempting to extract with passwords')
|
core.logger.info('EXTRACTOR: Attempting to extract with passwords')
|
||||||
for password in passwords:
|
for password in passwords:
|
||||||
if password == '': # if edited in windows or otherwise if blank lines.
|
if password == '': # if edited in windows or otherwise if blank lines.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue