From 2fdc2319679753b1ec19132e405cf3fea4422e41 Mon Sep 17 00:00:00 2001 From: mac12m99 <10120390+mac12m99@users.noreply.github.com> Date: Wed, 28 Apr 2021 18:31:05 +0200 Subject: [PATCH] Correzioni varie --- core/tmdb.py | 55 ++++++++-------------------------------- specials/globalsearch.py | 15 +++++------ 2 files changed, 18 insertions(+), 52 deletions(-) diff --git a/core/tmdb.py b/core/tmdb.py index 3e1219b7..a322481e 100644 --- a/core/tmdb.py +++ b/core/tmdb.py @@ -302,8 +302,6 @@ def set_infoLabels_item(item, seekTmdb=True, idioma_busqueda=def_lang, lock=None episodio = otmdb_global.get_episodio(numtemporada, episode) if episodio: - if episode == 89: - logger.debug('EPISODIO', jsontools.dump(episodio)) # Update data __leer_datos(otmdb_global) if episodio.get('episodio_titulo'): @@ -421,51 +419,24 @@ def set_infoLabels_item(item, seekTmdb=True, idioma_busqueda=def_lang, lock=None __leer_datos(otmdb) return len(item.infoLabels) - # title might contain - or : --> try to search only second title - def splitTitle(): - if '-' in item.fulltitle: - item.infoLabels['tvshowtitle'] = item.fulltitle.split('-')[1] - item.infoLabels['title'] = item.infoLabels['tvshowtitle'] - elif ':' in item.fulltitle: - item.infoLabels['tvshowtitle'] = item.fulltitle.split(':')[1] - item.infoLabels['title'] = item.infoLabels['tvshowtitle'] - else: - return False - return True + def unify(): + new_title = scrapertools.title_unify(item.fulltitle) + if new_title != item.fulltitle: + item.infoLabels['tvshowtitle'] = scrapertools.title_unify(item.infoLabels['tvshowtitle']) + item.infoLabels['title'] = scrapertools.title_unify(item.infoLabels['title']) + item.fulltitle = new_title + return True # We check what type of content it is... if item.contentType == 'movie': tipo_busqueda = 'movie' elif item.contentType == 'undefined': # don't know - 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 + tipo_busqueda = 'multi' else: tipo_busqueda = 'tv' ret = search(otmdb_global, tipo_busqueda) - if not ret: - if splitTitle(): + if not ret: # try with unified title + if unify(): ret = search(otmdb_global, tipo_busqueda) return ret # Search in tmdb is deactivated or has not given result @@ -866,9 +837,6 @@ class Tmdb(object): self.temporada = {} self.texto_buscado = kwargs.get('texto_buscado', '') - if type(self.texto_buscado) == list: - logger.debug('TESTO CERCATO', self.texto_buscado) - self.texto_buscado = self.texto_buscado[0] self.busqueda_id = kwargs.get('id_Tmdb', '') self.busqueda_texto = re.sub('\[\\\?(B|I|COLOR)\s?[^\]]*\]', '', self.texto_buscado).strip() @@ -1063,7 +1031,7 @@ class Tmdb(object): # We sort result based on fuzzy match to detect most similar if len(results) > 1: from lib.fuzzy_match import algorithims - results.sort(key=lambda r: algorithims.trigram(text_simple, r['title'] if self.busqueda_tipo == 'movie' else r['name']), reverse=True) + results.sort(key=lambda r: algorithims.trigram(text_simple, r.get('name', '') if self.busqueda_tipo == 'tv' else r.get('title', '')), reverse=True) # We return the number of results of this page self.results = results @@ -1078,7 +1046,6 @@ class Tmdb(object): logger.error(msg) return 0 - def __discover(self, index_results=0): self.result = ResultDictDefault() results = [] diff --git a/specials/globalsearch.py b/specials/globalsearch.py index 67db96e2..1afe7f0a 100644 --- a/specials/globalsearch.py +++ b/specials/globalsearch.py @@ -325,12 +325,12 @@ class SearchWindow(xbmcgui.WindowXML): for searchAction in self.searchActions: if self.exit: return self.search_threads.append(executor.submit(self.get_channel_results, searchAction)) - # for ch in futures.as_completed(self.search_threads): - # self.count += 1 - # if self.exit: return - # if ch.result(): - # channel, valid, other = ch.result() - # self.update(channel, valid, other) + for ch in futures.as_completed(self.search_threads): + self.count += 1 + if self.exit: return + if ch.result(): + channel, valid, other = ch.result() + self.update(channel, valid, other) except: import traceback logger.error(traceback.format_exc()) @@ -379,8 +379,7 @@ class SearchWindow(xbmcgui.WindowXML): import traceback logger.error(traceback.format_exc()) - self.count += 1 - return self.update(channel, valid, other if other else results) + return channel, valid, other if other else results def makeItem(self, url): item = Item().fromurl(url)