Script fixed

This commit is contained in:
nivong 2013-01-29 15:24:26 +01:00
commit e9965fa043

View file

@ -42,8 +42,6 @@ class AuthURLOpener(urllib.FancyURLopener):
def processEpisode(dirName, nzbName=None, failed=False): def processEpisode(dirName, nzbName=None, failed=False):
status = int(failed)
config = ConfigParser.ConfigParser() config = ConfigParser.ConfigParser()
configFilename = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessTV.cfg") configFilename = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessTV.cfg")
print "Loading config from", configFilename print "Loading config from", configFilename
@ -60,7 +58,6 @@ def processEpisode(dirName, nzbName=None, failed=False):
print "Could not read configuration file: ", str(e) print "Could not read configuration file: ", str(e)
sys.exit(1) sys.exit(1)
watch_dir = ""
host = config.get("SickBeard", "host") host = config.get("SickBeard", "host")
port = config.get("SickBeard", "port") port = config.get("SickBeard", "port")
username = config.get("SickBeard", "username") username = config.get("SickBeard", "username")
@ -75,46 +72,15 @@ def processEpisode(dirName, nzbName=None, failed=False):
except ConfigParser.NoOptionError: except ConfigParser.NoOptionError:
web_root = "" web_root = ""
try:
watch_dir = config.get("SickBeard", "watch_dir")
except ConfigParser.NoOptionError:
watch_dir = ""
try:
failed_fork = int(config.get("SickBeard", "failed_fork"))
except (ConfigParser.NoOptionError, ValueError):
failed_fork = 0
#allows us to specify the default watch directory and call the postproecssing on another PC with different directory structure.
if watch_dir != "":
dirName = watch_dir
params = {} params = {}
params['quiet'] = 1 params['quiet'] = 1
# if you have specified you are using development branch from fork https://github.com/Tolstyak/Sick-Beard.git params['dirName'] = dirName
if failed_fork: if nzbName != None:
params['dirName'] = dirName params['nzbName'] = nzbName
if nzbName != None:
params['nzbName'] = nzbName
params['failed'] = failed
if status:
print "The download failed. Sending 'failed' process request to SickBeard's failed branch"
else:
print "The download succeeded. Sending process request to SickBeard's failed branch"
# this is our default behaviour to work with the standard Master branch of SickBeard params['failed'] = failed
else:
params['dir'] = dirName
if nzbName != None:
params['nzbName'] = nzbName
# the standard Master bamch of SickBeard cannot process failed downloads. So Exit here.
if status:
print "The download failed. Nothing to process"
sys.exit()
else:
print "The download succeeded. Sending process request to SickBeard"
myOpener = AuthURLOpener(username, password) myOpener = AuthURLOpener(username, password)