mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-21 05:43:16 -07:00
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
Added delete_ignored option to all category sections, this allows automatic deleteing of ignored files (samples and invalid media files)
This commit is contained in:
parent
dea39ba4cc
commit
868ac210e9
3 changed files with 60 additions and 33 deletions
|
@ -37,6 +37,10 @@
|
||||||
delete_failed = 0
|
delete_failed = 0
|
||||||
wait_for = 2
|
wait_for = 2
|
||||||
extract = 1
|
extract = 1
|
||||||
|
# Set this to minimum required size to consider a media file valid (in MB)
|
||||||
|
minSize = 0
|
||||||
|
# Enable/Disable deleteing ignored files (samples and invalid media files)
|
||||||
|
delete_ignored = 0
|
||||||
##### Set to path where completed downloads are found on remote server for this category
|
##### Set to path where completed downloads are found on remote server for this category
|
||||||
remote_path =
|
remote_path =
|
||||||
##### Set to path where download client places completed downloads locally for this category
|
##### Set to path where download client places completed downloads locally for this category
|
||||||
|
@ -60,6 +64,10 @@
|
||||||
Torrent_NoLink = 0
|
Torrent_NoLink = 0
|
||||||
process_method =
|
process_method =
|
||||||
extract = 1
|
extract = 1
|
||||||
|
# Set this to minimum required size to consider a media file valid (in MB)
|
||||||
|
minSize = 0
|
||||||
|
# Enable/Disable deleteing ignored files (samples and invalid media files)
|
||||||
|
delete_ignored = 0
|
||||||
##### Set to path where completed downloads are found on remote server for this category
|
##### Set to path where completed downloads are found on remote server for this category
|
||||||
remote_path =
|
remote_path =
|
||||||
##### Set to path where download client places completed downloads locally for this category
|
##### Set to path where download client places completed downloads locally for this category
|
||||||
|
@ -82,6 +90,10 @@
|
||||||
# Enable/Disable linking for Torrents
|
# Enable/Disable linking for Torrents
|
||||||
Torrent_NoLink = 0
|
Torrent_NoLink = 0
|
||||||
extract = 1
|
extract = 1
|
||||||
|
# Set this to minimum required size to consider a media file valid (in MB)
|
||||||
|
minSize = 0
|
||||||
|
# Enable/Disable deleteing ignored files (samples and invalid media files)
|
||||||
|
delete_ignored = 0
|
||||||
##### Set to path where completed downloads are found on remote server for this category
|
##### Set to path where completed downloads are found on remote server for this category
|
||||||
remote_path =
|
remote_path =
|
||||||
##### Set to path where download client places completed downloads locally for this category
|
##### Set to path where download client places completed downloads locally for this category
|
||||||
|
@ -102,6 +114,10 @@
|
||||||
# Enable/Disable linking for Torrents
|
# Enable/Disable linking for Torrents
|
||||||
Torrent_NoLink = 0
|
Torrent_NoLink = 0
|
||||||
extract = 1
|
extract = 1
|
||||||
|
# Set this to minimum required size to consider a media file valid (in MB)
|
||||||
|
minSize = 0
|
||||||
|
# Enable/Disable deleteing ignored files (samples and invalid media files)
|
||||||
|
delete_ignored = 0
|
||||||
##### Set to path where completed downloads are found on remote server for this category
|
##### Set to path where completed downloads are found on remote server for this category
|
||||||
remote_path =
|
remote_path =
|
||||||
##### Set to path where download client places completed downloads locally for this category
|
##### Set to path where download client places completed downloads locally for this category
|
||||||
|
@ -122,6 +138,10 @@
|
||||||
# Enable/Disable linking for Torrents
|
# Enable/Disable linking for Torrents
|
||||||
Torrent_NoLink = 0
|
Torrent_NoLink = 0
|
||||||
extract = 1
|
extract = 1
|
||||||
|
# Set this to minimum required size to consider a media file valid (in MB)
|
||||||
|
minSize = 0
|
||||||
|
# Enable/Disable deleteing ignored files (samples and invalid media files)
|
||||||
|
delete_ignored = 0
|
||||||
##### Set to path where completed downloads are found on remote server for this category
|
##### Set to path where completed downloads are found on remote server for this category
|
||||||
remote_path =
|
remote_path =
|
||||||
##### Set to path where download client places completed downloads locally for this category
|
##### Set to path where download client places completed downloads locally for this category
|
||||||
|
@ -141,6 +161,8 @@
|
||||||
# Enable/Disable linking for Torrents
|
# Enable/Disable linking for Torrents
|
||||||
Torrent_NoLink = 0
|
Torrent_NoLink = 0
|
||||||
extract = 1
|
extract = 1
|
||||||
|
# Set this to minimum required size to consider a media file valid (in MB)
|
||||||
|
minSize = 0
|
||||||
##### Set to path where completed downloads are found on remote server for this category
|
##### Set to path where completed downloads are found on remote server for this category
|
||||||
remote_path =
|
remote_path =
|
||||||
##### Set to path where download client places completed downloads locally for this category
|
##### Set to path where download client places completed downloads locally for this category
|
||||||
|
@ -187,10 +209,6 @@
|
||||||
mediaExtensions = .mkv,.avi,.divx,.xvid,.mov,.wmv,.mp4,.mpg,.mpeg,.vob,.iso,.m4v
|
mediaExtensions = .mkv,.avi,.divx,.xvid,.mov,.wmv,.mp4,.mpg,.mpeg,.vob,.iso,.m4v
|
||||||
audioExtensions = .mp3, .aac, .ogg, .ape, .m4a, .asf, .wma, .flac
|
audioExtensions = .mp3, .aac, .ogg, .ape, .m4a, .asf, .wma, .flac
|
||||||
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 = 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
|
||||||
|
|
|
@ -268,9 +268,6 @@ def initialize(section=None):
|
||||||
if isinstance(AUDIOCONTAINER, str): AUDIOCONTAINER = AUDIOCONTAINER.split(',')
|
if isinstance(AUDIOCONTAINER, str): AUDIOCONTAINER = AUDIOCONTAINER.split(',')
|
||||||
if isinstance(METACONTAINER, str): METACONTAINER = METACONTAINER.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"])
|
TRANSCODE = int(CFG["Transcoder"]["transcode"])
|
||||||
DUPLICATE = int(CFG["Transcoder"]["duplicate"])
|
DUPLICATE = int(CFG["Transcoder"]["duplicate"])
|
||||||
IGNOREEXTENSIONS = (CFG["Transcoder"]["ignoreExtensions"])
|
IGNOREEXTENSIONS = (CFG["Transcoder"]["ignoreExtensions"])
|
||||||
|
@ -293,12 +290,12 @@ def initialize(section=None):
|
||||||
|
|
||||||
if not (os.path.isfile(FFMPEG)): # problem
|
if not (os.path.isfile(FFMPEG)): # problem
|
||||||
FFMPEG = None
|
FFMPEG = None
|
||||||
logger.warning("Failed to locate %s, transcoding disabled!" % (FFMPEG))
|
logger.warning("Failed to locate ffmpeg.exe, transcoding disabled!")
|
||||||
logger.warning("Install ffmpeg with x264 support to enable this feature ...")
|
logger.warning("Install ffmpeg with x264 support to enable this feature ...")
|
||||||
|
|
||||||
if not (os.path.isfile(FFPROBE)): # problem
|
if not (os.path.isfile(FFPROBE)): # problem
|
||||||
FFPROBE = None
|
FFPROBE = None
|
||||||
logger.warning("Failed to locate %s, video corruption detection disabled!" % (FFPROBE))
|
logger.warning("Failed to locate ffprobe.exe, video corruption detection disabled!")
|
||||||
logger.warning("Install ffmpeg with x264 support to enable this feature ...")
|
logger.warning("Install ffmpeg with x264 support to enable this feature ...")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -117,19 +117,28 @@ def category_search(inputDirectory, inputName, inputCategory, root, categories):
|
||||||
|
|
||||||
return inputDirectory, inputName, inputCategory, root, single
|
return inputDirectory, inputName, inputCategory, root, single
|
||||||
|
|
||||||
|
def getDirSize(inputPath):
|
||||||
|
from functools import partial
|
||||||
|
prepend = partial(os.path.join, inputPath)
|
||||||
|
return sum([(os.path.getsize(f) if os.path.isfile(f) else getDirSize(f)) for f in map(prepend, os.listdir(inputPath))])
|
||||||
|
|
||||||
def is_sample(inputName, minSampleSize, SampleIDs):
|
def is_minSize(inputName, minSize):
|
||||||
# 200 MB in bytes
|
fileName, fileExt = os.path.splitext(os.path.basename(inputName))
|
||||||
SIZE_CUTOFF = minSampleSize * 1024 * 1024
|
|
||||||
if os.path.getsize(inputName) < SIZE_CUTOFF:
|
|
||||||
if 'SizeOnly' in SampleIDs:
|
# audio files we need to check directory size not file size
|
||||||
return True
|
inputSize = os.path.getsize(inputName)
|
||||||
# Ignore 'sample' in files
|
if fileExt in (nzbtomedia.AUDIOCONTAINER):
|
||||||
for ident in SampleIDs:
|
inputSize = getDirSize(os.path.dirname(inputName))
|
||||||
if re.search(ident,inputName,flags=re.I):
|
|
||||||
return True
|
# Ignore files under a certain size
|
||||||
# Return False if none of these were met.
|
if inputSize < minSize * 1048576:
|
||||||
return False
|
return True
|
||||||
|
|
||||||
|
def is_sample(inputName):
|
||||||
|
# Ignore 'sample' in files
|
||||||
|
if re.search('(^|[\W_])sample\d*[\W_]', inputName.lower()):
|
||||||
|
return True
|
||||||
|
|
||||||
def copy_link(filePath, targetDirectory, useLink, outputDestination):
|
def copy_link(filePath, targetDirectory, useLink, outputDestination):
|
||||||
if os.path.isfile(targetDirectory):
|
if os.path.isfile(targetDirectory):
|
||||||
|
@ -442,7 +451,13 @@ def cleanProcDirs():
|
||||||
if nzbtomedia.CFG[section][category].isenabled():
|
if nzbtomedia.CFG[section][category].isenabled():
|
||||||
dirNames = get_dirnames(section, category)
|
dirNames = get_dirnames(section, category)
|
||||||
for dirName in dirNames:
|
for dirName in dirNames:
|
||||||
num_files = len(listMediaFiles(dirName))
|
try:
|
||||||
|
minSize = int(nzbtomedia.CFG[section][category]['minSize'])
|
||||||
|
except:minSize = 0
|
||||||
|
try:
|
||||||
|
delete_ignored = int(nzbtomedia.CFG[section][category]['delete_ignored'])
|
||||||
|
except:delete_ignored = 0
|
||||||
|
num_files = len(listMediaFiles(dirName, minSize=minSize, delete_ignored=delete_ignored))
|
||||||
if num_files > 0:
|
if num_files > 0:
|
||||||
logger.info(
|
logger.info(
|
||||||
"Directory %s still contains %s unprocessed file(s), skipping ..." % (dirName, num_files),
|
"Directory %s still contains %s unprocessed file(s), skipping ..." % (dirName, num_files),
|
||||||
|
@ -579,10 +594,6 @@ def isMediaFile(mediafile, media=True, audio=True, meta=True, archives=True):
|
||||||
if fileName.startswith('._'):
|
if fileName.startswith('._'):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if re.search('extras?$', fileName, re.I):
|
|
||||||
logger.info("Ignoring extras file: %s " % (mediafile))
|
|
||||||
return False
|
|
||||||
|
|
||||||
if (media and fileExt.lower() in nzbtomedia.MEDIACONTAINER)\
|
if (media and fileExt.lower() in nzbtomedia.MEDIACONTAINER)\
|
||||||
or (audio and fileExt.lower() in nzbtomedia.AUDIOCONTAINER)\
|
or (audio and fileExt.lower() in nzbtomedia.AUDIOCONTAINER)\
|
||||||
or (meta and fileExt.lower() in nzbtomedia.METACONTAINER)\
|
or (meta and fileExt.lower() in nzbtomedia.METACONTAINER)\
|
||||||
|
@ -591,7 +602,7 @@ def isMediaFile(mediafile, media=True, audio=True, meta=True, archives=True):
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def listMediaFiles(path, media=True, audio=True, meta=True, archives=True, ignoreSample=True):
|
def listMediaFiles(path, minSize=0, delete_ignored=0, media=True, audio=True, meta=True, archives=True):
|
||||||
if not dir or not os.path.isdir(path):
|
if not dir or not os.path.isdir(path):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
@ -601,15 +612,16 @@ def listMediaFiles(path, media=True, audio=True, meta=True, archives=True, ignor
|
||||||
|
|
||||||
# if it's a folder do it recursively
|
# if it's a folder do it recursively
|
||||||
if os.path.isdir(fullCurFile) and not curFile.startswith('.') and not curFile == 'Extras':
|
if os.path.isdir(fullCurFile) and not curFile.startswith('.') and not curFile == 'Extras':
|
||||||
files += listMediaFiles(fullCurFile, media, audio, meta, archives)
|
files += listMediaFiles(fullCurFile, minSize, delete_ignored, media, audio, meta, archives)
|
||||||
|
|
||||||
elif isMediaFile(curFile, media, audio, meta, archives):
|
elif isMediaFile(curFile, media, audio, meta, archives):
|
||||||
# Optionally ignore sample files
|
# 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:
|
if delete_ignored == 1:
|
||||||
os.unlink(fullCurFile)
|
try:
|
||||||
logger.debug('Sample file %s has been removed.' % (curFile))
|
os.unlink(fullCurFile)
|
||||||
except:continue
|
logger.debug('Ignored file %s has been removed ...' % (curFile))
|
||||||
|
except:pass
|
||||||
continue
|
continue
|
||||||
|
|
||||||
files.append(fullCurFile)
|
files.append(fullCurFile)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue