Fix TMDB (film)
This commit is contained in:
+49
-19
@@ -128,7 +128,7 @@ def cache_response(fn):
|
|||||||
else:
|
else:
|
||||||
|
|
||||||
url = re.sub('&year=-', '', args[0])
|
url = re.sub('&year=-', '', args[0])
|
||||||
if PY3: url = str.encode(url)
|
# if PY3: url = str.encode(url)
|
||||||
|
|
||||||
row = db['tmdb_cache'].get(url)
|
row = db['tmdb_cache'].get(url)
|
||||||
|
|
||||||
@@ -411,24 +411,51 @@ def set_infoLabels_item(item, seekTmdb=True, idioma_busqueda=def_lang, lock=None
|
|||||||
__leer_datos(otmdb)
|
__leer_datos(otmdb)
|
||||||
return len(item.infoLabels)
|
return len(item.infoLabels)
|
||||||
|
|
||||||
def unify():
|
# title might contain - or : --> try to search only second title
|
||||||
new_title = scrapertools.title_unify(item.fulltitle)
|
def splitTitle():
|
||||||
if new_title != item.fulltitle:
|
if '-' in item.fulltitle:
|
||||||
item.infoLabels['tvshowtitle'] = scrapertools.title_unify(item.infoLabels['tvshowtitle'])
|
item.infoLabels['tvshowtitle'] = item.fulltitle.split('-')[1]
|
||||||
item.infoLabels['title'] = scrapertools.title_unify(item.infoLabels['title'])
|
item.infoLabels['title'] = item.infoLabels['tvshowtitle']
|
||||||
item.fulltitle = new_title
|
elif ':' in item.fulltitle:
|
||||||
return True
|
item.infoLabels['tvshowtitle'] = item.fulltitle.split(':')[1]
|
||||||
|
item.infoLabels['title'] = item.infoLabels['tvshowtitle']
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
# We check what type of content it is...
|
# We check what type of content it is...
|
||||||
if item.contentType == 'movie':
|
if item.contentType == 'movie':
|
||||||
tipo_busqueda = 'movie'
|
tipo_busqueda = 'movie'
|
||||||
elif item.contentType == 'undefined': # don't know
|
elif item.contentType == 'undefined': # don't know
|
||||||
tipo_busqueda = 'multi'
|
def detect():
|
||||||
|
# try movie first
|
||||||
|
results = search(otmdb_global, 'movie')
|
||||||
|
if results:
|
||||||
|
item.contentType = 'movie'
|
||||||
|
infoMovie = item.infoLabels
|
||||||
|
if infoMovie['title'] == item.fulltitle: # exact match -> it's probably correct
|
||||||
|
return results
|
||||||
|
|
||||||
|
# try tvshow then
|
||||||
|
item.infoLabels = {'tvshowtitle': item.infoLabels['tvshowtitle']} # reset infolabels
|
||||||
|
results = search(otmdb_global, 'tv')
|
||||||
|
if results:
|
||||||
|
item.contentType = 'tvshow'
|
||||||
|
else:
|
||||||
|
item.infoLabels = infoMovie
|
||||||
|
|
||||||
|
return results
|
||||||
|
|
||||||
|
results = detect()
|
||||||
|
if not results:
|
||||||
|
if splitTitle():
|
||||||
|
results = detect()
|
||||||
|
return results
|
||||||
else:
|
else:
|
||||||
tipo_busqueda = 'tv'
|
tipo_busqueda = 'tv'
|
||||||
|
|
||||||
ret = search(otmdb_global, tipo_busqueda)
|
ret = search(otmdb_global, tipo_busqueda)
|
||||||
if not ret: # try with unified title
|
if not ret:
|
||||||
if unify():
|
if splitTitle():
|
||||||
ret = search(otmdb_global, tipo_busqueda)
|
ret = search(otmdb_global, tipo_busqueda)
|
||||||
return ret
|
return ret
|
||||||
# Search in tmdb is deactivated or has not given result
|
# Search in tmdb is deactivated or has not given result
|
||||||
@@ -871,6 +898,7 @@ class Tmdb(object):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
@cache_response
|
@cache_response
|
||||||
def get_json(url, cache=True):
|
def get_json(url, cache=True):
|
||||||
|
# from core.support import dbg;dbg()
|
||||||
try:
|
try:
|
||||||
result = httptools.downloadpage(url, cookies=False, ignore_response_code=True)
|
result = httptools.downloadpage(url, cookies=False, ignore_response_code=True)
|
||||||
|
|
||||||
@@ -927,6 +955,7 @@ class Tmdb(object):
|
|||||||
logger.error(traceback.format_exc())
|
logger.error(traceback.format_exc())
|
||||||
|
|
||||||
def __by_id(self, source='tmdb'):
|
def __by_id(self, source='tmdb'):
|
||||||
|
# from core.support import dbg;dbg()
|
||||||
|
|
||||||
if self.busqueda_id:
|
if self.busqueda_id:
|
||||||
if source == "tmdb":
|
if source == "tmdb":
|
||||||
@@ -1021,7 +1050,7 @@ class Tmdb(object):
|
|||||||
# We sort result based on fuzzy match to detect most similar
|
# We sort result based on fuzzy match to detect most similar
|
||||||
if len(results) > 1:
|
if len(results) > 1:
|
||||||
from lib.fuzzy_match import algorithims
|
from lib.fuzzy_match import algorithims
|
||||||
results.sort(key=lambda r: algorithims.trigram(text_simple, r.get('name', '') if self.busqueda_tipo == 'tv' else r.get('title', '')), reverse=True)
|
results.sort(key=lambda r: algorithims.trigram(text_simple, r['title'] if self.busqueda_tipo == 'movie' else r['name']), reverse=True)
|
||||||
|
|
||||||
# We return the number of results of this page
|
# We return the number of results of this page
|
||||||
self.results = results
|
self.results = results
|
||||||
@@ -1036,6 +1065,7 @@ class Tmdb(object):
|
|||||||
logger.error(msg)
|
logger.error(msg)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def __discover(self, index_results=0):
|
def __discover(self, index_results=0):
|
||||||
self.result = ResultDictDefault()
|
self.result = ResultDictDefault()
|
||||||
results = []
|
results = []
|
||||||
@@ -1134,16 +1164,15 @@ class Tmdb(object):
|
|||||||
try:
|
try:
|
||||||
if self.load_resultado(r, p):
|
if self.load_resultado(r, p):
|
||||||
result = self.result.copy()
|
result = self.result.copy()
|
||||||
if result['first_air_date']:
|
|
||||||
|
|
||||||
result['thumbnail'] = self.get_poster(size="w300")
|
result['thumbnail'] = self.get_poster(size="w300")
|
||||||
result['fanart'] = self.get_backdrop()
|
result['fanart'] = self.get_backdrop()
|
||||||
|
|
||||||
res.append(result)
|
res.append(result)
|
||||||
cr += 1
|
cr += 1
|
||||||
|
|
||||||
if cr >= num_result:
|
if cr >= num_result:
|
||||||
return res
|
return res
|
||||||
except:
|
except:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -1200,6 +1229,7 @@ class Tmdb(object):
|
|||||||
:rtype: str
|
:rtype: str
|
||||||
"""
|
"""
|
||||||
ret = ""
|
ret = ""
|
||||||
|
# from core.support import dbg;dbg()
|
||||||
|
|
||||||
if 'id' in self.result:
|
if 'id' in self.result:
|
||||||
ret = self.result.get('overview')
|
ret = self.result.get('overview')
|
||||||
|
|||||||
Reference in New Issue
Block a user