Better score calculating

This commit is contained in:
Ruud
2012-03-06 23:37:55 +01:00
parent 6e8a1950cd
commit af46827eb2
4 changed files with 36 additions and 7 deletions
+7 -1
View File
@@ -3,7 +3,7 @@ from couchpotato.core.helpers.encoding import toUnicode
from couchpotato.core.logger import CPLog
from couchpotato.core.plugins.base import Plugin
from couchpotato.core.plugins.score.scores import nameScore, nameRatioScore, \
sizeScore
sizeScore, providerScore, duplicateScore
log = CPLog(__name__)
@@ -31,4 +31,10 @@ class Score(Plugin):
except:
pass
# Provider score
score += providerScore(nzb['provider'])
# Duplicates in name
score += duplicateScore(nzb['name'], movie['library']['titles'][0]['title'])
return score
+23 -2
View File
@@ -27,14 +27,14 @@ def nameScore(name, year):
score = 0
name = name.lower()
#give points for the cool stuff
# give points for the cool stuff
for value in name_scores:
v = value.split(':')
add = int(v.pop())
if v.pop() in name:
score = score + add
#points if the year is correct
# points if the year is correct
if str(year) in name:
score = score + 5
@@ -58,3 +58,24 @@ def nameRatioScore(nzb_name, movie_name):
def sizeScore(size):
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
+1 -1
View File
@@ -102,4 +102,4 @@ class YarrProvider(Provider):
return [self.cat_backup_id]
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']
date = self.getTextElement(nzb, "pubDate")
description = ''
if 'nfo files' in self.getTextElement(nzb, "description"):
description = toUnicode(self.getCache('nzbclub.%s' % nzbclub_id, self.getTextElement(nzb, "link"), timeout = 25920000))
description = toUnicode(self.getCache('nzbclub.%s' % nzbclub_id, self.getTextElement(nzb, "link"), timeout = 25920000))
new = {
'id': nzbclub_id,
@@ -77,6 +75,10 @@ class NZBClub(NZBProvider, RSS):
}
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',
nzb = new, movie = movie, quality = quality,
imdb_results = False, single_category = False, single = True)