From e6aba0a0c9f06cf87de99b79352d14af0c25066b Mon Sep 17 00:00:00 2001 From: marco Date: Wed, 19 Aug 2020 15:00:18 +0200 Subject: [PATCH] =?UTF-8?q?ricerca=20globale=20pi=C3=B9=20precisa?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- channels/tantifilm.py | 3 +- core/item.py | 2 +- core/support.py | 5 +- core/tmdb.py | 308 +++++++++++++++++++++++------------------- specials/search.py | 13 +- 5 files changed, 178 insertions(+), 153 deletions(-) diff --git a/channels/tantifilm.py b/channels/tantifilm.py index ab038597..4deb01ec 100644 --- a/channels/tantifilm.py +++ b/channels/tantifilm.py @@ -50,8 +50,7 @@ def mainlist(item): @support.scrape def peliculas(item): if item.args == 'search': - patron = r'[^<]+)\)[^"]*"[^>]+>\s*[^"]+)".*?
\s*

(?P[^<]+)<\/p>' - # support.regexDbg(item, patron, headers) + patron = r'[0-9]+)[^<]*\)[^"]*"[^>]+>\s*[^"]+)".*?

\s*

(?P[^<]+)<\/p>' else: patronNext = r'

]+)?>?\s*]+>\s*<\/a>[^>]+>[^>]+>[^>]+>(?P.+?)(?P<lang>[sSuUbB\-iItTaA]+)?(?:[ ]?\((?P<year>\d{4})-?(?:\d{4})?)\).[^<]+[^>]+><\/a>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>\s*(?P<quality>[a-zA-Z-0-9\.]+)' diff --git a/core/item.py b/core/item.py index 0da43760..b95e8de3 100644 --- a/core/item.py +++ b/core/item.py @@ -41,7 +41,7 @@ class InfoLabels(dict): # super(InfoLabels, self).__setitem__('code', value) super(InfoLabels, self).__setitem__('imdb_id', str(value)) - elif name == "mediatype" and value not in ["list", "movie", "tvshow", "season", "episode", "music"]: + elif name == "mediatype" and value not in ["list", "movie", "tvshow", "season", "episode", "music", "undefined"]: super(InfoLabels, self).__setitem__('mediatype', 'list') elif name in ['tmdb_id', 'tvdb_id', 'noscrap_id']: diff --git a/core/support.py b/core/support.py index 5a660cec..2fa6b9ef 100755 --- a/core/support.py +++ b/core/support.py @@ -502,8 +502,7 @@ def scrape(func): args=item.args, page=pag + 1, thumbnail=thumb())) - - if action != 'play' and function != 'episodios' and 'patronMenu' not in args and item.contentType in ['movie', 'tvshow', 'episode'] and not disabletmdb: + if action != 'play' and function != 'episodios' and 'patronMenu' not in args and item.contentType in ['movie', 'tvshow', 'episode', 'undefined'] and not disabletmdb: tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True) if anime: @@ -683,7 +682,7 @@ def stayonline(id): return data -def menuItem(itemlist, filename, title='', action='', url='', contentType='movie', args=[], style=True): +def menuItem(itemlist, filename, title='', action='', url='', contentType='undefined', args=[], style=True): # Function to simplify menu creation # Call typo function diff --git a/core/tmdb.py b/core/tmdb.py index e1f2b7f2..63e518c8 100644 --- a/core/tmdb.py +++ b/core/tmdb.py @@ -287,154 +287,180 @@ def set_infoLabels_item(item, seekTmdb=True, idioma_busqueda=def_lang, lock=None item.fanart = item.infoLabels['fanart'] if seekTmdb: + def search(otmdb_global, tipo_busqueda): + if item.infoLabels['season']: + try: + numtemporada = int(item.infoLabels['season']) + except ValueError: + logger.debug("The season number is not valid.") + return -1 * len(item.infoLabels) + + if lock: + lock.acquire() + + if not otmdb_global or ( + item.infoLabels['tmdb_id'] and str(otmdb_global.result.get("id")) != item.infoLabels['tmdb_id']) \ + or ( + otmdb_global.texto_buscado and otmdb_global.texto_buscado != item.infoLabels['tvshowtitle']): + if item.infoLabels['tmdb_id']: + otmdb_global = Tmdb(id_Tmdb=item.infoLabels['tmdb_id'], tipo=tipo_busqueda, + idioma_busqueda=idioma_busqueda) + else: + otmdb_global = Tmdb(texto_buscado=item.infoLabels['tvshowtitle'], tipo=tipo_busqueda, + idioma_busqueda=idioma_busqueda, year=item.infoLabels['year']) + + __leer_datos(otmdb_global) + + # 4l3x87 - fix for overlap infoLabels if there is episode or season + # if lock and lock.locked(): + # lock.release() + + if item.infoLabels['episode']: + try: + episode = int(item.infoLabels['episode']) + except ValueError: + logger.debug("The episode number (%s) is not valid" % repr(item.infoLabels['episode'])) + return -1 * len(item.infoLabels) + + # We have valid season number and episode number... + # ... search episode data + item.infoLabels['mediatype'] = 'episode' + episodio = otmdb_global.get_episodio(numtemporada, episode) + + if episodio: + # Update data + __leer_datos(otmdb_global) + item.infoLabels['title'] = episodio['episodio_titulo'] + if episodio['episodio_sinopsis']: + item.infoLabels['plot'] = episodio['episodio_sinopsis'] + if episodio['episodio_imagen']: + item.infoLabels['poster_path'] = episodio['episodio_imagen'] + item.thumbnail = item.infoLabels['poster_path'] + if episodio['episodio_air_date']: + item.infoLabels['aired'] = episodio['episodio_air_date'] + if episodio['episodio_vote_average']: + item.infoLabels['rating'] = episodio['episodio_vote_average'] + item.infoLabels['votes'] = episodio['episodio_vote_count'] + + # 4l3x87 - fix for overlap infoLabels if there is episode or season + if lock and lock.locked(): + lock.release() + + return len(item.infoLabels) + + else: + # We have a valid season number but no episode number... + # ... search season data + item.infoLabels['mediatype'] = 'season' + temporada = otmdb_global.get_temporada(numtemporada) + if not isinstance(temporada, dict): + temporada = ast.literal_eval(temporada.decode('utf-8')) + + if temporada: + # Update data + __leer_datos(otmdb_global) + item.infoLabels['title'] = temporada['name'] if 'name' in temporada else '' + if 'overview' in temporada and temporada['overview']: + item.infoLabels['plot'] = temporada['overview'] + if 'air_date' in temporada and temporada['air_date']: + date = temporada['air_date'].split('-') + item.infoLabels['aired'] = date[2] + "/" + date[1] + "/" + date[0] + if 'poster_path' in temporada and temporada['poster_path']: + item.infoLabels['poster_path'] = 'http://image.tmdb.org/t/p/original' + temporada[ + 'poster_path'] + item.thumbnail = item.infoLabels['poster_path'] + + # 4l3x87 - fix for overlap infoLabels if there is episode or season + if lock and lock.locked(): + lock.release() + + return len(item.infoLabels) + + # 4l3x87 - fix for overlap infoLabels if there is episode or season + if lock and lock.locked(): + lock.release() + + # Search... + else: + otmdb = copy.copy(otmdb_global) + # Search by ID... + if item.infoLabels['tmdb_id']: + # ...Search for tmdb_id + otmdb = Tmdb(id_Tmdb=item.infoLabels['tmdb_id'], tipo=tipo_busqueda, + idioma_busqueda=idioma_busqueda) + + elif item.infoLabels['imdb_id']: + # ...Search by imdb code + otmdb = Tmdb(external_id=item.infoLabels['imdb_id'], external_source="imdb_id", tipo=tipo_busqueda, + idioma_busqueda=idioma_busqueda) + + elif tipo_busqueda == 'tv': # bsearch with other codes + if item.infoLabels['tvdb_id']: + # ...Search for tvdb_id + otmdb = Tmdb(external_id=item.infoLabels['tvdb_id'], external_source="tvdb_id", + tipo=tipo_busqueda, idioma_busqueda=idioma_busqueda) + elif item.infoLabels['freebase_mid']: + # ...Search for freebase_mid + otmdb = Tmdb(external_id=item.infoLabels['freebase_mid'], external_source="freebase_mid", + tipo=tipo_busqueda, idioma_busqueda=idioma_busqueda) + elif item.infoLabels['freebase_id']: + # ...Search by freebase_id + otmdb = Tmdb(external_id=item.infoLabels['freebase_id'], external_source="freebase_id", + tipo=tipo_busqueda, idioma_busqueda=idioma_busqueda) + elif item.infoLabels['tvrage_id']: + # ...Search by tvrage_id + otmdb = Tmdb(external_id=item.infoLabels['tvrage_id'], external_source="tvrage_id", + tipo=tipo_busqueda, idioma_busqueda=idioma_busqueda) + + # if otmdb is None: + if not item.infoLabels['tmdb_id'] and not item.infoLabels['imdb_id'] and not item.infoLabels[ + 'tvdb_id'] and not item.infoLabels['freebase_mid'] and not item.infoLabels['freebase_id'] and not \ + item.infoLabels['tvrage_id']: + # Could not search by ID ... + # do it by title + if tipo_busqueda == 'tv': + # Serial search by title and filtering your results if necessary + otmdb = Tmdb(texto_buscado=item.infoLabels['tvshowtitle'], tipo=tipo_busqueda, + idioma_busqueda=idioma_busqueda, filtro=item.infoLabels.get('filtro', {}), + year=item.infoLabels['year']) + else: + # Movie search by title ... + # if item.infoLabels['year'] or item.infoLabels['filtro']: + # ...and year or filter + searched_title = item.contentTitle if item.contentTitle else item.fulltitle + otmdb = Tmdb(texto_buscado=searched_title, tipo=tipo_busqueda, idioma_busqueda=idioma_busqueda, + filtro=item.infoLabels.get('filtro', {}), year=item.infoLabels['year']) + if otmdb is not None: + if otmdb.get_id() and config.get_setting("tmdb_plus_info", default=False): + # If the search has been successful and you are not looking for a list of items, + # carry out another search to expand the information + otmdb = Tmdb(id_Tmdb=otmdb.result.get("id"), tipo=tipo_busqueda, + idioma_busqueda=idioma_busqueda) + + if lock and lock.locked(): + lock.release() + + if otmdb is not None and otmdb.get_id(): + # The search has found a valid result + __leer_datos(otmdb) + return len(item.infoLabels) # We check what type of content it is... if item.contentType == 'movie': tipo_busqueda = 'movie' + elif item.contentType == 'undefined': # don't know + results = search(otmdb_global, 'movie') + if results: + item.contentType = 'movie' + else: + results = search(otmdb_global, 'tv') + if results: + item.contentType = 'tvshow' + return results else: tipo_busqueda = 'tv' - if item.infoLabels['season']: - try: - numtemporada = int(item.infoLabels['season']) - except ValueError: - logger.debug("The season number is not valid.") - return -1 * len(item.infoLabels) + return search(otmdb_global, tipo_busqueda) - if lock: - lock.acquire() - - if not otmdb_global or (item.infoLabels['tmdb_id'] and str(otmdb_global.result.get("id")) != item.infoLabels['tmdb_id']) \ - or (otmdb_global.texto_buscado and otmdb_global.texto_buscado != item.infoLabels['tvshowtitle']): - if item.infoLabels['tmdb_id']: - otmdb_global = Tmdb(id_Tmdb=item.infoLabels['tmdb_id'], tipo=tipo_busqueda, idioma_busqueda=idioma_busqueda) - else: - otmdb_global = Tmdb(texto_buscado=item.infoLabels['tvshowtitle'], tipo=tipo_busqueda, idioma_busqueda=idioma_busqueda, year=item.infoLabels['year']) - - __leer_datos(otmdb_global) - - # 4l3x87 - fix for overlap infoLabels if there is episode or season - # if lock and lock.locked(): - # lock.release() - - if item.infoLabels['episode']: - try: - episode = int(item.infoLabels['episode']) - except ValueError: - logger.debug("The episode number (%s) is not valid" % repr(item.infoLabels['episode'])) - return -1 * len(item.infoLabels) - - # We have valid season number and episode number... - # ... search episode data - item.infoLabels['mediatype'] = 'episode' - episodio = otmdb_global.get_episodio(numtemporada, episode) - - if episodio: - # Update data - __leer_datos(otmdb_global) - item.infoLabels['title'] = episodio['episodio_titulo'] - if episodio['episodio_sinopsis']: - item.infoLabels['plot'] = episodio['episodio_sinopsis'] - if episodio['episodio_imagen']: - item.infoLabels['poster_path'] = episodio['episodio_imagen'] - item.thumbnail = item.infoLabels['poster_path'] - if episodio['episodio_air_date']: - item.infoLabels['aired'] = episodio['episodio_air_date'] - if episodio['episodio_vote_average']: - item.infoLabels['rating'] = episodio['episodio_vote_average'] - item.infoLabels['votes'] = episodio['episodio_vote_count'] - - # 4l3x87 - fix for overlap infoLabels if there is episode or season - if lock and lock.locked(): - lock.release() - - return len(item.infoLabels) - - else: - # We have a valid season number but no episode number... - # ... search season data - item.infoLabels['mediatype'] = 'season' - temporada = otmdb_global.get_temporada(numtemporada) - if not isinstance(temporada, dict): - temporada = ast.literal_eval(temporada.decode('utf-8')) - - if temporada: - # Update data - __leer_datos(otmdb_global) - item.infoLabels['title'] = temporada['name'] if 'name' in temporada else '' - if 'overview' in temporada and temporada['overview']: - item.infoLabels['plot'] = temporada['overview'] - if 'air_date' in temporada and temporada['air_date']: - date = temporada['air_date'].split('-') - item.infoLabels['aired'] = date[2] + "/" + date[1] + "/" + date[0] - if 'poster_path' in temporada and temporada['poster_path']: - item.infoLabels['poster_path'] = 'http://image.tmdb.org/t/p/original' + temporada['poster_path'] - item.thumbnail = item.infoLabels['poster_path'] - - # 4l3x87 - fix for overlap infoLabels if there is episode or season - if lock and lock.locked(): - lock.release() - - return len(item.infoLabels) - - # 4l3x87 - fix for overlap infoLabels if there is episode or season - if lock and lock.locked(): - lock.release() - - # Search... - else: - otmdb = copy.copy(otmdb_global) - # Search by ID... - if item.infoLabels['tmdb_id']: - # ...Search for tmdb_id - otmdb = Tmdb(id_Tmdb=item.infoLabels['tmdb_id'], tipo=tipo_busqueda, idioma_busqueda=idioma_busqueda) - - elif item.infoLabels['imdb_id']: - # ...Search by imdb code - otmdb = Tmdb(external_id=item.infoLabels['imdb_id'], external_source="imdb_id", tipo=tipo_busqueda, idioma_busqueda=idioma_busqueda) - - elif tipo_busqueda == 'tv': # bsearch with other codes - if item.infoLabels['tvdb_id']: - # ...Search for tvdb_id - otmdb = Tmdb(external_id=item.infoLabels['tvdb_id'], external_source="tvdb_id", tipo=tipo_busqueda, idioma_busqueda=idioma_busqueda) - elif item.infoLabels['freebase_mid']: - # ...Search for freebase_mid - otmdb = Tmdb(external_id=item.infoLabels['freebase_mid'], external_source="freebase_mid", tipo=tipo_busqueda, idioma_busqueda=idioma_busqueda) - elif item.infoLabels['freebase_id']: - # ...Search by freebase_id - otmdb = Tmdb(external_id=item.infoLabels['freebase_id'], external_source="freebase_id", tipo=tipo_busqueda, idioma_busqueda=idioma_busqueda) - elif item.infoLabels['tvrage_id']: - # ...Search by tvrage_id - otmdb = Tmdb(external_id=item.infoLabels['tvrage_id'], external_source="tvrage_id", tipo=tipo_busqueda, idioma_busqueda=idioma_busqueda) - - # if otmdb is None: - if not item.infoLabels['tmdb_id'] and not item.infoLabels['imdb_id'] and not item.infoLabels['tvdb_id'] and not item.infoLabels['freebase_mid'] and not item.infoLabels['freebase_id'] and not item.infoLabels['tvrage_id']: - # Could not search by ID ... - # do it by title - if tipo_busqueda == 'tv': - # Serial search by title and filtering your results if necessary - otmdb = Tmdb(texto_buscado=item.infoLabels['tvshowtitle'], tipo=tipo_busqueda, - idioma_busqueda=idioma_busqueda, filtro=item.infoLabels.get('filtro', {}), - year=item.infoLabels['year']) - else: - # Movie search by title ... - # if item.infoLabels['year'] or item.infoLabels['filtro']: - # ...and year or filter - searched_title = item.contentTitle if item.contentTitle else item.fulltitle - otmdb = Tmdb(texto_buscado=searched_title, tipo=tipo_busqueda, idioma_busqueda=idioma_busqueda, - filtro=item.infoLabels.get('filtro', {}), year=item.infoLabels['year']) - if otmdb is not None: - if otmdb.get_id() and config.get_setting("tmdb_plus_info", default=False): - # If the search has been successful and you are not looking for a list of items, - # carry out another search to expand the information - otmdb = Tmdb(id_Tmdb=otmdb.result.get("id"), tipo=tipo_busqueda, idioma_busqueda=idioma_busqueda) - - if lock and lock.locked(): - lock.release() - - if otmdb is not None and otmdb.get_id(): - # The search has found a valid result - __leer_datos(otmdb) - return len(item.infoLabels) # Search in tmdb is deactivated or has not given result # item.contentType = item.infoLabels['mediatype'] return -1 * len(item.infoLabels) diff --git a/specials/search.py b/specials/search.py index 135dde4d..bb83850c 100644 --- a/specials/search.py +++ b/specials/search.py @@ -175,10 +175,10 @@ def channel_search(item): max_results = 10 if item.infoLabels['tvshowtitle']: - item.text = item.infoLabels['tvshowtitle'] + item.text = item.infoLabels['tvshowtitle'].split('-')[0] item.title = item.text elif item.infoLabels['title']: - item.text = item.infoLabels['title'] + item.text = item.infoLabels['title'].split('-')[0] item.title = item.text temp_search_file = config.get_temp_file('temp-search') @@ -213,7 +213,7 @@ def channel_search(item): module_dict[ch] = module search_action_list.extend([elem for elem in mainlist if - elem.action == "search" and (mode == 'all' or elem.contentType == mode)]) + elem.action == "search" and (mode == 'all' or elem.contentType in [mode, 'undefined'])]) if progress.iscanceled(): return [] except: @@ -338,10 +338,11 @@ def channel_search(item): if mode == 'all': results.insert(0, Item(title=typo(results_statistic, 'color kod bold'), thumbnail=get_thumb('search.png'))) else: - valid.insert(0, Item(title=typo(results_statistic, 'color kod bold'), thumbnail=get_thumb('search.png'))) + if not valid: + valid.append(Item(title=config.get_localized_string(60347), thumbnail=get_thumb('nofolder.png'))) - if results: - results.insert(0, Item(title=typo(config.get_localized_string(30025), 'color kod bold'), thumbnail=get_thumb('search.png'))) + valid.insert(0, Item(title=typo(results_statistic, 'color kod bold'), thumbnail=get_thumb('search.png'))) + results.insert(0, Item(title=typo(config.get_localized_string(30025), 'color kod bold'), thumbnail=get_thumb('search.png'))) # logger.debug(results_statistic) itlist = valid + results