diff --git a/couchpotato/core/media/_base/matcher/main.py b/couchpotato/core/media/_base/matcher/main.py old mode 100644 new mode 100755 index 64e13ae..c722368 --- a/couchpotato/core/media/_base/matcher/main.py +++ b/couchpotato/core/media/_base/matcher/main.py @@ -21,7 +21,6 @@ class Matcher(MatcherBase): addEvent('matcher.construct_from_raw', self.constructFromRaw) addEvent('matcher.correct_title', self.correctTitle) - addEvent('matcher.correct_quality', self.correctQuality) def parse(self, name, parser='scene'): return self.caper.parse(name, parser) @@ -70,20 +69,3 @@ class Matcher(MatcherBase): return True return False - - def correctQuality(self, chain, quality, quality_map): - if quality['identifier'] not in quality_map: - log.info2('Wrong: unknown preferred quality %s', quality['identifier']) - return False - - if 'video' not in chain.info: - log.info2('Wrong: no video tags found') - return False - - video_tags = quality_map[quality['identifier']] - - if not self.chainMatch(chain, 'video', video_tags): - log.info2('Wrong: %s tags not in chain', video_tags) - return False - - return True diff --git a/couchpotato/core/media/_base/quality/base.py b/couchpotato/core/media/_base/quality/base.py index ada1490..df83ef8 100755 --- a/couchpotato/core/media/_base/quality/base.py +++ b/couchpotato/core/media/_base/quality/base.py @@ -12,10 +12,11 @@ log = CPLog(__name__) class QualityBase(Plugin): - type = None + properties = {} qualities = [] + pre_releases = ['cam', 'ts', 'tc', 'r5', 'scr'] threed_tags = { 'sbs': [('half', 'sbs'), 'hsbs', ('full', 'sbs'), 'fsbs'], @@ -78,6 +79,23 @@ class QualityBase(Plugin): return temp + def expand(self, quality): + for key, options in self.properties.items(): + if key not in quality: + continue + + quality[key] = [self.getProperty(key, identifier) for identifier in quality[key]] + + return quality + + def getProperty(self, key, identifier): + if key not in self.properties: + return + + for item in self.properties[key]: + if item.get('identifier') == identifier: + return item + def resetCache(self): self.cached_qualities = None diff --git a/couchpotato/core/media/_base/searcher/main.py b/couchpotato/core/media/_base/searcher/main.py index a7249d8..9d6f1c3 100755 --- a/couchpotato/core/media/_base/searcher/main.py +++ b/couchpotato/core/media/_base/searcher/main.py @@ -90,13 +90,7 @@ class Searcher(SearcherBase): found = {} # Try guessing via quality tags - guess = fireEvent( - 'quality.guess', - files = [nzb.get('name')], - size = nzb.get('size', None), - types = types, - single = True - ) + guess = fireEvent('quality.guess', files = [nzb.get('name')], size = nzb.get('size', None), types = types, single = True) if guess: found[guess['identifier']] = True @@ -118,7 +112,7 @@ class Searcher(SearcherBase): found['dvdrip'] = True # Allow other qualities - for allowed in preferred_quality.get('allow'): + for allowed in preferred_quality.get('allow', []): if found.get(allowed): del found[allowed] diff --git a/couchpotato/core/media/movie/quality/main.py b/couchpotato/core/media/movie/quality/main.py index 1e1747a..b412c67 100755 --- a/couchpotato/core/media/movie/quality/main.py +++ b/couchpotato/core/media/movie/quality/main.py @@ -121,7 +121,7 @@ class MovieQuality(QualityBase): 'alternative': 9, 'tags': 9, 'ext': 3, - } + } # Check alt and tags for tag_type in ['identifier', 'alternative', 'tags', 'label']: diff --git a/couchpotato/core/media/show/matcher/base.py b/couchpotato/core/media/show/matcher/base.py index 186334f..35829bc 100755 --- a/couchpotato/core/media/show/matcher/base.py +++ b/couchpotato/core/media/show/matcher/base.py @@ -35,10 +35,6 @@ class Base(MatcherBase): log.info("Checking if '%s' is valid", release['name']) log.info2('Release parsed as: %s', chain.info) - if not fireEvent('matcher.correct_quality', chain, quality, self.quality_map, single = True): - log.info('Wrong: %s, quality does not match', release['name']) - return False - if not fireEvent('%s.matcher.correct_identifier' % self.type, chain, media): log.info('Wrong: %s, identifier does not match', release['name']) return False diff --git a/couchpotato/core/plugins/score/scores.py b/couchpotato/core/plugins/score/scores.py index a9f6c04..c0f6189 100755 --- a/couchpotato/core/plugins/score/scores.py +++ b/couchpotato/core/plugins/score/scores.py @@ -98,7 +98,7 @@ def namePositionScore(nzb_name, movie_name): found_quality = quality['identifier'] # Alt in words - for alt in quality['alternative']: + for alt in quality.get('alternative', []): if alt in nzb_words: found_quality = alt break