1 parent
afa782194d
commit
b07f91d6a5
1 file changed
+63
-38
@@ -33,33 +33,43 @@ name_scores = [
|
|||||||
def nameScore(name, year, preferred_words):
|
def nameScore(name, year, preferred_words):
|
||||||
""" Calculate score for words in the NZB name """
|
""" Calculate score for words in the NZB name """
|
||||||
|
|
||||||
score = 0
|
try:
|
||||||
name = name.lower()
|
score = 0
|
||||||
|
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 += add
|
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 += 5
|
score += 5
|
||||||
|
|
||||||
# Contains preferred word
|
# Contains preferred word
|
||||||
nzb_words = re.split('\W+', simplifyString(name))
|
nzb_words = re.split('\W+', simplifyString(name))
|
||||||
score += 100 * len(list(set(nzb_words) & set(preferred_words)))
|
score += 100 * len(list(set(nzb_words) & set(preferred_words)))
|
||||||
|
|
||||||
return score
|
return score
|
||||||
|
except:
|
||||||
|
log.error('Failed doing nameScore: %s', traceback.format_exc())
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def nameRatioScore(nzb_name, movie_name):
|
def nameRatioScore(nzb_name, movie_name):
|
||||||
nzb_words = re.split('\W+', fireEvent('scanner.create_file_identifier', nzb_name, single = True))
|
try:
|
||||||
movie_words = re.split('\W+', simplifyString(movie_name))
|
nzb_words = re.split('\W+', fireEvent('scanner.create_file_identifier', nzb_name, single = True))
|
||||||
|
movie_words = re.split('\W+', simplifyString(movie_name))
|
||||||
|
|
||||||
left_over = set(nzb_words) - set(movie_words)
|
left_over = set(nzb_words) - set(movie_words)
|
||||||
return 10 - len(left_over)
|
return 10 - len(left_over)
|
||||||
|
except:
|
||||||
|
log.error('Failed doing nameRatioScore: %s', traceback.format_exc())
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def namePositionScore(nzb_name, movie_name):
|
def namePositionScore(nzb_name, movie_name):
|
||||||
@@ -134,38 +144,53 @@ def providerScore(provider):
|
|||||||
|
|
||||||
def duplicateScore(nzb_name, movie_name):
|
def duplicateScore(nzb_name, movie_name):
|
||||||
|
|
||||||
nzb_words = re.split('\W+', simplifyString(nzb_name))
|
try:
|
||||||
movie_words = re.split('\W+', simplifyString(movie_name))
|
nzb_words = re.split('\W+', simplifyString(nzb_name))
|
||||||
|
movie_words = re.split('\W+', simplifyString(movie_name))
|
||||||
|
|
||||||
# minus for duplicates
|
# minus for duplicates
|
||||||
duplicates = [x for i, x in enumerate(nzb_words) if nzb_words[i:].count(x) > 1]
|
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
|
return len(list(set(duplicates) - set(movie_words))) * -4
|
||||||
|
except:
|
||||||
|
log.error('Failed doing duplicateScore: %s', traceback.format_exc())
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def partialIgnoredScore(nzb_name, movie_name, ignored_words):
|
def partialIgnoredScore(nzb_name, movie_name, ignored_words):
|
||||||
|
|
||||||
nzb_name = nzb_name.lower()
|
try:
|
||||||
movie_name = movie_name.lower()
|
nzb_name = nzb_name.lower()
|
||||||
|
movie_name = movie_name.lower()
|
||||||
|
|
||||||
score = 0
|
score = 0
|
||||||
for ignored_word in ignored_words:
|
for ignored_word in ignored_words:
|
||||||
if ignored_word in nzb_name and ignored_word not in movie_name:
|
if ignored_word in nzb_name and ignored_word not in movie_name:
|
||||||
score -= 5
|
score -= 5
|
||||||
|
|
||||||
return score
|
return score
|
||||||
|
except:
|
||||||
|
log.error('Failed doing partialIgnoredScore: %s', traceback.format_exc())
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def halfMultipartScore(nzb_name):
|
def halfMultipartScore(nzb_name):
|
||||||
|
|
||||||
wrong_found = 0
|
try:
|
||||||
for nr in [1, 2, 3, 4, 5, 'i', 'ii', 'iii', 'iv', 'v', 'a', 'b', 'c', 'd', 'e']:
|
wrong_found = 0
|
||||||
for wrong in ['cd', 'part', 'dis', 'disc', 'dvd']:
|
for nr in [1, 2, 3, 4, 5, 'i', 'ii', 'iii', 'iv', 'v', 'a', 'b', 'c', 'd', 'e']:
|
||||||
if '%s%s' % (wrong, nr) in nzb_name.lower():
|
for wrong in ['cd', 'part', 'dis', 'disc', 'dvd']:
|
||||||
wrong_found += 1
|
if '%s%s' % (wrong, nr) in nzb_name.lower():
|
||||||
|
wrong_found += 1
|
||||||
|
|
||||||
if wrong_found == 1:
|
if wrong_found == 1:
|
||||||
return -30
|
return -30
|
||||||
|
|
||||||
|
return 0
|
||||||
|
except:
|
||||||
|
log.error('Failed doing halfMultipartScore: %s', traceback.format_exc())
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user