Add spotter to name for scoring
This commit is contained in:
@@ -18,7 +18,7 @@ class Score(Plugin):
|
|||||||
def calculate(self, nzb, movie):
|
def calculate(self, nzb, movie):
|
||||||
''' Calculate the score of a NZB, used for sorting later '''
|
''' 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']:
|
for movie_title in movie['library']['titles']:
|
||||||
score += nameRatioScore(toUnicode(nzb['name']), toUnicode(movie_title['title']))
|
score += nameRatioScore(toUnicode(nzb['name']), toUnicode(movie_title['title']))
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
from couchpotato.core.event import fireEvent
|
from couchpotato.core.event import fireEvent
|
||||||
from couchpotato.core.helpers.encoding import simplifyString
|
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
|
from couchpotato.environment import Env
|
||||||
import re
|
import re
|
||||||
|
|
||||||
@@ -42,10 +42,8 @@ def nameScore(name, year):
|
|||||||
|
|
||||||
# Contains preferred word
|
# Contains preferred word
|
||||||
nzb_words = re.split('\W+', simplifyString(name))
|
nzb_words = re.split('\W+', simplifyString(name))
|
||||||
preferred_words = [x.strip() for x in Env.setting('preferred_words', section = 'searcher').split(',')]
|
preferred_words = splitString(Env.setting('preferred_words', section = 'searcher'))
|
||||||
for word in preferred_words:
|
score += 100 * len(list(set(nzb_words) & set(preferred_words)))
|
||||||
if word.strip() and word.strip().lower() in nzb_words:
|
|
||||||
score = score + 100
|
|
||||||
|
|
||||||
return score
|
return score
|
||||||
|
|
||||||
|
|||||||
@@ -53,11 +53,20 @@ class Newznab(NZBProvider, RSS):
|
|||||||
for nzb in nzbs:
|
for nzb in nzbs:
|
||||||
|
|
||||||
date = None
|
date = None
|
||||||
|
spotter = None
|
||||||
for item in nzb:
|
for item in nzb:
|
||||||
|
if date and spotter:
|
||||||
|
break
|
||||||
if item.attrib.get('name') == 'usenetdate':
|
if item.attrib.get('name') == 'usenetdate':
|
||||||
date = item.attrib.get('value')
|
date = item.attrib.get('value')
|
||||||
break
|
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:
|
if not date:
|
||||||
date = self.getTextElement(nzb, 'pubDate')
|
date = self.getTextElement(nzb, 'pubDate')
|
||||||
|
|
||||||
@@ -67,10 +76,15 @@ class Newznab(NZBProvider, RSS):
|
|||||||
if not name:
|
if not name:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
name_extra = ''
|
||||||
|
if spotter:
|
||||||
|
name_extra = spotter
|
||||||
|
|
||||||
results.append({
|
results.append({
|
||||||
'id': nzb_id,
|
'id': nzb_id,
|
||||||
'provider_extra': urlparse(host['host']).hostname or host['host'],
|
'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()))),
|
'age': self.calculateAge(int(time.mktime(parse(date).timetuple()))),
|
||||||
'size': int(self.getElement(nzb, 'enclosure').attrib['length']) / 1024 / 1024,
|
'size': int(self.getElement(nzb, 'enclosure').attrib['length']) / 1024 / 1024,
|
||||||
'url': (self.getUrl(host['host'], self.urls['download']) % tryUrlencode(nzb_id)) + self.getApiExt(host),
|
'url': (self.getUrl(host['host'], self.urls['download']) % tryUrlencode(nzb_id)) + self.getApiExt(host),
|
||||||
|
|||||||
Reference in New Issue
Block a user