Added "library.root" event, fixes to "matcher", "release" and "score" to use "library.root" + handle missing "year"
This commit is contained in:
@@ -11,6 +11,7 @@ class Library(LibraryBase):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
addEvent('library.title', self.title)
|
addEvent('library.title', self.title)
|
||||||
addEvent('library.related', self.related)
|
addEvent('library.related', self.related)
|
||||||
|
addEvent('library.root', self.root)
|
||||||
|
|
||||||
addApiView('library.query', self.queryView)
|
addApiView('library.query', self.queryView)
|
||||||
addApiView('library.related', self.relatedView)
|
addApiView('library.related', self.relatedView)
|
||||||
@@ -54,3 +55,12 @@ class Library(LibraryBase):
|
|||||||
result[cur['type']] = cur
|
result[cur['type']] = cur
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def root(self, media):
|
||||||
|
db = get_db()
|
||||||
|
cur = media
|
||||||
|
|
||||||
|
while cur and cur.get('parent_id'):
|
||||||
|
cur = db.get('id', cur['parent_id'])
|
||||||
|
|
||||||
|
return cur
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class Matcher(MatcherBase):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def correctTitle(self, chain, media):
|
def correctTitle(self, chain, media):
|
||||||
root_library = media['library']['root_library']
|
root = fireEvent('library.root', media, single = True)
|
||||||
|
|
||||||
if 'show_name' not in chain.info or not len(chain.info['show_name']):
|
if 'show_name' not in chain.info or not len(chain.info['show_name']):
|
||||||
log.info('Wrong: missing show name in parsed result')
|
log.info('Wrong: missing show name in parsed result')
|
||||||
@@ -50,10 +50,10 @@ class Matcher(MatcherBase):
|
|||||||
chain_words = [x.lower() for x in chain.info['show_name']]
|
chain_words = [x.lower() for x in chain.info['show_name']]
|
||||||
|
|
||||||
# Build a list of possible titles of the media we are searching for
|
# Build a list of possible titles of the media we are searching for
|
||||||
titles = root_library['info']['titles']
|
titles = root['info']['titles']
|
||||||
|
|
||||||
# Add year suffix titles (will result in ['<name_one>', '<name_one> <suffix_one>', '<name_two>', ...])
|
# Add year suffix titles (will result in ['<name_one>', '<name_one> <suffix_one>', '<name_two>', ...])
|
||||||
suffixes = [None, root_library['info']['year']]
|
suffixes = [None, root['info']['year']]
|
||||||
|
|
||||||
titles = [
|
titles = [
|
||||||
title + ((' %s' % suffix) if suffix else '')
|
title + ((' %s' % suffix) if suffix else '')
|
||||||
|
|||||||
@@ -315,7 +315,7 @@ class Release(Plugin):
|
|||||||
rls['download_info'] = download_result
|
rls['download_info'] = download_result
|
||||||
db.update(rls)
|
db.update(rls)
|
||||||
|
|
||||||
log_movie = '%s (%s) in %s' % (getTitle(media), media['info']['year'], rls['quality'])
|
log_movie = '%s (%s) in %s' % (getTitle(media), media['info'].get('year'), rls['quality'])
|
||||||
snatch_message = 'Snatched "%s": %s' % (data.get('name'), log_movie)
|
snatch_message = 'Snatched "%s": %s' % (data.get('name'), log_movie)
|
||||||
log.info(snatch_message)
|
log.info(snatch_message)
|
||||||
fireEvent('%s.snatched' % data['type'], message = snatch_message, data = rls)
|
fireEvent('%s.snatched' % data['type'], message = snatch_message, data = rls)
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class Score(Plugin):
|
|||||||
try: preferred_words = removeDuplicate(preferred_words + splitString(movie['category']['preferred'].lower()))
|
try: preferred_words = removeDuplicate(preferred_words + splitString(movie['category']['preferred'].lower()))
|
||||||
except: pass
|
except: pass
|
||||||
|
|
||||||
score = nameScore(toUnicode(nzb['name']), movie['info']['year'], preferred_words)
|
score = nameScore(toUnicode(nzb['name']), movie['info'].get('year'), preferred_words)
|
||||||
|
|
||||||
for movie_title in movie['info']['titles']:
|
for movie_title in movie['info']['titles']:
|
||||||
score += nameRatioScore(toUnicode(nzb['name']), toUnicode(movie_title))
|
score += nameRatioScore(toUnicode(nzb['name']), toUnicode(movie_title))
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ def nameScore(name, year, preferred_words):
|
|||||||
score += add
|
score += add
|
||||||
|
|
||||||
# points if the year is correct
|
# points if the year is correct
|
||||||
if str(year) in name:
|
if year and str(year) in name:
|
||||||
score += 5
|
score += 5
|
||||||
|
|
||||||
# Contains preferred word
|
# Contains preferred word
|
||||||
|
|||||||
Reference in New Issue
Block a user