mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-19 21:03:14 -07:00
support for *nix and nt systems
This commit is contained in:
parent
ce0d4b3f23
commit
7c4e14cca0
1 changed files with 38 additions and 18 deletions
|
@ -85,25 +85,45 @@ elif useLink == 0 and packed == 0: ## hardlink
|
||||||
|
|
||||||
elif useLink == 0 and packed == 1: ## unpack
|
elif useLink == 0 and packed == 1: ## unpack
|
||||||
## 7z x test.rar ---- need to add "yes" to command
|
## 7z x test.rar ---- need to add "yes" to command
|
||||||
## Windows only for now, should be adapted to *nix
|
|
||||||
cmd_7zip = [extractionTool, 'x']
|
|
||||||
ext_7zip = [".rar",".zip",".tar.gz","tgz",".tar.bz2", ".tbz",".tar.lzma", ".tlz",".7z", ".xz"]
|
|
||||||
EXTRACT_COMMANDS = dict.fromkeys(ext_zip, cmd_7zip)
|
|
||||||
print('Found 7zip')
|
|
||||||
|
|
||||||
files = [ f for f in listdir(Directory) if isfile(join(Directory,f)) ]
|
## Using Windows?
|
||||||
for f in files:
|
if os.name == 'nt':
|
||||||
ext = os.path.splitext(f["path"])
|
cmd_7zip = [extractionTool, 'x']
|
||||||
if ext[1] in (".gz", ".bz2", ".lzma"):
|
ext_7zip = [".rar",".zip",".tar.gz","tgz",".tar.bz2", ".tbz",".tar.lzma", ".tlz",".7z", ".xz"]
|
||||||
## Check if this is a tar
|
EXTRACT_COMMANDS = dict.fromkeys(ext_zip, cmd_7zip)
|
||||||
if os.path.splitext(ext[0]) == ".tar":
|
print('Found 7zip')
|
||||||
cmd = EXTRACT_COMMANDS[".tar" + ext[1]]
|
|
||||||
else:
|
files = [ f for f in listdir(Directory) if isfile(join(Directory,f)) ]
|
||||||
if ext[1] in EXTRACT_COMMANDS:
|
for f in files:
|
||||||
cmd = EXTRACT_COMMANDS[ext[1]]
|
ext = os.path.splitext(f["path"])
|
||||||
else:
|
if ext[1] in (".gz", ".bz2", ".lzma"):
|
||||||
print("ERROR: Unknown file type: %s", ext[1])
|
## Check if this is a tar
|
||||||
continue
|
if os.path.splitext(ext[0]) == ".tar":
|
||||||
|
cmd = EXTRACT_COMMANDS[".tar" + ext[1]]
|
||||||
|
else:
|
||||||
|
if ext[1] in EXTRACT_COMMANDS:
|
||||||
|
cmd = EXTRACT_COMMANDS[ext[1]]
|
||||||
|
else:
|
||||||
|
print("ERROR: Unknown file type: %s", ext[1])
|
||||||
|
continue
|
||||||
|
## Using linux?
|
||||||
|
elif os.name == 'posix':
|
||||||
|
required_cmds=["unrar", "unzip", "tar", "unxz", "unlzma", "7zr"]
|
||||||
|
EXTRACT_COMMANDS = {
|
||||||
|
".rar": ["unrar", "x -o+ -y"],
|
||||||
|
".zip": ["unzip", ""],
|
||||||
|
".tar.gz": ["tar", "xzf"],
|
||||||
|
".tgz": ["tar", "xzf"],
|
||||||
|
".tar.bz2": ["tar", "xjf"],
|
||||||
|
".tbz": ["tar", "xjf"],
|
||||||
|
".tar.lzma": ["tar", "--lzma xf"],
|
||||||
|
".tlz": ["tar", "--lzma xf"],
|
||||||
|
".txz": ["tar", "--xz xf"],
|
||||||
|
".7z": ["7zr", "x"],
|
||||||
|
}
|
||||||
|
## Need to add check for which commands that can be utilized in Linux..
|
||||||
|
else:
|
||||||
|
print "Unknown OS, exiting"
|
||||||
|
|
||||||
fp = os.path.join(save_path, os.path.normpath(f["path"]))
|
fp = os.path.join(save_path, os.path.normpath(f["path"]))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue