def callback_cuadro_completar(item, dict_values): # logger.debug(dict_values) global dict_default if dict_values.get("title", None): # Adaptar dict_values a infoLabels validos dict_values['mediatype'] = ['movie', 'tvshow'][dict_values['mediatype']] for k, v in dict_values.items(): if k in dict_default and dict_default[k] == dict_values[k]: del dict_values[k] if isinstance(item.infoLabels, InfoLabels): infoLabels = item.infoLabels else: infoLabels = InfoLabels() infoLabels.update(dict_values) item.infoLabels = infoLabels if item.infoLabels['code']: return True return False
def find_and_set_infoLabels(item): """ función que se llama para buscar y setear los infolabels :param item: :return: """ global scraper_global logger.debug("item:\n" + item.tostring('\n')) params = {} if item.contentType == "movie": tipo_contenido = "pelicula" title = item.contentTitle # get scraper pelis scraper = Tmdb() # para tmdb tipo_busqueda = "movie" else: tipo_contenido = "serie" title = item.contentSerieName # get scraper series scraper = Tmdb() # para tmdb tipo_busqueda = "tv" # esto ya está en el scraper tmdb # title = re.sub('\[\\\?(B|I|COLOR)\s?[^\]]*\]', '', title) # Si el titulo incluye el (año) se lo quitamos year = scrapertools.find_single_match(title, "^.+?\s*(\(\d{4}\))$") if year: title = title.replace(year, "").strip() item.infoLabels['year'] = year[1:-1] scraper_result = None results = [] while not scraper_result: # para tmdb if isinstance(scraper, Tmdb): logger.debug("scraper es Tmbdb") params["texto_buscado"] = title params["tipo"] = tipo_busqueda params["year"] = item.infoLabels['year'] if not results: if not item.infoLabels.get("tmdb_id"): if not item.infoLabels.get("imdb_id"): scraper_global = scraper(**params) else: logger.info("tiene imdb") # para tmdb if isinstance(scraper, Tmdb): params["external_id"] = item.infoLabels.get("imdb_id") params["external_source"] = "imdb_id" scraper_global = scraper(**params) elif not scraper_global or scraper_global.result.get("id") != item.infoLabels['tmdb_id']: # para tmdb if isinstance(scraper, Tmdb): params["id_Tmdb"] = item.infoLabels['tmdb_id'] params["idioma_busqueda"] = "es" scraper_global = scraper(**params) results = scraper_global.get_list_resultados() if len(results) > 1: scraper_result = platformtools.show_video_info(results, item=item, scraper=scraper, caption="[%s]: Selecciona la %s correcta" % (title, tipo_contenido)) elif len(results) > 0: scraper_result = results[0] if scraper_result is None: index = -1 if tipo_contenido == "serie": # Si no lo encuentra la serie por si solo, presentamos una lista de opciones opciones = ["Introducir otro nombre", "Buscar en TheTvDB.com"] index = platformtools.dialog_select("%s no encontrada" % tipo_contenido.capitalize(), opciones) elif platformtools.dialog_yesno("Película no encontrada", "No se ha encontrado la película:", title, '¿Desea introducir otro nombre?'): index = 0 if index < 0: logger.debug("he pulsado 'cancelar' en la ventana '%s no encontrada'" % tipo_contenido.capitalize()) break if index == 0: # "Introducir otro nombre" # Pregunta el titulo it = platformtools.dialog_input(title, "Introduzca el nombre de la %s a buscar" % tipo_contenido) if it is not None: title = it item.infoLabels['year'] = "" # reseteamos los resultados results = [] else: logger.debug("he pulsado 'cancelar' en la ventana 'introduzca el nombre correcto'") break if index == 1: # "Buscar en TheTvDB.com" results = tvdb_series_by_title(title) if isinstance(item.infoLabels, InfoLabels): infoLabels = item.infoLabels else: infoLabels = InfoLabels() if scraper_result: if 'id' in scraper_result: # resultados obtenidos de tmdb infoLabels['tmdb_id'] = scraper_result['id'] infoLabels['url_scraper'] = "https://www.themoviedb.org/tv/%s" % infoLabels['tmdb_id'] item.infoLabels = infoLabels tmdb.set_infoLabels_item(item) elif 'tvdb_id' in scraper_result: # resultados obtenidos de tvdb infoLabels.update(scraper_result) item.infoLabels = infoLabels # logger.debug("item:\n" + item.tostring('\n')) return True else: item.infoLabels = infoLabels return False
def find_and_set_infoLabels(item): """ función que se llama para buscar y setear los infolabels :param item: :return: """ global scraper_global logger.debug("item:\n" + item.tostring('\n')) params = {} if item.contentType == "movie": tipo_contenido = "pelicula" title = item.contentTitle # get scraper pelis scraper = Tmdb() # para tmdb tipo_busqueda = "movie" else: tipo_contenido = "serie" title = item.contentSerieName # get scraper series scraper = Tmdb() # para tmdb tipo_busqueda = "tv" # esto ya está en el scraper tmdb # title = re.sub('\[\\\?(B|I|COLOR)\s?[^\]]*\]', '', title) # Si el titulo incluye el (año) se lo quitamos year = scrapertools.find_single_match(title, "^.+?\s*(\(\d{4}\))$") if year: title = title.replace(year, "").strip() item.infoLabels['year'] = year[1:-1] scraper_result = None results = [] while not scraper_result: # para tmdb if isinstance(scraper, Tmdb): logger.debug("scraper es Tmbdb") params["texto_buscado"] = title params["tipo"] = tipo_busqueda params["year"] = item.infoLabels['year'] if not results: if not item.infoLabels.get("tmdb_id"): if not item.infoLabels.get("imdb_id"): scraper_global = scraper(**params) else: logger.info("tiene imdb") # para tmdb if isinstance(scraper, Tmdb): params["external_id"] = item.infoLabels.get("imdb_id") params["external_source"] = "imdb_id" scraper_global = scraper(**params) elif not scraper_global or scraper_global.result.get( "id") != item.infoLabels['tmdb_id']: # para tmdb if isinstance(scraper, Tmdb): params["id_Tmdb"] = item.infoLabels['tmdb_id'] params["idioma_busqueda"] = "es" scraper_global = scraper(**params) results = scraper_global.get_list_resultados() if len(results) > 1: scraper_result = platformtools.show_video_info( results, item=item, scraper=scraper, caption="[%s]: Selecciona la %s correcta" % (title, tipo_contenido)) elif len(results) > 0: scraper_result = results[0] if scraper_result is None: index = -1 if tipo_contenido == "serie": # Si no lo encuentra la serie por si solo, presentamos una lista de opciones opciones = ["Introducir otro nombre", "Buscar en TheTvDB.com"] index = platformtools.dialog_select( "%s no encontrada" % tipo_contenido.capitalize(), opciones) elif platformtools.dialog_yesno( "Película no encontrada", "No se ha encontrado la película:", title, '¿Desea introducir otro nombre?'): index = 0 if index < 0: logger.debug( "he pulsado 'cancelar' en la ventana '%s no encontrada'" % tipo_contenido.capitalize()) break if index == 0: # "Introducir otro nombre" # Pregunta el titulo it = platformtools.dialog_input( title, "Introduzca el nombre de la %s a buscar" % tipo_contenido) if it is not None: title = it item.infoLabels['year'] = "" # reseteamos los resultados results = [] else: logger.debug( "he pulsado 'cancelar' en la ventana 'introduzca el nombre correcto'" ) break if index == 1: # "Buscar en TheTvDB.com" results = tvdb_series_by_title(title) if isinstance(item.infoLabels, InfoLabels): infoLabels = item.infoLabels else: infoLabels = InfoLabels() if scraper_result: if 'id' in scraper_result: # resultados obtenidos de tmdb infoLabels['tmdb_id'] = scraper_result['id'] infoLabels[ 'url_scraper'] = "https://www.themoviedb.org/tv/%s" % infoLabels[ 'tmdb_id'] item.infoLabels = infoLabels tmdb.set_infoLabels_item(item) elif 'tvdb_id' in scraper_result: # resultados obtenidos de tvdb infoLabels.update(scraper_result) item.infoLabels = infoLabels # logger.debug("item:\n" + item.tostring('\n')) return True else: item.infoLabels = infoLabels return False