Browse Source

Improved quality matching

fixes #3829
pull/3814/merge
Ruud 11 years ago
parent
commit
b0ff526c95
  1. 30
      couchpotato/core/plugins/quality/main.py

30
couchpotato/core/plugins/quality/main.py

@ -187,14 +187,15 @@ class QualityPlugin(Plugin):
return False return False
def guess(self, files, extra = None, size = None): def guess(self, files, extra = None, size = None, use_cache = True):
if not extra: extra = {} if not extra: extra = {}
# Create hash for cache # Create hash for cache
cache_key = str([f.replace('.' + getExt(f), '') if len(getExt(f)) < 4 else f for f in files]) cache_key = str([f.replace('.' + getExt(f), '') if len(getExt(f)) < 4 else f for f in files])
cached = self.getCache(cache_key) if use_cache:
if cached and len(extra) == 0: cached = self.getCache(cache_key)
return cached if cached and len(extra) == 0:
return cached
qualities = self.all() qualities = self.all()
@ -234,7 +235,7 @@ class QualityPlugin(Plugin):
# Add additional size score if only 1 size validated # Add additional size score if only 1 size validated
if len(size_scores) == 1: if len(size_scores) == 1:
self.calcScore(score, size_scores[0], 10, penalty = False) self.calcScore(score, size_scores[0], 8, penalty = False)
del size_scores del size_scores
# Return nothing if all scores are <= 0 # Return nothing if all scores are <= 0
@ -259,7 +260,7 @@ class QualityPlugin(Plugin):
def containsTagScore(self, quality, words, cur_file = ''): def containsTagScore(self, quality, words, cur_file = ''):
cur_file = ss(cur_file) cur_file = ss(cur_file)
score = 0 score = 0.0
extension = words[-1] extension = words[-1]
words = words[:-1] words = words[:-1]
@ -267,7 +268,7 @@ class QualityPlugin(Plugin):
points = { points = {
'identifier': 10, 'identifier': 10,
'label': 10, 'label': 10,
'alternative': 9, 'alternative': 10,
'tags': 9, 'tags': 9,
'ext': 3, 'ext': 3,
} }
@ -285,7 +286,7 @@ class QualityPlugin(Plugin):
if isinstance(alt, (str, unicode)) and ss(alt.lower()) in words: if isinstance(alt, (str, unicode)) and ss(alt.lower()) in words:
log.debug('Found %s via %s %s in %s', (quality['identifier'], tag_type, quality.get(tag_type), cur_file)) log.debug('Found %s via %s %s in %s', (quality['identifier'], tag_type, quality.get(tag_type), cur_file))
score += points.get(tag_type) / 2 score += points.get(tag_type)
if list(set(qualities) & set(words)): if list(set(qualities) & set(words)):
log.debug('Found %s via %s %s in %s', (quality['identifier'], tag_type, quality.get(tag_type), cur_file)) log.debug('Found %s via %s %s in %s', (quality['identifier'], tag_type, quality.get(tag_type), cur_file))
@ -374,9 +375,9 @@ class QualityPlugin(Plugin):
for allow in quality.get('allow', []): for allow in quality.get('allow', []):
score[allow]['score'] -= 40 if self.cached_order[allow] < self.cached_order[quality['identifier']] else 5 score[allow]['score'] -= 40 if self.cached_order[allow] < self.cached_order[quality['identifier']] else 5
# Give panelty for all lower qualities # Give panelty for all other qualities
for q in self.qualities[self.order.index(quality.get('identifier'))+1:]: for q in self.qualities:
if score.get(q.get('identifier')): if quality.get('identifier') != q.get('identifier') and score.get(q.get('identifier')):
score[q.get('identifier')]['score'] -= 1 score[q.get('identifier')]['score'] -= 1
def isFinish(self, quality, profile, release_age = 0): def isFinish(self, quality, profile, release_age = 0):
@ -456,12 +457,15 @@ class QualityPlugin(Plugin):
'Movie Name (2014).mp4': {'size': 750, 'quality': 'brrip'}, 'Movie Name (2014).mp4': {'size': 750, 'quality': 'brrip'},
'Moviename.2014.720p.R6.WEB-DL.x264.AC3-xyz': {'size': 750, 'quality': 'r5'}, 'Moviename.2014.720p.R6.WEB-DL.x264.AC3-xyz': {'size': 750, 'quality': 'r5'},
'Movie name 2014 New Source 720p HDCAM x264 AC3 xyz': {'size': 750, 'quality': 'cam'}, 'Movie name 2014 New Source 720p HDCAM x264 AC3 xyz': {'size': 750, 'quality': 'cam'},
'Movie.Name.2014.720p.HD.TS.AC3.x264': {'size': 750, 'quality': 'ts'} 'Movie.Name.2014.720p.HD.TS.AC3.x264': {'size': 750, 'quality': 'ts'},
# 'Movie.Name.2014.1080p.HDrip.x264.aac-ReleaseGroup': {'size': 7500, 'quality': 'brrip'},
'Movie.Name.2014.HDCam.Chinese.Subs-ReleaseGroup': {'size': 15000, 'quality': 'cam'},
'Movie Name 2014 HQ DVDRip X264 AC3 (bla)': {'size': 0, 'quality': 'dvdrip'},
} }
correct = 0 correct = 0
for name in tests: for name in tests:
test_quality = self.guess(files = [name], extra = tests[name].get('extra', None), size = tests[name].get('size', None)) or {} test_quality = self.guess(files = [name], extra = tests[name].get('extra', None), size = tests[name].get('size', None), use_cache = False) or {}
success = test_quality.get('identifier') == tests[name]['quality'] and test_quality.get('is_3d') == tests[name].get('is_3d', False) success = test_quality.get('identifier') == tests[name]['quality'] and test_quality.get('is_3d') == tests[name].get('is_3d', False)
if not success: if not success:
log.error('%s failed check, thinks it\'s "%s" expecting "%s"', (name, log.error('%s failed check, thinks it\'s "%s" expecting "%s"', (name,

Loading…
Cancel
Save