more nzbget changes

This commit is contained in:
clinton-hall 2014-05-29 16:40:08 +09:30
parent 108fea700b
commit d3b495e4d8
3 changed files with 74 additions and 85 deletions

View file

@ -46,25 +46,23 @@ def is_sample(filePath, inputName, maxSampleSize, SampleIDs):
# Return False if none of these were met. # Return False if none of these were met.
return False return False
if not os.environ.has_key('NZBOP_SCRIPTDIR'):
print "This script can only be called from NZBGet (11.0 or later)."
sys.exit(0)
# NZBGet V11+ if os.environ['NZBOP_VERSION'][0:5] < '11.0':
# Check if the script is called from nzbget 11.0 or later print "NZBGet Version %s is not supported. Please update NZBGet." % (str(os.environ['NZBOP_VERSION'][0:5]))
if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5] < '11.0': sys.exit(0)
print "Script triggered from NZBGet (11.0 or later)."
# Check nzbget.conf options print "Script triggered from NZBGet Version %s." % (str(os.environ['NZBOP_VERSION'][0:5]))
status = 0 status = 0
if os.environ.has_key('NZBPP_TOTALSTATUS'):
if not os.environ['NZBPP_TOTALSTATUS'] == 'SUCCESS':
print "Download failed with status %s." % (os.environ['NZBPP_STATUS']))
status = 1
if os.environ['NZBOP_UNPACK'] != 'yes': else:
print "Please enable option \"Unpack\" in nzbget configuration file, exiting."
sys.exit(nzbtomedia.NZBGET_POSTPROCESS_ERROR)
# Check par status # Check par status
if os.environ['NZBPP_PARSTATUS'] == '3':
print "Par-check successful, but Par-repair disabled, exiting."
print "Please check your Par-repair settings for future downloads."
sys.exit(nzbtomedia.NZBGET_POSTPROCESS_NONE)
if os.environ['NZBPP_PARSTATUS'] == '1' or os.environ['NZBPP_PARSTATUS'] == '4': if os.environ['NZBPP_PARSTATUS'] == '1' or os.environ['NZBPP_PARSTATUS'] == '4':
print "Par-repair failed, setting status \"failed\"." print "Par-repair failed, setting status \"failed\"."
status = 1 status = 1
@ -92,7 +90,6 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5
status = 1 status = 1
# All checks done, now launching the script. # All checks done, now launching the script.
if status == 1: if status == 1:
sys.exit(nzbtomedia.NZBGET_POSTPROCESS_NONE) sys.exit(nzbtomedia.NZBGET_POSTPROCESS_NONE)
@ -100,10 +97,8 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5
SampleIDs = os.environ['NZBPO_SAMPLEIDS'].split(',') SampleIDs = os.environ['NZBPO_SAMPLEIDS'].split(',')
for dirpath, dirnames, filenames in os.walk(os.environ['NZBPP_DIRECTORY']): for dirpath, dirnames, filenames in os.walk(os.environ['NZBPP_DIRECTORY']):
for file in filenames: for file in filenames:
filePath = os.path.join(dirpath, file) filePath = os.path.join(dirpath, file)
fileName, fileExtension = os.path.splitext(file) fileName, fileExtension = os.path.splitext(file)
if fileExtension in mediaContainer: # If the file is a video file if fileExtension in mediaContainer: # If the file is a video file
if is_sample(filePath, os.environ['NZBPP_NZBNAME'], os.environ['NZBPO_MAXSAMPLESIZE'], SampleIDs): # Ignore samples if is_sample(filePath, os.environ['NZBPP_NZBNAME'], os.environ['NZBPO_MAXSAMPLESIZE'], SampleIDs): # Ignore samples
print "Deleting sample file: ", filePath print "Deleting sample file: ", filePath
@ -113,6 +108,3 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5
print "Error: unable to delete file", filePath print "Error: unable to delete file", filePath
sys.exit(nzbtomedia.NZBGET_POSTPROCESS_ERROR) sys.exit(nzbtomedia.NZBGET_POSTPROCESS_ERROR)
sys.exit(nzbtomedia.NZBGET_POSTPROCESS_SUCCESS) sys.exit(nzbtomedia.NZBGET_POSTPROCESS_SUCCESS)
else:
print "This script can only be called from NZBGet (11.0 or later)."
sys.exit(0)

View file

@ -16,22 +16,23 @@ import os
import sys import sys
import nzbtomedia import nzbtomedia
if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5] < '11.0': if not os.environ.has_key('NZBOP_SCRIPTDIR'):
print "Script triggered from NZBGet (11.0 or later)." print "This script can only be called from NZBGet (11.0 or later)."
sys.exit(0)
# Check nzbget.conf options if os.environ['NZBOP_VERSION'][0:5] < '11.0':
print "NZBGet Version %s is not supported. Please update NZBGet." % (str(os.environ['NZBOP_VERSION'][0:5]))
sys.exit(0)
print "Script triggered from NZBGet Version %s." % (str(os.environ['NZBOP_VERSION'][0:5]))
status = 0 status = 0
if os.environ.has_key('NZBPP_TOTALSTATUS'):
if not os.environ['NZBPP_TOTALSTATUS'] == 'SUCCESS':
print "Download failed with status %s." % (os.environ['NZBPP_STATUS']))
status = 1
if os.environ['NZBOP_UNPACK'] != 'yes': else:
print "Please enable option \"Unpack\" in nzbget configuration file, exiting."
sys.exit(nzbtomedia.NZBGET_POSTPROCESS_ERROR)
# Check par status # Check par status
if os.environ['NZBPP_PARSTATUS'] == '3':
print "Par-check successful, but Par-repair disabled, exiting."
print "Please check your Par-repair settings for future downloads."
sys.exit(nzbtomedia.NZBGET_POSTPROCESS_NONE)
if os.environ['NZBPP_PARSTATUS'] == '1' or os.environ['NZBPP_PARSTATUS'] == '4': if os.environ['NZBPP_PARSTATUS'] == '1' or os.environ['NZBPP_PARSTATUS'] == '4':
print "Par-repair failed, setting status \"failed\"." print "Par-repair failed, setting status \"failed\"."
status = 1 status = 1
@ -59,7 +60,6 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5
status = 1 status = 1
# All checks done, now launching the script. # All checks done, now launching the script.
if status == 1: if status == 1:
sys.exit(nzbtomedia.NZBGET_POSTPROCESS_NONE) sys.exit(nzbtomedia.NZBGET_POSTPROCESS_NONE)
@ -75,7 +75,3 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5
print "Error: unable to reset time for file", file print "Error: unable to reset time for file", file
sys.exit(nzbtomedia.NZBGET_POSTPROCESS_ERROR) sys.exit(nzbtomedia.NZBGET_POSTPROCESS_ERROR)
sys.exit(nzbtomedia.NZBGET_POSTPROCESS_SUCCESS) sys.exit(nzbtomedia.NZBGET_POSTPROCESS_SUCCESS)
else:
print "This script can only be called from NZBGet (11.0 or later)."
sys.exit(0)

View file

@ -415,6 +415,11 @@ def main(args, section=None):
# NZBGet # NZBGet
if os.environ.has_key('NZBOP_SCRIPTDIR'): if os.environ.has_key('NZBOP_SCRIPTDIR'):
# Check if the script is called from nzbget 11.0 or later
if os.environ['NZBOP_VERSION'][0:5] < '11.0':
logger.error("NZBGet Version %s is not supported. Please update NZBGet." %(str(os.environ['NZBOP_VERSION'][0:5])))
sys.exit(nzbtomedia.NZBGET_POSTPROCESS_ERROR)
logger.info("Script triggered from NZBGet Version %s." %(str(os.environ['NZBOP_VERSION'][0:5]))) logger.info("Script triggered from NZBGet Version %s." %(str(os.environ['NZBOP_VERSION'][0:5])))
# Check if the script is called from nzbget 13.0 or later # Check if the script is called from nzbget 13.0 or later
@ -423,12 +428,8 @@ def main(args, section=None):
logger.info("Download failed with status %s." %(os.environ['NZBPP_STATUS'])) logger.info("Download failed with status %s." %(os.environ['NZBPP_STATUS']))
status = 1 status = 1
# Check if the script is called from nzbget 11.0 or later
elif os.environ['NZBOP_VERSION'][0:5] < '11.0':
logger.error("NZBGet Version %s is not supported. Please update NZBGet." %(str(os.environ['NZBOP_VERSION'][0:5])))
sys.exit(nzbtomedia.NZBGET_POSTPROCESS_ERROR)
else: else:
# Check par status
if os.environ['NZBPP_PARSTATUS'] == '1' or os.environ['NZBPP_PARSTATUS'] == '4': if os.environ['NZBPP_PARSTATUS'] == '1' or os.environ['NZBPP_PARSTATUS'] == '4':
logger.warning("Par-repair failed, setting status \"failed\"") logger.warning("Par-repair failed, setting status \"failed\"")
status = 1 status = 1