fix nzbget health checks. fixes #268

This commit is contained in:
clinton-hall 2014-02-22 12:25:53 +10:30
commit 465d2fc1d4
6 changed files with 116 additions and 183 deletions

View file

@ -157,58 +157,46 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5
status = 0 status = 0
if os.environ['NZBOP_UNPACK'] != 'yes': if os.environ['NZBOP_UNPACK'] != 'yes':
Logger.error("Please enable option \"Unpack\" in nzbget configuration file, exiting") Logger.error("MAIN: Please enable option \"Unpack\" in nzbget configuration file, exiting")
sys.exit(POSTPROCESS_ERROR) sys.exit(POSTPROCESS_ERROR)
# Check par status # Check par status
if os.environ['NZBPP_PARSTATUS'] == '3': if os.environ['NZBPP_PARSTATUS'] == '3':
Logger.warning("Par-check successful, but Par-repair disabled, exiting") Logger.warning("MAIN: Par-check successful, but Par-repair disabled, exiting")
Logger.info("MAIN: Please check your Par-repair settings for future downloads.")
sys.exit(POSTPROCESS_NONE) sys.exit(POSTPROCESS_NONE)
if os.environ['NZBPP_PARSTATUS'] == '1': if os.environ['NZBPP_PARSTATUS'] == '1' or os.environ['NZBPP_PARSTATUS'] == '4':
Logger.warning("Par-check failed, setting status \"failed\"") Logger.warning("MAIN: Par-repair failed, setting status \"failed\"")
status = 1 status = 1
# Check unpack status # Check unpack status
if os.environ['NZBPP_UNPACKSTATUS'] == '1': if os.environ['NZBPP_UNPACKSTATUS'] == '1':
Logger.warning("Unpack failed, setting status \"failed\"") Logger.warning("MAIN: Unpack failed, setting status \"failed\"")
status = 1 status = 1
if os.environ['NZBPP_UNPACKSTATUS'] == '0' and os.environ['NZBPP_PARSTATUS'] != '2': if os.environ['NZBPP_UNPACKSTATUS'] == '0' and os.environ['NZBPP_PARSTATUS'] == '0':
# Unpack is disabled or was skipped due to nzb-file properties or due to errors during par-check # Unpack was skipped due to nzb-file properties or due to errors during par-check
for dirpath, dirnames, filenames in os.walk(os.environ['NZBPP_DIRECTORY']): if os.environ['NZBPP_HEALTH'] < 1000:
for file in filenames: Logger.warning("MAIN: Download health is compromised and Par-check/repair disabled or no .par2 files found. Setting status \"failed\"")
fileExtension = os.path.splitext(file)[1] Logger.info("MAIN: Please check your Par-check/repair settings for future downloads.")
if fileExtension in ['.rar', '.7z'] or os.path.splitext(fileExtension)[1] in ['.rar', '.7z']:
Logger.warning("Post-Process: Archive files exist but unpack skipped, setting status \"failed\"")
status = 1
break
if fileExtension in ['.par2']:
Logger.warning("Post-Process: Unpack skipped and par-check skipped (although par2-files exist), setting status \"failed\"g")
status = 1
break
if os.path.isfile(os.path.join(os.environ['NZBPP_DIRECTORY'], "_brokenlog.txt")) and not status == 1:
Logger.warning("Post-Process: _brokenlog.txt exists, download is probably damaged, exiting")
status = 1 status = 1
if not status == 1: else:
Logger.info("Neither archive- nor par2-files found, _brokenlog.txt doesn't exist, considering download successful") Logger.info("MAIN: Par-check/repair disabled or no .par2 files found, and Unpack not required. Health is ok so handle as though download successful")
Logger.info("MAIN: Please check your Par-check/repair settings for future downloads.")
# Check if destination directory exists (important for reprocessing of history items) # Check if destination directory exists (important for reprocessing of history items)
if not os.path.isdir(os.environ['NZBPP_DIRECTORY']): if not os.path.isdir(os.environ['NZBPP_DIRECTORY']):
Logger.error("Post-Process: Nothing to post-process: destination directory %s doesn't exist", os.environ['NZBPP_DIRECTORY']) Logger.error("MAIN: Nothing to post-process: destination directory %s doesn't exist. Setting status \"failed\"", os.environ['NZBPP_DIRECTORY'])
status = 1 status = 1
# All checks done, now launching the script. # All checks done, now launching the script.
download_id = "" download_id = ""
if os.environ.has_key('NZBPR_COUCHPOTATO'): if os.environ.has_key('NZBPR_COUCHPOTATO'):
download_id = os.environ['NZBPR_COUCHPOTATO'] download_id = os.environ['NZBPR_COUCHPOTATO']
Logger.info("Script triggered from NZBGet, starting autoProcessMovie...") Logger.info("MAIN: Script triggered from NZBGet, starting autoProcessMovie...")
clientAgent = "nzbget"
result = autoProcessMovie.process(os.environ['NZBPP_DIRECTORY'], os.environ['NZBPP_NZBNAME'], status, clientAgent, download_id) result = autoProcessMovie.process(os.environ['NZBPP_DIRECTORY'], os.environ['NZBPP_NZBNAME'], status, clientAgent, download_id)
# SABnzbd Pre 0.7.17 # SABnzbd Pre 0.7.17
elif len(sys.argv) == SABNZB_NO_OF_ARGUMENTS: elif len(sys.argv) == SABNZB_NO_OF_ARGUMENTS:
@ -220,7 +208,7 @@ elif len(sys.argv) == SABNZB_NO_OF_ARGUMENTS:
# 5 User-defined category # 5 User-defined category
# 6 Group that the NZB was posted in e.g. alt.binaries.x # 6 Group that the NZB was posted in e.g. alt.binaries.x
# 7 Status of post processing. 0 = OK, 1=failed verification, 2=failed unpack, 3=1+2 # 7 Status of post processing. 0 = OK, 1=failed verification, 2=failed unpack, 3=1+2
Logger.info("Script triggered from SABnzbd, starting autoProcessMovie...") Logger.info("MAIN: Script triggered from SABnzbd, starting autoProcessMovie...")
clientAgent = "sabnzbd" clientAgent = "sabnzbd"
result = autoProcessMovie.process(sys.argv[1], sys.argv[2], sys.argv[7], clientAgent) result = autoProcessMovie.process(sys.argv[1], sys.argv[2], sys.argv[7], clientAgent)
# SABnzbd 0.7.17+ # SABnzbd 0.7.17+
@ -234,12 +222,12 @@ elif len(sys.argv) >= SABNZB_0717_NO_OF_ARGUMENTS:
# 6 Group that the NZB was posted in e.g. alt.binaries.x # 6 Group that the NZB was posted in e.g. alt.binaries.x
# 7 Status of post processing. 0 = OK, 1=failed verification, 2=failed unpack, 3=1+2 # 7 Status of post processing. 0 = OK, 1=failed verification, 2=failed unpack, 3=1+2
# 8 Failure URL # 8 Failure URL
Logger.info("Script triggered from SABnzbd 0.7.17+, starting autoProcessMovie...") Logger.info("MAIN: Script triggered from SABnzbd 0.7.17+, starting autoProcessMovie...")
clientAgent = "sabnzbd" clientAgent = "sabnzbd"
result = autoProcessMovie.process(sys.argv[1], sys.argv[2], sys.argv[7], clientAgent) result = autoProcessMovie.process(sys.argv[1], sys.argv[2], sys.argv[7], clientAgent)
else: else:
Logger.warn("Invalid number of arguments received from client.") Logger.warn("MAIN: Invalid number of arguments received from client.")
Logger.info("Running autoProcessMovie as a manual run...") Logger.info("MAIN: Running autoProcessMovie as a manual run...")
clientAgent = "manual" clientAgent = "manual"
result = autoProcessMovie.process('Manual Run', 'Manual Run', 0, clientAgent) result = autoProcessMovie.process('Manual Run', 'Manual Run', 0, clientAgent)

View file

@ -97,54 +97,43 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5
status = 0 status = 0
if os.environ['NZBOP_UNPACK'] != 'yes': if os.environ['NZBOP_UNPACK'] != 'yes':
Logger.error("Please enable option \"Unpack\" in nzbget configuration file, exiting") Logger.error("MAIN: Please enable option \"Unpack\" in nzbget configuration file, exiting")
sys.exit(POSTPROCESS_ERROR) sys.exit(POSTPROCESS_ERROR)
# Check par status # Check par status
if os.environ['NZBPP_PARSTATUS'] == '3': if os.environ['NZBPP_PARSTATUS'] == '3':
Logger.warning("Par-check successful, but Par-repair disabled, exiting") Logger.warning("MAIN: Par-check successful, but Par-repair disabled, exiting")
Logger.info("MAIN: Please check your Par-repair settings for future downloads.")
sys.exit(POSTPROCESS_NONE) sys.exit(POSTPROCESS_NONE)
if os.environ['NZBPP_PARSTATUS'] == '1': if os.environ['NZBPP_PARSTATUS'] == '1' or os.environ['NZBPP_PARSTATUS'] == '4':
Logger.warning("Par-check failed, setting status \"failed\"") Logger.warning("MAIN: Par-repair failed, setting status \"failed\"")
status = 1 status = 1
# Check unpack status # Check unpack status
if os.environ['NZBPP_UNPACKSTATUS'] == '1': if os.environ['NZBPP_UNPACKSTATUS'] == '1':
Logger.warning("Unpack failed, setting status \"failed\"") Logger.warning("MAIN: Unpack failed, setting status \"failed\"")
status = 1 status = 1
if os.environ['NZBPP_UNPACKSTATUS'] == '0' and os.environ['NZBPP_PARSTATUS'] != '2': if os.environ['NZBPP_UNPACKSTATUS'] == '0' and os.environ['NZBPP_PARSTATUS'] == '0':
# Unpack is disabled or was skipped due to nzb-file properties or due to errors during par-check # Unpack was skipped due to nzb-file properties or due to errors during par-check
for dirpath, dirnames, filenames in os.walk(os.environ['NZBPP_DIRECTORY']): if os.environ['NZBPP_HEALTH'] < 1000:
for file in filenames: Logger.warning("MAIN: Download health is compromised and Par-check/repair disabled or no .par2 files found. Setting status \"failed\"")
fileExtension = os.path.splitext(file)[1] Logger.info("MAIN: Please check your Par-check/repair settings for future downloads.")
if fileExtension in ['.rar', '.7z'] or os.path.splitext(fileExtension)[1] in ['.rar', '.7z']:
Logger.warning("Post-Process: Archive files exist but unpack skipped, setting status \"failed\"")
status = 1
break
if fileExtension in ['.par2']:
Logger.warning("Post-Process: Unpack skipped and par-check skipped (although par2-files exist), setting status \"failed\"g")
status = 1
break
if os.path.isfile(os.path.join(os.environ['NZBPP_DIRECTORY'], "_brokenlog.txt")) and not status == 1:
Logger.warning("Post-Process: _brokenlog.txt exists, download is probably damaged, exiting")
status = 1 status = 1
if not status == 1: else:
Logger.info("Neither archive- nor par2-files found, _brokenlog.txt doesn't exist, considering download successful") Logger.info("MAIN: Par-check/repair disabled or no .par2 files found, and Unpack not required. Health is ok so handle as though download successful")
Logger.info("MAIN: Please check your Par-check/repair settings for future downloads.")
# Check if destination directory exists (important for reprocessing of history items) # Check if destination directory exists (important for reprocessing of history items)
if not os.path.isdir(os.environ['NZBPP_DIRECTORY']): if not os.path.isdir(os.environ['NZBPP_DIRECTORY']):
Logger.error("Post-Process: Nothing to post-process: destination directory %s doesn't exist", os.environ['NZBPP_DIRECTORY']) Logger.error("MAIN: Nothing to post-process: destination directory %s doesn't exist. Setting status \"failed\"", os.environ['NZBPP_DIRECTORY'])
status = 1 status = 1
# All checks done, now launching the script. # All checks done, now launching the script.
Logger.info("Script triggered from NZBGet, starting autoProcessGames...") Logger.info("MAIN: Script triggered from NZBGet, starting autoProcessGames...")
result = autoProcessGames.process(os.environ['NZBPP_DIRECTORY'], os.environ['NZBPP_NZBNAME'], status) result = autoProcessGames.process(os.environ['NZBPP_DIRECTORY'], os.environ['NZBPP_NZBNAME'], status)
# SABnzbd Pre 0.7.17 # SABnzbd Pre 0.7.17
elif len(sys.argv) == SABNZB_NO_OF_ARGUMENTS: elif len(sys.argv) == SABNZB_NO_OF_ARGUMENTS:
@ -156,7 +145,7 @@ elif len(sys.argv) == SABNZB_NO_OF_ARGUMENTS:
# 5 User-defined category # 5 User-defined category
# 6 Group that the NZB was posted in e.g. alt.binaries.x # 6 Group that the NZB was posted in e.g. alt.binaries.x
# 7 Status of post processing. 0 = OK, 1=failed verification, 2=failed unpack, 3=1+2 # 7 Status of post processing. 0 = OK, 1=failed verification, 2=failed unpack, 3=1+2
Logger.info("Script triggered from SABnzbd, starting autoProcessGames...") Logger.info("MAIN: Script triggered from SABnzbd, starting autoProcessGames...")
result = autoProcessGames.process(sys.argv[1], sys.argv[3], sys.argv[7]) result = autoProcessGames.process(sys.argv[1], sys.argv[3], sys.argv[7])
# SABnzbd 0.7.17+ # SABnzbd 0.7.17+
elif len(sys.argv) >= SABNZB_0717_NO_OF_ARGUMENTS: elif len(sys.argv) >= SABNZB_0717_NO_OF_ARGUMENTS:
@ -169,10 +158,10 @@ elif len(sys.argv) >= SABNZB_0717_NO_OF_ARGUMENTS:
# 6 Group that the NZB was posted in e.g. alt.binaries.x # 6 Group that the NZB was posted in e.g. alt.binaries.x
# 7 Status of post processing. 0 = OK, 1=failed verification, 2=failed unpack, 3=1+2 # 7 Status of post processing. 0 = OK, 1=failed verification, 2=failed unpack, 3=1+2
# 8 Failure URL # 8 Failure URL
Logger.info("Script triggered from SABnzbd 0.7.17+, starting autoProcessGames...") Logger.info("MAIN: Script triggered from SABnzbd 0.7.17+, starting autoProcessGames...")
result = autoProcessGames.process(sys.argv[1], sys.argv[3], sys.argv[7]) result = autoProcessGames.process(sys.argv[1], sys.argv[3], sys.argv[7])
else: else:
Logger.warn("Invalid number of arguments received from client. Exiting") Logger.warn("MAIN: Invalid number of arguments received from client. Exiting")
sys.exit(1) sys.exit(1)
if result == 0: if result == 0:

