Added minSize option to all category subsections, this allows you to set a minimum size requirement for downloads to pass to be considered a valid media file and if they fail this check there ignored and removed from disk, Default size is 200MB.

This commit is contained in:
echel0n 2014-04-22 09:01:30 -07:00
commit 8f93dc5354
3 changed files with 27 additions and 25 deletions

View file

@ -37,6 +37,8 @@
delete_failed = 0
wait_for = 2
extract = 1
# Set this to minimum required size to consider a media file valid (in MB, eg 200mb)
minSize = 200
##### Set to path where completed downloads are found on remote server for this category
remote_path =
##### Set to path where download client places completed downloads locally for this category
@ -60,6 +62,8 @@
Torrent_NoLink = 0
process_method =
extract = 1
# Set this to minimum required size to consider a media file valid (in MB, eg 200mb)
minSize = 200
##### Set to path where completed downloads are found on remote server for this category
remote_path =
##### Set to path where download client places completed downloads locally for this category
@ -82,6 +86,8 @@
# Enable/Disable linking for Torrents
Torrent_NoLink = 0
extract = 1
# Set this to minimum required size to consider a media file valid (in MB, eg 200mb)
minSize = 200
##### Set to path where completed downloads are found on remote server for this category
remote_path =
##### Set to path where download client places completed downloads locally for this category
@ -102,6 +108,8 @@
# Enable/Disable linking for Torrents
Torrent_NoLink = 0
extract = 1
# Set this to minimum required size to consider a media file valid (in MB, eg 200mb)
minSize = 200
##### Set to path where completed downloads are found on remote server for this category
remote_path =
##### Set to path where download client places completed downloads locally for this category
@ -122,6 +130,8 @@
# Enable/Disable linking for Torrents
Torrent_NoLink = 0
extract = 1
# Set this to minimum required size to consider a media file valid (in MB, eg 200mb)
minSize = 200
##### Set to path where completed downloads are found on remote server for this category
remote_path =
##### Set to path where download client places completed downloads locally for this category
@ -141,6 +151,8 @@
# Enable/Disable linking for Torrents
Torrent_NoLink = 0
extract = 1
# Set this to minimum required size to consider a media file valid (in MB, eg 200mb)
minSize = 200
##### Set to path where completed downloads are found on remote server for this category
remote_path =
##### Set to path where download client places completed downloads locally for this category
@ -187,10 +199,6 @@
mediaExtensions = .mkv,.avi,.divx,.xvid,.mov,.wmv,.mp4,.mpg,.mpeg,.vob,.iso,.m4v
audioExtensions = .mp3, .aac, .ogg, .ape, .m4a, .asf, .wma, .flac
metaExtensions = .nfo,.sub,.srt,.jpg,.gif
###### minSampleSize - Minimum required size to consider a media file not a sample file (in MB, eg 200mb)
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]
transcode = 0

View file

@ -268,9 +268,6 @@ def initialize(section=None):
if isinstance(AUDIOCONTAINER, str): AUDIOCONTAINER = AUDIOCONTAINER.split(',')
if isinstance(METACONTAINER, str): METACONTAINER = METACONTAINER.split(',')
MINSAMPLESIZE = int(CFG["Extensions"]["minSampleSize"]) # 200 (in MB)
SAMPLEIDS = CFG["Extensions"]["SampleIDs"]
TRANSCODE = int(CFG["Transcoder"]["transcode"])
DUPLICATE = int(CFG["Transcoder"]["duplicate"])
IGNOREEXTENSIONS = (CFG["Transcoder"]["ignoreExtensions"])

View file

@ -117,19 +117,14 @@ def category_search(inputDirectory, inputName, inputCategory, root, categories):
return inputDirectory, inputName, inputCategory, root, single
def is_minSize(inputName, minSize):
if os.path.getsize(inputName) < minSize * 1048576:
return True
def is_sample(inputName, minSampleSize, SampleIDs):
# 200 MB in bytes
SIZE_CUTOFF = minSampleSize * 1024 * 1024
if os.path.getsize(inputName) < SIZE_CUTOFF:
if 'SizeOnly' in SampleIDs:
return True
def is_sample(inputName):
# Ignore 'sample' in files
for ident in SampleIDs:
if re.search(ident,inputName,flags=re.I):
if re.search('(^|[\W_])sample\d*[\W_]', inputName.lower()):
return True
# Return False if none of these were met.
return False
def copy_link(filePath, targetDirectory, useLink, outputDestination):
if os.path.isfile(targetDirectory):
@ -442,7 +437,10 @@ def cleanProcDirs():
if nzbtomedia.CFG[section][category].isenabled():
dirNames = get_dirnames(section, category)
for dirName in dirNames:
num_files = len(listMediaFiles(dirName))
try:
minSize = nzbtomedia.CFG[section][category]['minSize']
except:minSize = 200
num_files = len(listMediaFiles(dirName, minSize=minSize))
if num_files > 0:
logger.info(
"Directory %s still contains %s unprocessed file(s), skipping ..." % (dirName, num_files),
@ -591,7 +589,7 @@ def isMediaFile(mediafile, media=True, audio=True, meta=True, archives=True):
else:
return False
def listMediaFiles(path, media=True, audio=True, meta=True, archives=True, ignoreSample=True):
def listMediaFiles(path, minSize=200, media=True, audio=True, meta=True, archives=True, ignoreSample=True):
if not dir or not os.path.isdir(path):
return []
@ -605,13 +603,12 @@ def listMediaFiles(path, media=True, audio=True, meta=True, archives=True, ignor
elif isMediaFile(curFile, media, audio, meta, archives):
# Optionally ignore sample files
if ignoreSample and is_sample(fullCurFile, nzbtomedia.MINSAMPLESIZE, nzbtomedia.SAMPLEIDS):
if is_sample(fullCurFile) or not is_minSize(fullCurFile, minSize):
try:
os.unlink(fullCurFile)
logger.debug('Sample file %s has been removed.' % (curFile))
except:continue
continue
else:
files.append(fullCurFile)
return files