mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-19 21:03:14 -07:00
remove external scripts. Now at https://github.com/clinton-hall/GetScripts
This commit is contained in:
parent
d3adf45eb8
commit
e0b7ec3c23
2 changed files with 0 additions and 187 deletions
110
DeleteSamples.py
110
DeleteSamples.py
|
@ -1,110 +0,0 @@
|
||||||
#!/usr/bin/env python2
|
|
||||||
#
|
|
||||||
##############################################################################
|
|
||||||
### NZBGET POST-PROCESSING SCRIPT ###
|
|
||||||
|
|
||||||
# Delete ".sample" files.
|
|
||||||
#
|
|
||||||
# This script removed sample files from the download directory.
|
|
||||||
#
|
|
||||||
# NOTE: This script requires Python to be installed on your system.
|
|
||||||
|
|
||||||
##############################################################################
|
|
||||||
### OPTIONS ###
|
|
||||||
|
|
||||||
# Media Extensions
|
|
||||||
#
|
|
||||||
# This is a list of media extensions that may be deleted if a Sample_id is in the filename.
|
|
||||||
#mediaExtensions=.mkv,.avi,.divx,.xvid,.mov,.wmv,.mp4,.mpg,.mpeg,.vob,.iso
|
|
||||||
|
|
||||||
# maxSampleSize
|
|
||||||
#
|
|
||||||
# This is the maximum size (in MiB) to be be considered as sample file.
|
|
||||||
#maxSampleSize=200
|
|
||||||
|
|
||||||
# SampleIDs
|
|
||||||
#
|
|
||||||
# This is a list of identifiers used for samples. e.g sample,-s. Use 'SizeOnly' to delete all media files less than maxSampleSize.
|
|
||||||
#SampleIDs=sample,-s.
|
|
||||||
|
|
||||||
### NZBGET POST-PROCESSING SCRIPT ###
|
|
||||||
##############################################################################
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import nzbtomedia
|
|
||||||
|
|
||||||
def is_sample(filePath, inputName, maxSampleSize, SampleIDs):
|
|
||||||
# 200 MB in bytes
|
|
||||||
SIZE_CUTOFF = int(maxSampleSize) * 1024 * 1024
|
|
||||||
if os.path.getsize(filePath) < SIZE_CUTOFF:
|
|
||||||
if 'SizeOnly' in SampleIDs:
|
|
||||||
return True
|
|
||||||
# Ignore 'sample' in files unless 'sample' in Torrent Name
|
|
||||||
for ident in SampleIDs:
|
|
||||||
if ident.lower() in filePath.lower() and not ident.lower() in inputName.lower():
|
|
||||||
return True
|
|
||||||
# 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']))
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
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':
|
|
||||||
print "Download failed with status %s." % (os.environ['NZBPP_STATUS'])
|
|
||||||
status = 1
|
|
||||||
|
|
||||||
else:
|
|
||||||
# Check par status
|
|
||||||
if os.environ['NZBPP_PARSTATUS'] == '1' or os.environ['NZBPP_PARSTATUS'] == '4':
|
|
||||||
print "Par-repair failed, setting status \"failed\"."
|
|
||||||
status = 1
|
|
||||||
|
|
||||||
# Check unpack status
|
|
||||||
if os.environ['NZBPP_UNPACKSTATUS'] == '1':
|
|
||||||
print "Unpack failed, setting status \"failed\"."
|
|
||||||
status = 1
|
|
||||||
|
|
||||||
if os.environ['NZBPP_UNPACKSTATUS'] == '0' and os.environ['NZBPP_PARSTATUS'] == '0':
|
|
||||||
# Unpack was skipped due to nzb-file properties or due to errors during par-check
|
|
||||||
|
|
||||||
if os.environ['NZBPP_HEALTH'] < 1000:
|
|
||||||
print "Download health is compromised and Par-check/repair disabled or no .par2 files found. Setting status \"failed\"."
|
|
||||||
print "Please check your Par-check/repair settings for future downloads."
|
|
||||||
status = 1
|
|
||||||
|
|
||||||
else:
|
|
||||||
print "Par-check/repair disabled or no .par2 files found, and Unpack not required. Health is ok so handle as though download successful."
|
|
||||||
print "Please check your Par-check/repair settings for future downloads."
|
|
||||||
|
|
||||||
# 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\"."
|
|
||||||
status = 1
|
|
||||||
|
|
||||||
# All checks done, now launching the script.
|
|
||||||
if status == 1:
|
|
||||||
sys.exit(nzbtomedia.NZBGET_POSTPROCESS_NONE)
|
|
||||||
|
|
||||||
mediaContainer = os.environ['NZBPO_MEDIAEXTENSIONS'].split(',')
|
|
||||||
SampleIDs = os.environ['NZBPO_SAMPLEIDS'].split(',')
|
|
||||||
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: # If the file is a video file
|
|
||||||
if is_sample(filePath, os.environ['NZBPP_NZBNAME'], os.environ['NZBPO_MAXSAMPLESIZE'], SampleIDs): # Ignore samples
|
|
||||||
print "Deleting sample file: ", filePath
|
|
||||||
try:
|
|
||||||
os.unlink(filePath)
|
|
||||||
except:
|
|
||||||
print "Error: unable to delete file", filePath
|
|
||||||
sys.exit(nzbtomedia.NZBGET_POSTPROCESS_ERROR)
|
|
||||||
sys.exit(nzbtomedia.NZBGET_POSTPROCESS_SUCCESS)
|
|
|
@ -1,77 +0,0 @@
|
||||||
#!/usr/bin/env python2
|
|
||||||
#
|
|
||||||
##############################################################################
|
|
||||||
### NZBGET POST-PROCESSING SCRIPT ###
|
|
||||||
|
|
||||||
# Reset the Date Modified and Date Created for downloaded files.
|
|
||||||
#
|
|
||||||
# This is useful for sorting "newly added" media.
|
|
||||||
# This should run before other scripts.
|
|
||||||
#
|
|
||||||
# NOTE: This script requires Python to be installed on your system.
|
|
||||||
|
|
||||||
### NZBGET POST-PROCESSING SCRIPT ###
|
|
||||||
##############################################################################
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import nzbtomedia
|
|
||||||
|
|
||||||
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']))
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
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':
|
|
||||||
print "Download failed with status %s." % (os.environ['NZBPP_STATUS'])
|
|
||||||
status = 1
|
|
||||||
|
|
||||||
else:
|
|
||||||
# Check par status
|
|
||||||
if os.environ['NZBPP_PARSTATUS'] == '1' or os.environ['NZBPP_PARSTATUS'] == '4':
|
|
||||||
print "Par-repair failed, setting status \"failed\"."
|
|
||||||
status = 1
|
|
||||||
|
|
||||||
# Check unpack status
|
|
||||||
if os.environ['NZBPP_UNPACKSTATUS'] == '1':
|
|
||||||
print "Unpack failed, setting status \"failed\"."
|
|
||||||
status = 1
|
|
||||||
|
|
||||||
if os.environ['NZBPP_UNPACKSTATUS'] == '0' and os.environ['NZBPP_PARSTATUS'] == '0':
|
|
||||||
# Unpack was skipped due to nzb-file properties or due to errors during par-check
|
|
||||||
|
|
||||||
if os.environ['NZBPP_HEALTH'] < 1000:
|
|
||||||
print "Download health is compromised and Par-check/repair disabled or no .par2 files found. Setting status \"failed\"."
|
|
||||||
print "Please check your Par-check/repair settings for future downloads."
|
|
||||||
status = 1
|
|
||||||
|
|
||||||
else:
|
|
||||||
print "Par-check/repair disabled or no .par2 files found, and Unpack not required. Health is ok so handle as though download successful."
|
|
||||||
print "Please check your Par-check/repair settings for future downloads."
|
|
||||||
|
|
||||||
# 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\"."
|
|
||||||
status = 1
|
|
||||||
|
|
||||||
# All checks done, now launching the script.
|
|
||||||
if status == 1:
|
|
||||||
sys.exit(nzbtomedia.NZBGET_POSTPROCESS_NONE)
|
|
||||||
|
|
||||||
directory = os.path.normpath(os.environ['NZBPP_DIRECTORY'])
|
|
||||||
for dirpath, dirnames, filenames in os.walk(directory):
|
|
||||||
for file in filenames:
|
|
||||||
filepath = os.path.join(dirpath, file)
|
|
||||||
print "reseting datetime for file", filepath
|
|
||||||
try:
|
|
||||||
os.utime(filepath, None)
|
|
||||||
continue
|
|
||||||
except:
|
|
||||||
print "Error: unable to reset time for file", file
|
|
||||||
sys.exit(nzbtomedia.NZBGET_POSTPROCESS_ERROR)
|
|
||||||
sys.exit(nzbtomedia.NZBGET_POSTPROCESS_SUCCESS)
|
|
Loading…
Add table
Add a link
Reference in a new issue