View file

@ -102,54 +102,43 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5
status = 0 status = 0
if os.environ['NZBOP_UNPACK'] != 'yes': if os.environ['NZBOP_UNPACK'] != 'yes':
Logger.error("Please enable option \"Unpack\" in nzbget configuration file, exiting") Logger.error("MAIN: Please enable option \"Unpack\" in nzbget configuration file, exiting")
sys.exit(POSTPROCESS_ERROR) sys.exit(POSTPROCESS_ERROR)
# Check par status # Check par status
if os.environ['NZBPP_PARSTATUS'] == '3': if os.environ['NZBPP_PARSTATUS'] == '3':
Logger.warning("Par-check successful, but Par-repair disabled, exiting") Logger.warning("MAIN: Par-check successful, but Par-repair disabled, exiting")
Logger.info("MAIN: Please check your Par-repair settings for future downloads.")
sys.exit(POSTPROCESS_NONE) sys.exit(POSTPROCESS_NONE)
if os.environ['NZBPP_PARSTATUS'] == '1': if os.environ['NZBPP_PARSTATUS'] == '1' or os.environ['NZBPP_PARSTATUS'] == '4':
Logger.warning("Par-check failed, setting status \"failed\"") Logger.warning("MAIN: Par-repair failed, setting status \"failed\"")
status = 1 status = 1
# Check unpack status # Check unpack status
if os.environ['NZBPP_UNPACKSTATUS'] == '1': if os.environ['NZBPP_UNPACKSTATUS'] == '1':
Logger.warning("Unpack failed, setting status \"failed\"") Logger.warning("MAIN: Unpack failed, setting status \"failed\"")
status = 1 status = 1
if os.environ['NZBPP_UNPACKSTATUS'] == '0' and os.environ['NZBPP_PARSTATUS'] != '2': if os.environ['NZBPP_UNPACKSTATUS'] == '0' and os.environ['NZBPP_PARSTATUS'] == '0':
# Unpack is disabled or was skipped due to nzb-file properties or due to errors during par-check # Unpack was skipped due to nzb-file properties or due to errors during par-check
for dirpath, dirnames, filenames in os.walk(os.environ['NZBPP_DIRECTORY']): if os.environ['NZBPP_HEALTH'] < 1000:
for file in filenames: Logger.warning("MAIN: Download health is compromised and Par-check/repair disabled or no .par2 files found. Setting status \"failed\"")
fileExtension = os.path.splitext(file)[1] Logger.info("MAIN: Please check your Par-check/repair settings for future downloads.")
if fileExtension in ['.rar', '.7z'] or os.path.splitext(fileExtension)[1] in ['.rar', '.7z']:
Logger.warning("Post-Process: Archive files exist but unpack skipped, setting status \"failed\"")
status = 1
break
if fileExtension in ['.par2']:
Logger.warning("Post-Process: Unpack skipped and par-check skipped (although par2-files exist), setting status \"failed\"g")
status = 1
break
if os.path.isfile(os.path.join(os.environ['NZBPP_DIRECTORY'], "_brokenlog.txt")) and not status == 1:
Logger.warning("Post-Process: _brokenlog.txt exists, download is probably damaged, exiting")
status = 1 status = 1
if not status == 1: else:
Logger.info("Neither archive- nor par2-files found, _brokenlog.txt doesn't exist, considering download successful") Logger.info("MAIN: Par-check/repair disabled or no .par2 files found, and Unpack not required. Health is ok so handle as though download successful")
Logger.info("MAIN: Please check your Par-check/repair settings for future downloads.")
# Check if destination directory exists (important for reprocessing of history items) # Check if destination directory exists (important for reprocessing of history items)
if not os.path.isdir(os.environ['NZBPP_DIRECTORY']): if not os.path.isdir(os.environ['NZBPP_DIRECTORY']):
Logger.error("Post-Process: Nothing to post-process: destination directory %s doesn't exist", os.environ['NZBPP_DIRECTORY']) Logger.error("MAIN: Nothing to post-process: destination directory %s doesn't exist. Setting status \"failed\"", os.environ['NZBPP_DIRECTORY'])
status = 1 status = 1
# All checks done, now launching the script # All checks done, now launching the script.
Logger.info("Script triggered from NZBGet, starting autoProcessMusic...") Logger.info("MAIN: Script triggered from NZBGet, starting autoProcessMusic...")
result = autoProcessMusic.process(os.environ['NZBPP_DIRECTORY'], os.environ['NZBPP_NZBNAME'], status) result = autoProcessMusic.process(os.environ['NZBPP_DIRECTORY'], os.environ['NZBPP_NZBNAME'], status)
# SABnzbd Pre 0.7.17 # SABnzbd Pre 0.7.17
elif len(sys.argv) == SABNZB_NO_OF_ARGUMENTS: elif len(sys.argv) == SABNZB_NO_OF_ARGUMENTS:
@ -161,7 +150,7 @@ elif len(sys.argv) == SABNZB_NO_OF_ARGUMENTS:
# 5 User-defined category # 5 User-defined category
# 6 Group that the NZB was posted in e.g. alt.binaries.x # 6 Group that the NZB was posted in e.g. alt.binaries.x
# 7 Status of post processing. 0 = OK, 1=failed verification, 2=failed unpack, 3=1+2 # 7 Status of post processing. 0 = OK, 1=failed verification, 2=failed unpack, 3=1+2
Logger.info("Script triggered from SABnzbd, starting autoProcessMusic...") Logger.info("MAIN: Script triggered from SABnzbd, starting autoProcessMusic...")
result = autoProcessMusic.process(sys.argv[1], sys.argv[2], sys.argv[7]) result = autoProcessMusic.process(sys.argv[1], sys.argv[2], sys.argv[7])
# SABnzbd 0.7.17+ # SABnzbd 0.7.17+
elif len(sys.argv) >= SABNZB_0717_NO_OF_ARGUMENTS: elif len(sys.argv) >= SABNZB_0717_NO_OF_ARGUMENTS:
@ -174,11 +163,11 @@ elif len(sys.argv) >= SABNZB_0717_NO_OF_ARGUMENTS:
# 6 Group that the NZB was posted in e.g. alt.binaries.x # 6 Group that the NZB was posted in e.g. alt.binaries.x
# 7 Status of post processing. 0 = OK, 1=failed verification, 2=failed unpack, 3=1+2 # 7 Status of post processing. 0 = OK, 1=failed verification, 2=failed unpack, 3=1+2
# 8 Failue URL # 8 Failue URL
Logger.info("Script triggered from SABnzbd 0.7.17+, starting autoProcessMusic...") Logger.info("MAIN: Script triggered from SABnzbd 0.7.17+, starting autoProcessMusic...")
result = autoProcessMusic.process(sys.argv[1], sys.argv[2], sys.argv[7]) result = autoProcessMusic.process(sys.argv[1], sys.argv[2], sys.argv[7])
else: else:
Logger.warn("Invalid number of arguments received from client.") Logger.warn("MAIN: Invalid number of arguments received from client.")
Logger.info("Running autoProcessMusic as a manual run...") Logger.info("MAIN: Running autoProcessMusic as a manual run...")
result = autoProcessMusic.process('Manual Run', 'Manual Run', 0) result = autoProcessMusic.process('Manual Run', 'Manual Run', 0)
if result == 0: if result == 0:

View file

@ -288,7 +288,7 @@ WakeUp()
config = ConfigParser.ConfigParser() config = ConfigParser.ConfigParser()
configFilename = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.cfg") configFilename = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.cfg")
if not os.path.isfile(configFilename): if not os.path.isfile(configFilename):
Logger.error("You need an autoProcessMedia.cfg file - did you rename and edit the .sample?") Logger.error("MAIN: You need an autoProcessMedia.cfg file - did you rename and edit the .sample?")
sys.exit(-1) sys.exit(-1)
# CONFIG FILE # CONFIG FILE
Logger.info("MAIN: Loading config from %s", configFilename) Logger.info("MAIN: Loading config from %s", configFilename)
@ -317,50 +317,39 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5
status = 0 status = 0
if os.environ['NZBOP_UNPACK'] != 'yes': if os.environ['NZBOP_UNPACK'] != 'yes':
Logger.error("Please enable option \"Unpack\" in nzbget configuration file, exiting") Logger.error("MAIN: Please enable option \"Unpack\" in nzbget configuration file, exiting")
sys.exit(POSTPROCESS_ERROR) sys.exit(POSTPROCESS_ERROR)
# Check par status # Check par status
if os.environ['NZBPP_PARSTATUS'] == '3': if os.environ['NZBPP_PARSTATUS'] == '3':
Logger.warning("Par-check successful, but Par-repair disabled, exiting") Logger.warning("MAIN: Par-check successful, but Par-repair disabled, exiting")
Logger.info("MAIN: Please check your Par-repair settings for future downloads.")
sys.exit(POSTPROCESS_NONE) sys.exit(POSTPROCESS_NONE)
if os.environ['NZBPP_PARSTATUS'] == '1': if os.environ['NZBPP_PARSTATUS'] == '1' or os.environ['NZBPP_PARSTATUS'] == '4':
Logger.warning("Par-check failed, setting status \"failed\"") Logger.warning("MAIN: Par-repair failed, setting status \"failed\"")
status = 1 status = 1
# Check unpack status # Check unpack status
if os.environ['NZBPP_UNPACKSTATUS'] == '1': if os.environ['NZBPP_UNPACKSTATUS'] == '1':
Logger.warning("Unpack failed, setting status \"failed\"") Logger.warning("MAIN: Unpack failed, setting status \"failed\"")
status = 1 status = 1
if os.environ['NZBPP_UNPACKSTATUS'] == '0' and os.environ['NZBPP_PARSTATUS'] != '2': if os.environ['NZBPP_UNPACKSTATUS'] == '0' and os.environ['NZBPP_PARSTATUS'] == '0':
# Unpack is disabled or was skipped due to nzb-file properties or due to errors during par-check # Unpack was skipped due to nzb-file properties or due to errors during par-check
for dirpath, dirnames, filenames in os.walk(os.environ['NZBPP_DIRECTORY']): if os.environ['NZBPP_HEALTH'] < 1000:
for file in filenames: Logger.warning("MAIN: Download health is compromised and Par-check/repair disabled or no .par2 files found. Setting status \"failed\"")
fileExtension = os.path.splitext(file)[1] Logger.info("MAIN: Please check your Par-check/repair settings for future downloads.")
if fileExtension in ['.rar', '.7z'] or os.path.splitext(fileExtension)[1] in ['.rar', '.7z']:
Logger.warning("Post-Process: Archive files exist but unpack skipped, setting status \"failed\"")
status = 1
break
if fileExtension in ['.par2']:
Logger.warning("Post-Process: Unpack skipped and par-check skipped (although par2-files exist), setting status \"failed\"g")
status = 1
break
if os.path.isfile(os.path.join(os.environ['NZBPP_DIRECTORY'], "_brokenlog.txt")) and not status == 1:
Logger.warning("Post-Process: _brokenlog.txt exists, download is probably damaged, exiting")
status = 1 status = 1
if not status == 1: else:
Logger.info("Neither archive- nor par2-files found, _brokenlog.txt doesn't exist, considering download successful") Logger.info("MAIN: Par-check/repair disabled or no .par2 files found, and Unpack not required. Health is ok so handle as though download successful")
Logger.info("MAIN: Please check your Par-check/repair settings for future downloads.")
# Check if destination directory exists (important for reprocessing of history items) # Check if destination directory exists (important for reprocessing of history items)
if not os.path.isdir(os.environ['NZBPP_DIRECTORY']): if not os.path.isdir(os.environ['NZBPP_DIRECTORY']):
Logger.error("Post-Process: Nothing to post-process: destination directory %s doesn't exist", os.environ['NZBPP_DIRECTORY']) Logger.error("MAIN: Nothing to post-process: destination directory %s doesn't exist. Setting status \"failed\"", os.environ['NZBPP_DIRECTORY'])
status = 1 status = 1
# All checks done, now launching the script. # All checks done, now launching the script.

View file

@ -100,54 +100,43 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5
status = 0 status = 0
if os.environ['NZBOP_UNPACK'] != 'yes': if os.environ['NZBOP_UNPACK'] != 'yes':
Logger.error("Please enable option \"Unpack\" in nzbget configuration file, exiting") Logger.error("MAIN: Please enable option \"Unpack\" in nzbget configuration file, exiting")
sys.exit(POSTPROCESS_ERROR) sys.exit(POSTPROCESS_ERROR)
# Check par status # Check par status
if os.environ['NZBPP_PARSTATUS'] == '3': if os.environ['NZBPP_PARSTATUS'] == '3':
Logger.warning("Par-check successful, but Par-repair disabled, exiting") Logger.warning("MAIN: Par-check successful, but Par-repair disabled, exiting")
Logger.info("MAIN: Please check your Par-repair settings for future downloads.")
sys.exit(POSTPROCESS_NONE) sys.exit(POSTPROCESS_NONE)
if os.environ['NZBPP_PARSTATUS'] == '1': if os.environ['NZBPP_PARSTATUS'] == '1' or os.environ['NZBPP_PARSTATUS'] == '4':
Logger.warning("Par-check failed, setting status \"failed\"") Logger.warning("MAIN: Par-repair failed, setting status \"failed\"")
status = 1 status = 1
# Check unpack status # Check unpack status
if os.environ['NZBPP_UNPACKSTATUS'] == '1': if os.environ['NZBPP_UNPACKSTATUS'] == '1':
Logger.warning("Unpack failed, setting status \"failed\"") Logger.warning("MAIN: Unpack failed, setting status \"failed\"")
status = 1 status = 1
if os.environ['NZBPP_UNPACKSTATUS'] == '0' and os.environ['NZBPP_PARSTATUS'] != '2': if os.environ['NZBPP_UNPACKSTATUS'] == '0' and os.environ['NZBPP_PARSTATUS'] == '0':
# Unpack is disabled or was skipped due to nzb-file properties or due to errors during par-check # Unpack was skipped due to nzb-file properties or due to errors during par-check
for dirpath, dirnames, filenames in os.walk(os.environ['NZBPP_DIRECTORY']): if os.environ['NZBPP_HEALTH'] < 1000:
for file in filenames: Logger.warning("MAIN: Download health is compromised and Par-check/repair disabled or no .par2 files found. Setting status \"failed\"")
fileExtension = os.path.splitext(file)[1] Logger.info("MAIN: Please check your Par-check/repair settings for future downloads.")
if fileExtension in ['.rar', '.7z'] or os.path.splitext(fileExtension)[1] in ['.rar', '.7z']:
Logger.warning("Post-Process: Archive files exist but unpack skipped, setting status \"failed\"")
status = 1
break
if fileExtension in ['.par2']:
Logger.warning("Post-Process: Unpack skipped and par-check skipped (although par2-files exist), setting status \"failed\"g")
status = 1
break
if os.path.isfile(os.path.join(os.environ['NZBPP_DIRECTORY'], "_brokenlog.txt")) and not status == 1:
Logger.warning("Post-Process: _brokenlog.txt exists, download is probably damaged, exiting")
status = 1 status = 1
if not status == 1: else:
Logger.info("Neither archive- nor par2-files found, _brokenlog.txt doesn't exist, considering download successful") Logger.info("MAIN: Par-check/repair disabled or no .par2 files found, and Unpack not required. Health is ok so handle as though download successful")
Logger.info("MAIN: Please check your Par-check/repair settings for future downloads.")
# Check if destination directory exists (important for reprocessing of history items) # Check if destination directory exists (important for reprocessing of history items)
if not os.path.isdir(os.environ['NZBPP_DIRECTORY']): if not os.path.isdir(os.environ['NZBPP_DIRECTORY']):
Logger.error("Post-Process: Nothing to post-process: destination directory %s doesn't exist", os.environ['NZBPP_DIRECTORY']) Logger.error("MAIN: Nothing to post-process: destination directory %s doesn't exist. Setting status \"failed\"", os.environ['NZBPP_DIRECTORY'])
status = 1 status = 1
# All checks done, now launching the script. # All checks done, now launching the script.
Logger.info("Script triggered from NZBGet, starting autoProcessComics...") Logger.info("MAIN: Script triggered from NZBGet, starting autoProcessComics...")
result = autoProcessComics.processEpisode(os.environ['NZBPP_DIRECTORY'], os.environ['NZBPP_NZBNAME'], status) result = autoProcessComics.processEpisode(os.environ['NZBPP_DIRECTORY'], os.environ['NZBPP_NZBNAME'], status)
# SABnzbd Pre 0.7.17 # SABnzbd Pre 0.7.17
elif len(sys.argv) == SABNZB_NO_OF_ARGUMENTS: elif len(sys.argv) == SABNZB_NO_OF_ARGUMENTS:
@ -159,7 +148,7 @@ elif len(sys.argv) == SABNZB_NO_OF_ARGUMENTS:
# 5 User-defined category # 5 User-defined category
# 6 Group that the NZB was posted in e.g. alt.binaries.x # 6 Group that the NZB was posted in e.g. alt.binaries.x
# 7 Status of post processing. 0 = OK, 1=failed verification, 2=failed unpack, 3=1+2 # 7 Status of post processing. 0 = OK, 1=failed verification, 2=failed unpack, 3=1+2
Logger.info("Script triggered from SABnzbd, starting autoProcessComics...") Logger.info("MAIN: Script triggered from SABnzbd, starting autoProcessComics...")
result = autoProcessComics.processEpisode(sys.argv[1], sys.argv[3], sys.argv[7]) result = autoProcessComics.processEpisode(sys.argv[1], sys.argv[3], sys.argv[7])
# SABnzbd 0.7.17+ # SABnzbd 0.7.17+
elif len(sys.argv) >= SABNZB_0717_NO_OF_ARGUMENTS: elif len(sys.argv) >= SABNZB_0717_NO_OF_ARGUMENTS:
@ -172,11 +161,11 @@ elif len(sys.argv) >= SABNZB_0717_NO_OF_ARGUMENTS:
# 6 Group that the NZB was posted in e.g. alt.binaries.x # 6 Group that the NZB was posted in e.g. alt.binaries.x
# 7 Status of post processing. 0 = OK, 1=failed verification, 2=failed unpack, 3=1+2 # 7 Status of post processing. 0 = OK, 1=failed verification, 2=failed unpack, 3=1+2
# 8 Failure URL # 8 Failure URL
Logger.info("Script triggered from SABnzbd 0.7.17+, starting autoProcessComics...") Logger.info("MAIN: Script triggered from SABnzbd 0.7.17+, starting autoProcessComics...")
result = autoProcessComics.processEpisode(sys.argv[1], sys.argv[3], sys.argv[7]) result = autoProcessComics.processEpisode(sys.argv[1], sys.argv[3], sys.argv[7])
else: else:
Logger.warn("Invalid number of arguments received from client.") Logger.warn("MAIN: Invalid number of arguments received from client.")
Logger.info("Running autoProcessComics as a manual run...") Logger.info("MAIN: Running autoProcessComics as a manual run...")
result = autoProcessComics.processEpisode('Manual Run', 'Manual Run', 0) result = autoProcessComics.processEpisode('Manual Run', 'Manual Run', 0)
if result == 0: if result == 0:

View file

@ -159,54 +159,43 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5
status = 0 status = 0
if os.environ['NZBOP_UNPACK'] != 'yes': if os.environ['NZBOP_UNPACK'] != 'yes':
Logger.error("Please enable option \"Unpack\" in nzbget configuration file, exiting") Logger.error("MAIN: Please enable option \"Unpack\" in nzbget configuration file, exiting")
sys.exit(POSTPROCESS_ERROR) sys.exit(POSTPROCESS_ERROR)
# Check par status # Check par status
if os.environ['NZBPP_PARSTATUS'] == '3': if os.environ['NZBPP_PARSTATUS'] == '3':
Logger.warning("Par-check successful, but Par-repair disabled, exiting") Logger.warning("MAIN: Par-check successful, but Par-repair disabled, exiting")
Logger.info("MAIN: Please check your Par-repair settings for future downloads.")
sys.exit(POSTPROCESS_NONE) sys.exit(POSTPROCESS_NONE)
if os.environ['NZBPP_PARSTATUS'] == '1': if os.environ['NZBPP_PARSTATUS'] == '1' or os.environ['NZBPP_PARSTATUS'] == '4':
Logger.warning("Par-check failed, setting status \"failed\"") Logger.warning("MAIN: Par-repair failed, setting status \"failed\"")
status = 1 status = 1
# Check unpack status # Check unpack status
if os.environ['NZBPP_UNPACKSTATUS'] == '1': if os.environ['NZBPP_UNPACKSTATUS'] == '1':
Logger.warning("Unpack failed, setting status \"failed\"") Logger.warning("MAIN: Unpack failed, setting status \"failed\"")
status = 1 status = 1
if os.environ['NZBPP_UNPACKSTATUS'] == '0' and os.environ['NZBPP_PARSTATUS'] != '2': if os.environ['NZBPP_UNPACKSTATUS'] == '0' and os.environ['NZBPP_PARSTATUS'] == '0':
# Unpack is disabled or was skipped due to nzb-file properties or due to errors during par-check # Unpack was skipped due to nzb-file properties or due to errors during par-check
for dirpath, dirnames, filenames in os.walk(os.environ['NZBPP_DIRECTORY']): if os.environ['NZBPP_HEALTH'] < 1000:
for file in filenames: Logger.warning("MAIN: Download health is compromised and Par-check/repair disabled or no .par2 files found. Setting status \"failed\"")
fileExtension = os.path.splitext(file)[1] Logger.info("MAIN: Please check your Par-check/repair settings for future downloads.")
if fileExtension in ['.rar', '.7z'] or os.path.splitext(fileExtension)[1] in ['.rar', '.7z']:
Logger.warning("Post-Process: Archive files exist but unpack skipped, setting status \"failed\"")
status = 1
break
if fileExtension in ['.par2']:
Logger.warning("Post-Process: Unpack skipped and par-check skipped (although par2-files exist), setting status \"failed\"g")
status = 1
break
if os.path.isfile(os.path.join(os.environ['NZBPP_DIRECTORY'], "_brokenlog.txt")) and not status == 1:
Logger.warning("Post-Process: _brokenlog.txt exists, download is probably damaged, exiting")
status = 1 status = 1
if not status == 1: else:
Logger.info("Neither archive- nor par2-files found, _brokenlog.txt doesn't exist, considering download successful") Logger.info("MAIN: Par-check/repair disabled or no .par2 files found, and Unpack not required. Health is ok so handle as though download successful")
Logger.info("MAIN: Please check your Par-check/repair settings for future downloads.")
# Check if destination directory exists (important for reprocessing of history items) # Check if destination directory exists (important for reprocessing of history items)
if not os.path.isdir(os.environ['NZBPP_DIRECTORY']): if not os.path.isdir(os.environ['NZBPP_DIRECTORY']):
Logger.error("Post-Process: Nothing to post-process: destination directory %s doesn't exist", os.environ['NZBPP_DIRECTORY']) Logger.error("MAIN: Nothing to post-process: destination directory %s doesn't exist. Setting status \"failed\"", os.environ['NZBPP_DIRECTORY'])
status = 1 status = 1
# All checks done, now launching the script. # All checks done, now launching the script.
Logger.info("Script triggered from NZBGet, starting autoProcessTV...") Logger.info("MAIN: Script triggered from NZBGet, starting autoProcessTV...")
clientAgent = "nzbget" clientAgent = "nzbget"
result = autoProcessTV.processEpisode(os.environ['NZBPP_DIRECTORY'], os.environ['NZBPP_NZBFILENAME'], status, clientAgent, os.environ['NZBPP_CATEGORY']) result = autoProcessTV.processEpisode(os.environ['NZBPP_DIRECTORY'], os.environ['NZBPP_NZBFILENAME'], status, clientAgent, os.environ['NZBPP_CATEGORY'])
# SABnzbd Pre 0.7.17 # SABnzbd Pre 0.7.17
@ -219,7 +208,7 @@ elif len(sys.argv) == SABNZB_NO_OF_ARGUMENTS:
# 5 User-defined category # 5 User-defined category
# 6 Group that the NZB was posted in e.g. alt.binaries.x # 6 Group that the NZB was posted in e.g. alt.binaries.x
# 7 Status of post processing. 0 = OK, 1=failed verification, 2=failed unpack, 3=1+2 # 7 Status of post processing. 0 = OK, 1=failed verification, 2=failed unpack, 3=1+2
Logger.info("Script triggered from SABnzbd, starting autoProcessTV...") Logger.info("MAIN: Script triggered from SABnzbd, starting autoProcessTV...")
clientAgent = "sabnzbd" clientAgent = "sabnzbd"
result = autoProcessTV.processEpisode(sys.argv[1], sys.argv[2], sys.argv[7], clientAgent, sys.argv[5]) result = autoProcessTV.processEpisode(sys.argv[1], sys.argv[2], sys.argv[7], clientAgent, sys.argv[5])
# SABnzbd 0.7.17+ # SABnzbd 0.7.17+
@ -233,12 +222,12 @@ elif len(sys.argv) >= SABNZB_0717_NO_OF_ARGUMENTS:
# 6 Group that the NZB was posted in e.g. alt.binaries.x # 6 Group that the NZB was posted in e.g. alt.binaries.x
# 7 Status of post processing. 0 = OK, 1=failed verification, 2=failed unpack, 3=1+2 # 7 Status of post processing. 0 = OK, 1=failed verification, 2=failed unpack, 3=1+2
# 8 Failure URL # 8 Failure URL
Logger.info("Script triggered from SABnzbd 0.7.17+, starting autoProcessTV...") Logger.info("MAIN: Script triggered from SABnzbd 0.7.17+, starting autoProcessTV...")
clientAgent = "sabnzbd" clientAgent = "sabnzbd"
result = autoProcessTV.processEpisode(sys.argv[1], sys.argv[2], sys.argv[7], clientAgent, sys.argv[5]) result = autoProcessTV.processEpisode(sys.argv[1], sys.argv[2], sys.argv[7], clientAgent, sys.argv[5])
else: else:
Logger.debug("Invalid number of arguments received from client.") Logger.debug("MAIN: Invalid number of arguments received from client.")
Logger.info("Running autoProcessTV as a manual run...") Logger.info("MAIN: Running autoProcessTV as a manual run...")
result = autoProcessTV.processEpisode('Manual Run', 'Manual Run', 0) result = autoProcessTV.processEpisode('Manual Run', 'Manual Run', 0)
if result == 0: if result == 0: