Add size to quality guessing
And cleanup searcher
This commit is contained in:
@@ -177,7 +177,7 @@ class QualityPlugin(Plugin):
|
||||
|
||||
return False
|
||||
|
||||
def guess(self, files, extra = None):
|
||||
def guess(self, files, extra = None, size = None):
|
||||
if not extra: extra = {}
|
||||
|
||||
# Create hash for cache
|
||||
@@ -205,6 +205,11 @@ class QualityPlugin(Plugin):
|
||||
|
||||
self.calcScore(score, quality, contains_score, threedscore)
|
||||
|
||||
# Evaluate score based on size
|
||||
for quality in qualities:
|
||||
size_score = self.guessSizeScore(quality, size = size)
|
||||
self.calcScore(score, quality, size_score)
|
||||
|
||||
# Try again with loose testing
|
||||
for quality in qualities:
|
||||
loose_score = self.guessLooseScore(quality, extra = extra)
|
||||
@@ -308,6 +313,19 @@ class QualityPlugin(Plugin):
|
||||
|
||||
return score
|
||||
|
||||
|
||||
def guessSizeScore(self, quality, size = None):
|
||||
|
||||
score = 0
|
||||
|
||||
if size:
|
||||
|
||||
if tryInt(size) >= tryInt(quality['size_min']) and tryInt(size) < tryInt(quality['size_max']):
|
||||
log.info2('Found %s via release size: %s MB < %s MB < %s MB', (quality['identifier'], quality['size_min'], size, quality['size_max']))
|
||||
score += 5
|
||||
|
||||
return score
|
||||
|
||||
def calcScore(self, score, quality, add_score, threedscore = (0, None)):
|
||||
|
||||
score[quality['identifier']]['score'] += add_score
|
||||
|
||||
@@ -164,7 +164,7 @@ class Scanner(Plugin):
|
||||
identifiers = [identifier]
|
||||
|
||||
# Identifier with quality
|
||||
quality = fireEvent('quality.guess', [file_path], single = True) if not is_dvd_file else {'identifier':'dvdr'}
|
||||
quality = fireEvent('quality.guess', files = [file_path], size = self.getFileSize(file_path), single = True) if not is_dvd_file else {'identifier':'dvdr'}
|
||||
if quality:
|
||||
identifier_with_quality = '%s %s' % (identifier, quality.get('identifier', ''))
|
||||
identifiers = [identifier_with_quality, identifier]
|
||||
@@ -450,7 +450,7 @@ class Scanner(Plugin):
|
||||
data['quality'] = None
|
||||
if release_download and release_download.get('quality'):
|
||||
data['quality'] = fireEvent('quality.single', release_download.get('quality'), single = True)
|
||||
data['quality']['is_3d'] = release_download.get('is_3d', False)
|
||||
data['quality']['is_3d'] = release_download.get('is_3d', 0)
|
||||
|
||||
if not data['quality']:
|
||||
data['quality'] = fireEvent('quality.guess', files = files, extra = data, single = True)
|
||||
@@ -709,12 +709,18 @@ class Scanner(Plugin):
|
||||
if not file_size: file_size = []
|
||||
|
||||
try:
|
||||
return (file_size.get('min', 0) * 1048576) < os.path.getsize(file) < (file_size.get('max', 100000) * 1048576)
|
||||
return file_size.get('min', 0) < self.getFileSize(file) < file_size.get('max', 100000)
|
||||
except:
|
||||
log.error('Couldn\'t get filesize of %s.', file)
|
||||
|
||||
return False
|
||||
|
||||
def getFileSize(self, file):
|
||||
try:
|
||||
return os.path.getsize(file) / 1024 / 1024
|
||||
except:
|
||||
return None
|
||||
|
||||
def createStringIdentifier(self, file_path, folder = '', exclude_filename = False):
|
||||
|
||||
year = self.findYear(file_path)
|
||||
|
||||
Reference in New Issue
Block a user