formatting

This commit is contained in:
LooseSeal2
2019-07-17 01:00:02 -07:00
parent 067ef0515b
commit e3c685e5b9
52 changed files with 567 additions and 428 deletions

View File

@@ -16,6 +16,7 @@ NZBGET_POSTPROCESS_SUCCESS = 93
NZBGET_POSTPROCESS_ERROR = 94
NZBGET_POSTPROCESS_NONE = 95
def is_sample(filePath, inputName, maxSampleSize, SampleIDs):
# 200 MB in bytes
SIZE_CUTOFF = int(maxSampleSize) * 1024 * 1024
@@ -29,15 +30,18 @@ def is_sample(filePath, inputName, maxSampleSize, SampleIDs):
# Return False if none of these were met.
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)
if os.environ['NZBOP_VERSION'][0:5] < '11.0':
print "NZBGet Version %s is not supported. Please update NZBGet." % (str(os.environ['NZBOP_VERSION']))
print "NZBGet Version %s is not supported. Please update NZBGet." % (
str(os.environ['NZBOP_VERSION']))
sys.exit(0)
print "Script triggered from NZBGet Version %s." % (str(os.environ['NZBOP_VERSION']))
print "Script triggered from NZBGet Version %s." % (
str(os.environ['NZBOP_VERSION']))
status = 0
if os.environ.has_key('NZBPP_TOTALSTATUS'):
if not os.environ['NZBPP_TOTALSTATUS'] == 'SUCCESS':
@@ -69,7 +73,8 @@ else:
# Check if destination directory exists (important for reprocessing of history items)
if not os.path.isdir(os.environ['NZBPP_DIRECTORY']):
print "Nothing to post-process: destination directory", os.environ['NZBPP_DIRECTORY'], "doesn't exist. Setting status \"failed\"."
print "Nothing to post-process: destination directory", os.environ[
'NZBPP_DIRECTORY'], "doesn't exist. Setting status \"failed\"."
status = 1
# All checks done, now launching the script.
@@ -82,8 +87,9 @@ for dirpath, dirnames, filenames in os.walk(os.environ['NZBPP_DIRECTORY']):
for file in filenames:
filePath = os.path.join(dirpath, file)
fileName, fileExtension = os.path.splitext(file)
if fileExtension in mediaContainer or ".*" 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 fileExtension in mediaContainer or ".*" in mediaContainer: # If the file is a video file
# Ignore samples
if is_sample(filePath, os.environ['NZBPP_NZBNAME'], os.environ['NZBPO_MAXSAMPLESIZE'], SampleIDs):
print "Deleting sample file: ", filePath
try:
os.unlink(filePath)