mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-20 13:23:18 -07:00
fixed directories and standardize os. calls
This commit is contained in:
parent
6cb1cf6a79
commit
b964e34d4e
1 changed files with 11 additions and 17 deletions
|
@ -3,8 +3,6 @@
|
||||||
import autoProcessMovie
|
import autoProcessMovie
|
||||||
import autoProcessTV
|
import autoProcessTV
|
||||||
import sys, os, ConfigParser
|
import sys, os, ConfigParser
|
||||||
from os import listdir
|
|
||||||
from os.path import isfile, join
|
|
||||||
|
|
||||||
old_stdout = sys.stdout #backup the default stdout
|
old_stdout = sys.stdout #backup the default stdout
|
||||||
log_file = open(os.path.join(os.path.dirname(sys.argv[0]), "postprocess.log"),"a+")
|
log_file = open(os.path.join(os.path.dirname(sys.argv[0]), "postprocess.log"),"a+")
|
||||||
|
@ -92,9 +90,9 @@ useLink = int(config.get("Torrent", "uselink"))
|
||||||
extractionTool = config.get("Torrent", "extractiontool")
|
extractionTool = config.get("Torrent", "extractiontool")
|
||||||
|
|
||||||
if Category == Movie_Cat:
|
if Category == Movie_Cat:
|
||||||
destination = Movie_dest
|
destination = os.path.join(Movie_dest, Name)
|
||||||
elif Category == TV_Cat:
|
elif Category == TV_Cat:
|
||||||
destination = TV_dest
|
destination = os.path.join(TV_dest, Name)
|
||||||
else:
|
else:
|
||||||
print "INFO: Not assigned a label of either", Movie_Cat, "or", TV_Cat, ". Exiting"
|
print "INFO: Not assigned a label of either", Movie_Cat, "or", TV_Cat, ". Exiting"
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
@ -148,9 +146,10 @@ elif packed == 1: ## unpack
|
||||||
else:
|
else:
|
||||||
print "ERROR: Unknown OS, exiting"
|
print "ERROR: Unknown OS, exiting"
|
||||||
|
|
||||||
files = [ f for f in listdir(Directory) if isfile(join(Directory,f)) ]
|
files = [ f for f in os.listdir(Directory) if os.path.isfile(os.path.join(Directory,f)) ]
|
||||||
for f in files:
|
for f in files:
|
||||||
ext = os.path.splitext(f["path"])
|
ext = os.path.splitext(f)
|
||||||
|
fp = os.path.join(Directory, os.path.normpath(f))
|
||||||
if ext[1] in (".gz", ".bz2", ".lzma"):
|
if ext[1] in (".gz", ".bz2", ".lzma"):
|
||||||
## 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":
|
||||||
|
@ -161,26 +160,21 @@ elif packed == 1: ## unpack
|
||||||
else:
|
else:
|
||||||
print("ERROR: Unknown file type: %s", ext[1])
|
print("ERROR: Unknown file type: %s", ext[1])
|
||||||
continue
|
continue
|
||||||
|
|
||||||
fp = os.path.join(destination, os.path.normpath(f["path"]))
|
|
||||||
|
|
||||||
## Destination path
|
## Create destination folder
|
||||||
dest = os.path.join(destination, Name)
|
if not os.path.exists(destination):
|
||||||
|
|
||||||
## Create destionation folder
|
|
||||||
if not os.path.exists(dest):
|
|
||||||
try:
|
try:
|
||||||
os.makedirs(dest)
|
os.makedirs(destination)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
print("ERROR: Not possible to create destination folder: %s", e)
|
print("ERROR: Not possible to create destination folder: %s", e)
|
||||||
return
|
return
|
||||||
|
|
||||||
print("INFO: Extracting to %s", dest)
|
print("INFO: Extracting to %s", destination)
|
||||||
|
|
||||||
|
|
||||||
## Running..
|
## Running..
|
||||||
print("INFO: Extracting %s %s %s %s", cmd[0], cmd[1], fp, dest)
|
print("INFO: Extracting %s %s %s %s", cmd[0], cmd[1], fp, destination)
|
||||||
d = getProcessValue(cmd[0], cmd[1].split() + [str(fp)], {}, str(dest))
|
d = getProcessValue(cmd[0], cmd[1].split() + [str(fp)], {}, str(destination))
|
||||||
d.addCallback(on_extract_success)
|
d.addCallback(on_extract_success)
|
||||||
d.addErrback(on_extract_failed)
|
d.addErrback(on_extract_failed)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue