mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-20 05:13:16 -07:00
keep these scripts independent
This commit is contained in:
parent
da09af8de7
commit
30890428b9
2 changed files with 21 additions and 12 deletions
|
@ -31,8 +31,12 @@
|
||||||
##############################################################################
|
##############################################################################
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from nzbtomedia.nzbToMediaConfig import config
|
|
||||||
|
|
||||||
|
# NZBGet argv: all passed as environment variables.
|
||||||
|
# Exit codes used by NZBGet
|
||||||
|
POSTPROCESS_SUCCESS=93
|
||||||
|
POSTPROCESS_ERROR=94
|
||||||
|
POSTPROCESS_NONE=95
|
||||||
|
|
||||||
def is_sample(filePath, inputName, maxSampleSize, SampleIDs):
|
def is_sample(filePath, inputName, maxSampleSize, SampleIDs):
|
||||||
# 200 MB in bytes
|
# 200 MB in bytes
|
||||||
|
@ -58,13 +62,13 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5
|
||||||
|
|
||||||
if os.environ['NZBOP_UNPACK'] != 'yes':
|
if os.environ['NZBOP_UNPACK'] != 'yes':
|
||||||
print "Please enable option \"Unpack\" in nzbget configuration file, exiting."
|
print "Please enable option \"Unpack\" in nzbget configuration file, exiting."
|
||||||
sys.exit(config.NZBGET_POSTPROCESS_ERROR)
|
sys.exit(POSTPROCESS_ERROR)
|
||||||
|
|
||||||
# Check par status
|
# Check par status
|
||||||
if os.environ['NZBPP_PARSTATUS'] == '3':
|
if os.environ['NZBPP_PARSTATUS'] == '3':
|
||||||
print "Par-check successful, but Par-repair disabled, exiting."
|
print "Par-check successful, but Par-repair disabled, exiting."
|
||||||
print "Please check your Par-repair settings for future downloads."
|
print "Please check your Par-repair settings for future downloads."
|
||||||
sys.exit(config.NZBGET_POSTPROCESS_NONE)
|
sys.exit(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\"."
|
||||||
|
@ -95,7 +99,7 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5
|
||||||
# All checks done, now launching the script.
|
# All checks done, now launching the script.
|
||||||
|
|
||||||
if status == 1:
|
if status == 1:
|
||||||
sys.exit(config.NZBGET_POSTPROCESS_NONE)
|
sys.exit(POSTPROCESS_NONE)
|
||||||
|
|
||||||
mediaContainer = os.environ['NZBPO_MEDIAEXTENSIONS'].split(',')
|
mediaContainer = os.environ['NZBPO_MEDIAEXTENSIONS'].split(',')
|
||||||
SampleIDs = os.environ['NZBPO_SAMPLEIDS'].split(',')
|
SampleIDs = os.environ['NZBPO_SAMPLEIDS'].split(',')
|
||||||
|
@ -112,8 +116,8 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5
|
||||||
os.unlink(filePath)
|
os.unlink(filePath)
|
||||||
except:
|
except:
|
||||||
print "Error: unable to delete file", filePath
|
print "Error: unable to delete file", filePath
|
||||||
sys.exit(config.NZBGET_POSTPROCESS_ERROR)
|
sys.exit(POSTPROCESS_ERROR)
|
||||||
sys.exit(config.NZBGET_POSTPROCESS_SUCCESS)
|
sys.exit(POSTPROCESS_SUCCESS)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print "This script can only be called from NZBGet (11.0 or later)."
|
print "This script can only be called from NZBGet (11.0 or later)."
|
||||||
|
|
|
@ -17,7 +17,12 @@
|
||||||
# Check if the script is called from nzbget 11.0 or later
|
# Check if the script is called from nzbget 11.0 or later
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from nzbtomedia.nzbToMediaConfig import config
|
|
||||||
|
# NZBGet argv: all passed as environment variables.
|
||||||
|
# Exit codes used by NZBGet
|
||||||
|
POSTPROCESS_SUCCESS=93
|
||||||
|
POSTPROCESS_ERROR=94
|
||||||
|
POSTPROCESS_NONE=95
|
||||||
|
|
||||||
if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5] < '11.0':
|
if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5] < '11.0':
|
||||||
print "Script triggered from NZBGet (11.0 or later)."
|
print "Script triggered from NZBGet (11.0 or later)."
|
||||||
|
@ -27,13 +32,13 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5
|
||||||
|
|
||||||
if os.environ['NZBOP_UNPACK'] != 'yes':
|
if os.environ['NZBOP_UNPACK'] != 'yes':
|
||||||
print "Please enable option \"Unpack\" in nzbget configuration file, exiting."
|
print "Please enable option \"Unpack\" in nzbget configuration file, exiting."
|
||||||
sys.exit(config.NZBGET_POSTPROCESS_ERROR)
|
sys.exit(POSTPROCESS_ERROR)
|
||||||
|
|
||||||
# Check par status
|
# Check par status
|
||||||
if os.environ['NZBPP_PARSTATUS'] == '3':
|
if os.environ['NZBPP_PARSTATUS'] == '3':
|
||||||
print "Par-check successful, but Par-repair disabled, exiting."
|
print "Par-check successful, but Par-repair disabled, exiting."
|
||||||
print "Please check your Par-repair settings for future downloads."
|
print "Please check your Par-repair settings for future downloads."
|
||||||
sys.exit(config.NZBGET_POSTPROCESS_NONE)
|
sys.exit(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\"."
|
||||||
|
@ -64,7 +69,7 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5
|
||||||
# All checks done, now launching the script.
|
# All checks done, now launching the script.
|
||||||
|
|
||||||
if status == 1:
|
if status == 1:
|
||||||
sys.exit(config.NZBGET_POSTPROCESS_NONE)
|
sys.exit(POSTPROCESS_NONE)
|
||||||
|
|
||||||
directory = os.path.normpath(os.environ['NZBPP_DIRECTORY'])
|
directory = os.path.normpath(os.environ['NZBPP_DIRECTORY'])
|
||||||
for dirpath, dirnames, filenames in os.walk(directory):
|
for dirpath, dirnames, filenames in os.walk(directory):
|
||||||
|
@ -76,8 +81,8 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5
|
||||||
continue
|
continue
|
||||||
except:
|
except:
|
||||||
print "Error: unable to reset time for file", file
|
print "Error: unable to reset time for file", file
|
||||||
sys.exit(config.NZBGET_POSTPROCESS_ERROR)
|
sys.exit(POSTPROCESS_ERROR)
|
||||||
sys.exit(config.NZBGET_POSTPROCESS_SUCCESS)
|
sys.exit(POSTPROCESS_SUCCESS)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print "This script can only be called from NZBGet (11.0 or later)."
|
print "This script can only be called from NZBGet (11.0 or later)."
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue