diff --git a/couchpotato/core/plugins/score/main.py b/couchpotato/core/plugins/score/main.py index f853be95..4f16539d 100644 --- a/couchpotato/core/plugins/score/main.py +++ b/couchpotato/core/plugins/score/main.py @@ -18,7 +18,7 @@ class Score(Plugin): def calculate(self, nzb, movie): ''' Calculate the score of a NZB, used for sorting later ''' - score = nameScore(toUnicode(nzb['name']), movie['library']['year']) + score = nameScore(toUnicode(nzb['name'] + ' ' + nzb.get('name_extra', '')), movie['library']['year']) for movie_title in movie['library']['titles']: score += nameRatioScore(toUnicode(nzb['name']), toUnicode(movie_title['title'])) diff --git a/couchpotato/core/plugins/score/scores.py b/couchpotato/core/plugins/score/scores.py index c9345fc0..95ef9b97 100644 --- a/couchpotato/core/plugins/score/scores.py +++ b/couchpotato/core/plugins/score/scores.py @@ -1,6 +1,6 @@ from couchpotato.core.event import fireEvent from couchpotato.core.helpers.encoding import simplifyString -from couchpotato.core.helpers.variable import tryInt +from couchpotato.core.helpers.variable import tryInt, splitString from couchpotato.environment import Env import re @@ -42,10 +42,8 @@ def nameScore(name, year): # Contains preferred word nzb_words = re.split('\W+', simplifyString(name)) - preferred_words = [x.strip() for x in Env.setting('preferred_words', section = 'searcher').split(',')] - for word in preferred_words: - if word.strip() and word.strip().lower() in nzb_words: - score = score + 100 + preferred_words = splitString(Env.setting('preferred_words', section = 'searcher')) + score += 100 * len(list(set(nzb_words) & set(preferred_words))) return score diff --git a/couchpotato/core/providers/nzb/newznab/main.py b/couchpotato/core/providers/nzb/newznab/main.py index 11107c1f..c57dfeb9 100644 --- a/couchpotato/core/providers/nzb/newznab/main.py +++ b/couchpotato/core/providers/nzb/newznab/main.py @@ -53,11 +53,20 @@ class Newznab(NZBProvider, RSS): for nzb in nzbs: date = None + spotter = None for item in nzb: + if date and spotter: + break if item.attrib.get('name') == 'usenetdate': date = item.attrib.get('value') break + # Get the name of the person who posts the spot + if item.attrib.get('name') == 'poster': + if "@spot.net" in item.attrib.get('value'): + spotter = item.attrib.get('value').split("@")[0] + continue + if not date: date = self.getTextElement(nzb, 'pubDate') @@ -67,10 +76,15 @@ class Newznab(NZBProvider, RSS): if not name: continue + name_extra = '' + if spotter: + name_extra = spotter + results.append({ 'id': nzb_id, 'provider_extra': urlparse(host['host']).hostname or host['host'], - 'name': self.getTextElement(nzb, 'title'), + 'name': name, + 'name_extra': name_extra, 'age': self.calculateAge(int(time.mktime(parse(date).timetuple()))), 'size': int(self.getElement(nzb, 'enclosure').attrib['length']) / 1024 / 1024, 'url': (self.getUrl(host['host'], self.urls['download']) % tryUrlencode(nzb_id)) + self.getApiExt(host),