Altre Traduzioni

This commit is contained in:
Alhaziel01
2020-05-27 12:31:48 +02:00
parent 4d1d84779d
commit 65d8d63733
8 changed files with 442 additions and 496 deletions
+32 -34
View File
@@ -9,8 +9,7 @@ from core.item import InfoLabels
from platformcode import config, logger
from platformcode import platformtools
# Este modulo es una interface para poder implementar diferentes scrapers
# contendra todos las funciones comunes
# This module is an interface to implement different scrapers, it will contain all the common functions
dict_default = None
scraper = None
@@ -18,36 +17,35 @@ scraper = None
def find_and_set_infoLabels(item):
"""
función que se llama para buscar y setear los infolabels
function called to search and set infolabels
:param item:
:return: boleano que indica si se ha podido encontrar el 'code'
:return: Boolean indicating if the 'code' could be found
"""
global scraper
scraper = None
# logger.debug("item:\n" + item.tostring('\n'))
list_opciones_cuadro = [config.get_localized_string(60223), config.get_localized_string(60224)]
# Si se añaden más scrapers hay q declararlos aqui-> "modulo_scraper": "Texto_en_cuadro"
scrapers_disponibles = {'tmdb': config.get_localized_string(60225),
'tvdb': config.get_localized_string(60226)}
# If more scrapers are added, they must be declared here-> "modulo_scraper": "Text_in_box"
scrapers_disponibles = {'tmdb': config.get_localized_string(60225), 'tvdb': config.get_localized_string(60226)}
# Obtener el Scraper por defecto de la configuracion segun el tipo de contenido
# Get the default Scraper of the configuration according to the content type
if item.contentType == "movie":
scraper_actual = ['tmdb'][config.get_setting("scraper_movies", "videolibrary")]
tipo_contenido = config.get_localized_string(70283)
title = item.contentTitle
# Completar lista de opciones para este tipo de contenido
# Complete list of options for this type of content
list_opciones_cuadro.append(scrapers_disponibles['tmdb'])
else:
scraper_actual = ['tmdb', 'tvdb'][config.get_setting("scraper_tvshows", "videolibrary")]
tipo_contenido = "serie"
title = item.contentSerieName
# Completar lista de opciones para este tipo de contenido
# Complete list of options for this type of content
list_opciones_cuadro.append(scrapers_disponibles['tmdb'])
list_opciones_cuadro.append(scrapers_disponibles['tvdb'])
# Importamos el scraper
# We import the scraper
try:
scraper = __import__('core.%s' % scraper_actual, fromlist=["core.%s" % scraper_actual])
except ImportError:
@@ -57,34 +55,34 @@ def find_and_set_infoLabels(item):
logger.error(traceback.format_exc())
while scraper:
# Llamamos a la funcion find_and_set_infoLabels del scraper seleccionado
# We call the find_and_set_infoLabels function of the selected scraper
scraper_result = scraper.find_and_set_infoLabels(item)
# Verificar si existe 'code'
# Check if there is a 'code'
if scraper_result and item.infoLabels['code']:
# code correcto
# correct code
logger.info("Identificador encontrado: %s" % item.infoLabels['code'])
scraper.completar_codigos(item)
return True
elif scraper_result:
# Contenido encontrado pero no hay 'code'
# Content found but no 'code'
msg = config.get_localized_string(60227) % title
else:
# Contenido no encontrado
# Content not found
msg = config.get_localized_string(60228) % title
logger.info(msg)
# Mostrar cuadro con otras opciones:
# Show box with other options:
if scrapers_disponibles[scraper_actual] in list_opciones_cuadro:
list_opciones_cuadro.remove(scrapers_disponibles[scraper_actual])
index = platformtools.dialog_select(msg, list_opciones_cuadro)
if index < 0:
logger.debug("Se ha pulsado 'cancelar' en la ventana '%s'" % msg)
logger.debug("You have clicked 'cancel' in the window '%s'" % msg)
return False
elif index == 0:
# Pregunta el titulo
# Ask the title
title = platformtools.dialog_input(title, config.get_localized_string(60229) % tipo_contenido)
if title:
if item.contentType == "movie":
@@ -92,25 +90,25 @@ def find_and_set_infoLabels(item):
else:
item.contentSerieName = title
else:
logger.debug("he pulsado 'cancelar' en la ventana 'Introduzca el nombre correcto'")
logger.debug("I clicked 'cancel' in the window 'Enter the correct name'")
return False
elif index == 1:
# Hay q crear un cuadro de dialogo para introducir los datos
logger.info("Completar información")
# You have to create a dialog box to enter the data
logger.info("Complete information")
if cuadro_completar(item):
# code correcto
logger.info("Identificador encontrado: %s" % str(item.infoLabels['code']))
# correct code
logger.info("Identifier found: %s" % str(item.infoLabels['code']))
return True
# raise
elif list_opciones_cuadro[index] in list(scrapers_disponibles.values()):
# Obtener el nombre del modulo del scraper
# Get the name of the scraper module
for k, v in list(scrapers_disponibles.items()):
if list_opciones_cuadro[index] == v:
if scrapers_disponibles[scraper_actual] not in list_opciones_cuadro:
list_opciones_cuadro.append(scrapers_disponibles[scraper_actual])
# Importamos el scraper k
# We import the scraper k
scraper_actual = k
try:
scraper = None
@@ -119,7 +117,7 @@ def find_and_set_infoLabels(item):
exec("import core." + scraper_actual + " as scraper_module")
break
logger.error("Error al importar el modulo scraper %s" % scraper_actual)
logger.error("Error importing the scraper module %s" % scraper_actual)
def cuadro_completar(item):
@@ -129,7 +127,7 @@ def cuadro_completar(item):
dict_default = {}
COLOR = ["0xFF65B3DA", "0xFFFFFFFF"]
# Creamos la lista de campos del infoLabel
# We create the list of infoLabel fields
controls = [("title", "text", config.get_localized_string(60230)),
("originaltitle", "text", config.get_localized_string(60231)),
("year", "text", config.get_localized_string(60232)),
@@ -171,7 +169,7 @@ def cuadro_completar(item):
if len(c) > 3:
enabled += c[3]
# default para casos especiales
# default for special cases
if c[0] == "url_tmdb" and item.infoLabels["tmdb_id"] and 'tmdb' in item.infoLabels["url_scraper"]:
dict_default[c[0]] = item.infoLabels["url_scraper"]
@@ -181,7 +179,7 @@ def cuadro_completar(item):
if not dict_default[c[0]] or dict_default[c[0]] == 'None' or dict_default[c[0]] == 0:
dict_default[c[0]] = ''
elif isinstance(dict_default[c[0]], (int, float)) or (not PY3 and isinstance(dict_default[c[0]], (int, float, long))):
# Si es numerico lo convertimos en str
# If it is numerical we convert it into str
dict_default[c[0]] = str(dict_default[c[0]])
listado_controles.append({'id': c[0],
@@ -207,7 +205,7 @@ def callback_cuadro_completar(item, dict_values):
global dict_default
if dict_values.get("title", None):
# Adaptar dict_values a infoLabels validos
# Adapt dict_values to valid infoLabels
dict_values['mediatype'] = ['movie', 'tvshow'][dict_values['mediatype']]
for k, v in list(dict_values.items()):
if k in dict_default and dict_default[k] == dict_values[k]:
@@ -229,16 +227,16 @@ def callback_cuadro_completar(item, dict_values):
def get_nfo(item):
"""
Devuelve la información necesaria para que se scrapee el resultado en la videoteca de kodi,
Returns the information necessary for the result to be scraped into the kodi video library,
@param item: elemento que contiene los datos necesarios para generar la info
@param item: element that contains the data necessary to generate the info
@type item: Item
@rtype: str
@return:
"""
logger.info()
if "infoLabels" in item and "noscrap_id" in item.infoLabels:
# Crea el fichero xml con los datos que se obtiene de item ya que no hay ningún scraper activo
# Create the xml file with the data obtained from the item since there is no active scraper
info_nfo = '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>'
if "season" in item.infoLabels and "episode" in item.infoLabels: