mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-07-16 02:02:53 -07:00
added list of sample ids. Fixes #256
This commit is contained in:
parent
fff690de79
commit
4e602956f6
6 changed files with 40 additions and 11 deletions
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
# Media Extensions
|
# Media Extensions
|
||||||
#
|
#
|
||||||
# This is a list of media extensions that may be deleted if ".sample" is in the filename.
|
# 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
|
#mediaExtensions=.mkv,.avi,.divx,.xvid,.mov,.wmv,.mp4,.mpg,.mpeg,.vob,.iso
|
||||||
|
|
||||||
# maxSampleSize
|
# maxSampleSize
|
||||||
|
@ -22,17 +22,30 @@
|
||||||
# This is the maximum size (in MiB) to be be considered as sample file.
|
# This is the maximum size (in MiB) to be be considered as sample file.
|
||||||
#maxSampleSize=200
|
#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 ###
|
### NZBGET POST-PROCESSING SCRIPT ###
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
def is_sample(filePath, inputName, maxSampleSize):
|
|
||||||
|
def is_sample(filePath, inputName, maxSampleSize, SampleIDs):
|
||||||
# 200 MB in bytes
|
# 200 MB in bytes
|
||||||
SIZE_CUTOFF = int(maxSampleSize) * 1024 * 1024
|
SIZE_CUTOFF = int(maxSampleSize) * 1024 * 1024
|
||||||
# Ignore 'sample' in files unless 'sample' in Torrent Name
|
if os.path.getsize(filePath) < SIZE_CUTOFF:
|
||||||
return ('sample' in filePath.lower()) and (not 'sample' in inputName) and (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
|
||||||
|
|
||||||
|
|
||||||
# NZBGet V11+
|
# NZBGet V11+
|
||||||
|
@ -101,6 +114,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.
|
||||||
|
|
||||||
mediaContainer = os.environ['NZBPO_MEDIAEXTENSIONS'].split(',')
|
mediaContainer = os.environ['NZBPO_MEDIAEXTENSIONS'].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:
|
||||||
|
|
||||||
|
@ -108,7 +122,7 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5
|
||||||
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']): # 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
|
||||||
try:
|
try:
|
||||||
os.unlink(filePath)
|
os.unlink(filePath)
|
||||||
|
|
|
@ -149,7 +149,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
||||||
continue # This file has not been recently moved or created, skip it
|
continue # This file has not been recently moved or created, skip it
|
||||||
|
|
||||||
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, inputName, minSampleSize) and not inputCategory in hpCategory: # Ignore samples
|
if is_sample(filePath, inputName, minSampleSize, SampleIDs) and not inputCategory in hpCategory: # Ignore samples
|
||||||
Logger.info("MAIN: Ignoring sample file: %s ", filePath)
|
Logger.info("MAIN: Ignoring sample file: %s ", filePath)
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
|
@ -213,7 +213,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
||||||
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, inputName, minSampleSize):
|
if is_sample(filePath, inputName, minSampleSize, SampleIDs):
|
||||||
Logger.debug("MAIN: Removing sample file: %s", filePath)
|
Logger.debug("MAIN: Removing sample file: %s", filePath)
|
||||||
os.unlink(filePath) # remove samples
|
os.unlink(filePath) # remove samples
|
||||||
else:
|
else:
|
||||||
|
@ -433,6 +433,7 @@ if __name__ == "__main__":
|
||||||
mediaContainer = (config.get("Extensions", "mediaExtensions")).split(',') # .mkv,.avi,.divx
|
mediaContainer = (config.get("Extensions", "mediaExtensions")).split(',') # .mkv,.avi,.divx
|
||||||
metaContainer = (config.get("Extensions", "metaExtensions")).split(',') # .nfo,.sub,.srt
|
metaContainer = (config.get("Extensions", "metaExtensions")).split(',') # .nfo,.sub,.srt
|
||||||
minSampleSize = int(config.get("Extensions", "minSampleSize")) # 200 (in MB)
|
minSampleSize = int(config.get("Extensions", "minSampleSize")) # 200 (in MB)
|
||||||
|
SampleIDs = (config.get("Extensions", "SampleIDs")).split(',') # sample,-s.
|
||||||
|
|
||||||
cpsCategory = (config.get("CouchPotato", "cpsCategory")).split(',') # movie
|
cpsCategory = (config.get("CouchPotato", "cpsCategory")).split(',') # movie
|
||||||
sbCategory = (config.get("SickBeard", "sbCategory")).split(',') # tv
|
sbCategory = (config.get("SickBeard", "sbCategory")).split(',') # tv
|
||||||
|
|
|
@ -100,6 +100,10 @@ def processEpisode(dirName, nzbName=None, failed=False, inputCategory=None):
|
||||||
wait_for = int(config.get(section, "wait_for"))
|
wait_for = int(config.get(section, "wait_for"))
|
||||||
except (ConfigParser.NoOptionError, ValueError):
|
except (ConfigParser.NoOptionError, ValueError):
|
||||||
wait_for = 5
|
wait_for = 5
|
||||||
|
try:
|
||||||
|
SampleIDs = (config.get("Extensions", "SampleIDs")).split(',')
|
||||||
|
except (ConfigParser.NoOptionError, ValueError):
|
||||||
|
SampleIDs = ['sample','-s.']
|
||||||
|
|
||||||
TimeOut = 60 * int(wait_for) # SickBeard needs to complete all moving and renaming before returning the log sequence via url.
|
TimeOut = 60 * int(wait_for) # SickBeard needs to complete all moving and renaming before returning the log sequence via url.
|
||||||
socket.setdefaulttimeout(int(TimeOut)) #initialize socket timeout.
|
socket.setdefaulttimeout(int(TimeOut)) #initialize socket timeout.
|
||||||
|
@ -126,7 +130,7 @@ def processEpisode(dirName, nzbName=None, failed=False, inputCategory=None):
|
||||||
filePath = os.path.join(dirpath, file)
|
filePath = os.path.join(dirpath, file)
|
||||||
fileExtension = os.path.splitext(file)[1]
|
fileExtension = os.path.splitext(file)[1]
|
||||||
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, nzbName, minSampleSize):
|
if is_sample(filePath, nzbName, minSampleSize, SampleIDs):
|
||||||
Logger.debug("Removing sample file: %s", filePath)
|
Logger.debug("Removing sample file: %s", filePath)
|
||||||
os.unlink(filePath) # remove samples
|
os.unlink(filePath) # remove samples
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -161,11 +161,18 @@ def category_search(inputDirectory, inputName, inputCategory, root, categories):
|
||||||
return inputDirectory, inputName, inputCategory, root
|
return inputDirectory, inputName, inputCategory, root
|
||||||
|
|
||||||
|
|
||||||
def is_sample(filePath, inputName, minSampleSize):
|
def is_sample(filePath, inputName, minSampleSize, SampleIDs):
|
||||||
# 200 MB in bytes
|
# 200 MB in bytes
|
||||||
SIZE_CUTOFF = minSampleSize * 1024 * 1024
|
SIZE_CUTOFF = minSampleSize * 1024 * 1024
|
||||||
# Ignore 'sample' in files unless 'sample' in Torrent Name
|
if os.path.getsize(filePath) < SIZE_CUTOFF:
|
||||||
return ('sample' in filePath.lower()) and (not 'sample' in inputName) and (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
|
||||||
|
|
||||||
|
|
||||||
def copy_link(filePath, targetDirectory, useLink, outputDestination):
|
def copy_link(filePath, targetDirectory, useLink, outputDestination):
|
||||||
|
|
|
@ -108,6 +108,8 @@ mediaExtensions = .mkv,.avi,.divx,.xvid,.mov,.wmv,.mp4,.mpg,.mpeg,.vob,.iso,.m4v
|
||||||
metaExtensions = .nfo,.sub,.srt,.jpg,.gif
|
metaExtensions = .nfo,.sub,.srt,.jpg,.gif
|
||||||
###### minSampleSize - Minimum required size to consider a media file not a sample file (in MB, eg 200mb)
|
###### minSampleSize - Minimum required size to consider a media file not a sample file (in MB, eg 200mb)
|
||||||
minSampleSize = 200
|
minSampleSize = 200
|
||||||
|
###### SampleIDs - a list of common sample identifiers. Use SizeOnly to ignore this and delete all media files less than minSampleSize
|
||||||
|
SampleIDs = sample,-s.
|
||||||
|
|
||||||
[Transcoder]
|
[Transcoder]
|
||||||
transcode = 0
|
transcode = 0
|
||||||
|
|
|
@ -6,6 +6,7 @@ Impacts All
|
||||||
Change default "wait_for" to 5 mins. CouchPotato can take more than 2 minutes to return on renamer.scan request.
|
Change default "wait_for" to 5 mins. CouchPotato can take more than 2 minutes to return on renamer.scan request.
|
||||||
Added SickBeard "wait_for" to bw customizable to prevent unwanted timeouts.
|
Added SickBeard "wait_for" to bw customizable to prevent unwanted timeouts.
|
||||||
Fixed ascii conversion of directory name.
|
Fixed ascii conversion of directory name.
|
||||||
|
Added list of common sample ids and a way to set deletion of All media files less than the sample file size limit.
|
||||||
|
|
||||||
Impacts NZBs
|
Impacts NZBs
|
||||||
Fix Error with manual run of nzbToMedia
|
Fix Error with manual run of nzbToMedia
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue