Fix Tmdb In caso non si conosca il mediatype e sia presente l'anno

This commit is contained in:
Alhaziel01
2022-08-23 18:08:37 +02:00
parent f590067983
commit fb80f47bc8
2 changed files with 8 additions and 2 deletions

View File

@@ -70,7 +70,7 @@ def peliculas(item):
action = 'check'
patron = r'src="(?P<poster>http[^"]+)(?:[^>]+>){4}\s*<a href="(?P<url>[^"]+)[^>]+>\s*(?P<title>[^\[\(\<]+)(?:\[(?P<quality>[^\]]+)\])?\s*(?:\((?P<lang>[a-zA-z-]+)\))?\s*(?:\((?P<year>\d+)\))?\s*</a>\s*</h2>'
if item.args == 'search':
patron = '<title>(?P<title>[^\[\(\<]+)(?:\[(?P<quality>[^\]]+)\])?\s*(?:\((?P<lang>[a-zA-z-]+)\))?[^>]+>\s*<link>(?P<url>[^<]+)'
patron = r'<title>(?P<title>[^\[\(\<]+)(?:\[(?P<quality>[^\]]+)\])?\s*(?:\((?P<lang>[a-zA-z-]+)\))?\s*(?:\((?P<year>\d+)\))?\s*[^>]+>\s*<link>(?P<url>[^<]+)'
patronNext = r'href="([^"]+)[^>]+>Successivo'
return locals()

View File

@@ -1033,6 +1033,12 @@ class Tmdb(object):
if len(results) > 1:
from lib.fuzzy_match import algorithims
if self.search_type == 'multi':
if self.search_year:
for r in results:
if (r.get('release_date', '') and r.get('release_date', '')[:4] == self.search_year) or (r.get('first_air_date', '') and r.get('first_air_date', '')[:4] == self.search_year):
results = [r]
break
if len(results) > 1:
results.sort(key=lambda r: algorithims.trigram(text_simple, r.get('name', '') if r.get('media_type') == 'tv' else r.get('title', '')), reverse=True)
else:
results.sort(key=lambda r: algorithims.trigram(text_simple, r.get('name', '') if self.search_type == 'tv' else r.get('title', '')), reverse=True)