Better score calculating
This commit is contained in:
@@ -3,7 +3,7 @@ from couchpotato.core.helpers.encoding import toUnicode
|
|||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.plugins.base import Plugin
|
from couchpotato.core.plugins.base import Plugin
|
||||||
from couchpotato.core.plugins.score.scores import nameScore, nameRatioScore, \
|
from couchpotato.core.plugins.score.scores import nameScore, nameRatioScore, \
|
||||||
sizeScore
|
sizeScore, providerScore, duplicateScore
|
||||||
|
|
||||||
log = CPLog(__name__)
|
log = CPLog(__name__)
|
||||||
|
|
||||||
@@ -31,4 +31,10 @@ class Score(Plugin):
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# Provider score
|
||||||
|
score += providerScore(nzb['provider'])
|
||||||
|
|
||||||
|
# Duplicates in name
|
||||||
|
score += duplicateScore(nzb['name'], movie['library']['titles'][0]['title'])
|
||||||
|
|
||||||
return score
|
return score
|
||||||
|
|||||||
@@ -27,14 +27,14 @@ def nameScore(name, year):
|
|||||||
score = 0
|
score = 0
|
||||||
name = name.lower()
|
name = name.lower()
|
||||||
|
|
||||||
#give points for the cool stuff
|
# give points for the cool stuff
|
||||||
for value in name_scores:
|
for value in name_scores:
|
||||||
v = value.split(':')
|
v = value.split(':')
|
||||||
add = int(v.pop())
|
add = int(v.pop())
|
||||||
if v.pop() in name:
|
if v.pop() in name:
|
||||||
score = score + add
|
score = score + add
|
||||||
|
|
||||||
#points if the year is correct
|
# points if the year is correct
|
||||||
if str(year) in name:
|
if str(year) in name:
|
||||||
score = score + 5
|
score = score + 5
|
||||||
|
|
||||||
@@ -58,3 +58,24 @@ def nameRatioScore(nzb_name, movie_name):
|
|||||||
|
|
||||||
def sizeScore(size):
|
def sizeScore(size):
|
||||||
return 0 if size else -20
|
return 0 if size else -20
|
||||||
|
|
||||||
|
|
||||||
|
def providerScore(provider):
|
||||||
|
if provider in ['NZBMatrix', 'Nzbs', 'Newzbin']:
|
||||||
|
return 30
|
||||||
|
|
||||||
|
if provider in ['Newznab', 'Moovee', 'X264']:
|
||||||
|
return 10
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
def duplicateScore(nzb_name, movie_name):
|
||||||
|
|
||||||
|
nzb_words = re.split('\W+', simplifyString(nzb_name))
|
||||||
|
movie_words = re.split('\W+', simplifyString(movie_name))
|
||||||
|
|
||||||
|
# minus for duplicates
|
||||||
|
duplicates = [x for i, x in enumerate(nzb_words) if nzb_words[i:].count(x) > 1]
|
||||||
|
|
||||||
|
return len(list(set(duplicates) - set(movie_words))) * -4
|
||||||
|
|||||||
@@ -102,4 +102,4 @@ class YarrProvider(Provider):
|
|||||||
return [self.cat_backup_id]
|
return [self.cat_backup_id]
|
||||||
|
|
||||||
def found(self, new):
|
def found(self, new):
|
||||||
log.info('Found: score(%(score)s): %(name)s' % new)
|
log.info('Found: score(%(score)s) on %(provider)s: %(name)s' % new)
|
||||||
|
|||||||
@@ -59,9 +59,7 @@ class NZBClub(NZBProvider, RSS):
|
|||||||
size = enclosure['length']
|
size = enclosure['length']
|
||||||
date = self.getTextElement(nzb, "pubDate")
|
date = self.getTextElement(nzb, "pubDate")
|
||||||
|
|
||||||
description = ''
|
description = toUnicode(self.getCache('nzbclub.%s' % nzbclub_id, self.getTextElement(nzb, "link"), timeout = 25920000))
|
||||||
if 'nfo files' in self.getTextElement(nzb, "description"):
|
|
||||||
description = toUnicode(self.getCache('nzbclub.%s' % nzbclub_id, self.getTextElement(nzb, "link"), timeout = 25920000))
|
|
||||||
|
|
||||||
new = {
|
new = {
|
||||||
'id': nzbclub_id,
|
'id': nzbclub_id,
|
||||||
@@ -77,6 +75,10 @@ class NZBClub(NZBProvider, RSS):
|
|||||||
}
|
}
|
||||||
new['score'] = fireEvent('score.calculate', new, movie, single = True)
|
new['score'] = fireEvent('score.calculate', new, movie, single = True)
|
||||||
|
|
||||||
|
if 'ARCHIVE inside ARCHIVE' in description:
|
||||||
|
log.info('Wrong: Seems to be passworded files: %s' % new['name'])
|
||||||
|
continue
|
||||||
|
|
||||||
is_correct_movie = fireEvent('searcher.correct_movie',
|
is_correct_movie = fireEvent('searcher.correct_movie',
|
||||||
nzb = new, movie = movie, quality = quality,
|
nzb = new, movie = movie, quality = quality,
|
||||||
imdb_results = False, single_category = False, single = True)
|
imdb_results = False, single_category = False, single = True)
|
||||||
|
|||||||
Reference in New Issue
Block a user