Merge remote-tracking branch 'origin/master'

This commit is contained in:
marco
2020-02-06 19:00:26 +01:00
7 changed files with 78 additions and 80 deletions

View File

@@ -36,9 +36,7 @@ def get_channel_parameters(channel_name):
# logger.debug(channel_parameters)
if channel_parameters:
# cambios de nombres y valores por defecto
channel_parameters["title"] = channel_parameters.pop("name") + (
' [DEPRECATED]' if channel_parameters.has_key('deprecated') and channel_parameters[
'deprecated'] else '')
channel_parameters["title"] = channel_parameters.pop("name") + (' [DEPRECATED]' if 'deprecated' in channel_parameters and channel_parameters['deprecated'] else '')
channel_parameters["channel"] = channel_parameters.pop("id")
# si no existe el key se declaran valor por defecto para que no de fallos en las funciones que lo llaman
@@ -194,8 +192,8 @@ def get_default_settings(channel_name):
channel_language = channel_json['language']
channel_controls = channel_json['settings']
categories = channel_json['categories']
not_active = channel_json['not_active'] if channel_json.has_key('not_active') else []
default_off = channel_json['default_off'] if channel_json.has_key('default_off') else []
not_active = channel_json['not_active'] if 'not_active' in channel_json else []
default_off = channel_json['default_off'] if 'default_off' in channel_json else []
# Apply default configurations if they do not exist
for control in default_controls:

View File

@@ -133,13 +133,13 @@ def read(path, linea_inicio=0, total_lineas=None, whence=0, silent=False, vfs=Tr
try:
linea_inicio = int(linea_inicio)
except:
logger.error('Read: ERROR de linea_inicio: %s' % str(linea_inicio))
logger.error('Read: Start_line ERROR: %s' % str(linea_inicio))
linea_inicio = 0
if total_lineas != None and not isinstance(total_lineas, int):
try:
total_lineas = int(total_lineas)
except:
logger.error('Read: ERROR de total_lineas: %s' % str(total_lineas))
logger.error('Read: ERROR of total_lineas: %s' % str(total_lineas))
total_lineas = None
if xbmc_vfs and vfs:
if not exists(path): return False
@@ -151,7 +151,7 @@ def read(path, linea_inicio=0, total_lineas=None, whence=0, silent=False, vfs=Tr
except:
return False
f.seek(linea_inicio, whence)
logger.debug('POSICIÓN de comienzo de lectura, tell(): %s' % f.seek(0, 1))
logger.debug('POSITION of beginning of reading,, tell(): %s' % f.seek(0, 1))
if total_lineas == None:
total_lineas = 0
data = f.read(total_lineas)
@@ -169,7 +169,7 @@ def read(path, linea_inicio=0, total_lineas=None, whence=0, silent=False, vfs=Tr
f.close()
except:
if not silent:
logger.error("ERROR al leer el archivo: %s" % path)
logger.error("ERROR reading file: %s" % path)
logger.error(traceback.format_exc())
return False
@@ -226,20 +226,20 @@ def file_open(path, mode="r", silent=False, vfs=True):
if xbmc_vfs and vfs:
if 'r' in mode and '+' in mode:
mode = mode.replace('r', 'w').replace('+', '')
logger.debug('Open MODE cambiado a: %s' % mode)
logger.debug('Open MODE changed to: %s' % mode)
if 'a' in mode:
mode = mode.replace('a', 'w').replace('+', '')
logger.debug('Open MODE cambiado a: %s' % mode)
logger.debug('Open MODE changed to: %s' % mode)
return xbmcvfs.File(path, mode)
elif path.lower().startswith("smb://"):
return samba.smb_open(path, mode)
else:
return open(path, mode)
except:
logger.error("ERROR al abrir el archivo: %s, %s" % (path, mode))
logger.error("ERROR when opening file: %s, %s" % (path, mode))
if not silent:
logger.error(traceback.format_exc())
platformtools.dialog_notification("Error al abrir", path)
platformtools.dialog_notification("Error Opening", path)
return False
@@ -258,7 +258,7 @@ def file_stat(path, silent=False, vfs=True):
return xbmcvfs.Stat(path)
raise
except:
logger.error("File_Stat no soportado: %s" % path)
logger.error("File_Stat not supported: %s" % path)
if not silent:
logger.error(traceback.format_exc())
return False
@@ -283,9 +283,9 @@ def rename(path, new_name, silent=False, strict=False, vfs=True):
dest = encode(join(dirname(path_end), new_name))
result = xbmcvfs.rename(path, dest)
if not result and not strict:
logger.error("ERROR al RENOMBRAR el archivo: %s. Copiando y borrando" % path)
logger.error("ERROR RENAME file: %s. Copying and deleting" % path)
if not silent:
dialogo = platformtools.dialog_progress("Copiando archivo", "")
dialogo = platformtools.dialog_progress("Copying file", "")
result = xbmcvfs.copy(path, dest)
if not result:
return False
@@ -298,10 +298,10 @@ def rename(path, new_name, silent=False, strict=False, vfs=True):
new_name = encode(new_name, False)
os.rename(path, os.path.join(os.path.dirname(path), new_name))
except:
logger.error("ERROR al renombrar el archivo: %s" % path)
logger.error("ERROR when renaming the file: %s" % path)
if not silent:
logger.error(traceback.format_exc())
platformtools.dialog_notification("Error al renombrar", path)
platformtools.dialog_notification("Error renaming", path)
return False
else:
return True
@@ -324,9 +324,9 @@ def move(path, dest, silent=False, strict=False, vfs=True):
dest = encode(dest)
result = xbmcvfs.rename(path, dest)
if not result and not strict:
logger.error("ERROR al MOVER el archivo: %s. Copiando y borrando" % path)
logger.error("ERROR when MOVING the file: %s. Copying and deleting" % path)
if not silent:
dialogo = platformtools.dialog_progress("Copiando archivo", "")
dialogo = platformtools.dialog_progress("Copying file", "")
result = xbmcvfs.copy(path, dest)
if not result:
return False
@@ -349,7 +349,7 @@ def move(path, dest, silent=False, strict=False, vfs=True):
dialogo = platformtools.dialog_progress("Copiando archivo", "")
return copy(path, dest) == True and remove(path) == True
except:
logger.error("ERROR al mover el archivo: %s a %s" % (path, dest))
logger.error("ERROR when moving file: %s to %s" % (path, dest))
if not silent:
logger.error(traceback.format_exc())
return False
@@ -376,7 +376,7 @@ def copy(path, dest, silent=False, vfs=True):
if not silent:
dialogo = platformtools.dialog_progress("Copiando archivo", "")
return bool(xbmcvfs.copy(path, dest))
fo = file_open(path, "rb")
fd = file_open(dest, "wb")
if fo and fd:
@@ -398,7 +398,7 @@ def copy(path, dest, silent=False, vfs=True):
if not silent:
dialogo.close()
except:
logger.error("ERROR al copiar el archivo: %s" % path)
logger.error("ERROR when copying the file: %s" % path)
if not silent:
logger.error(traceback.format_exc())
return False
@@ -420,13 +420,13 @@ def exists(path, silent=False, vfs=True):
result = bool(xbmcvfs.exists(path))
if not result and not path.endswith('/') and not path.endswith('\\'):
result = bool(xbmcvfs.exists(join(path, ' ').rstrip()))
return result
return result
elif path.lower().startswith("smb://"):
return samba.exists(path)
else:
return os.path.exists(path)
except:
logger.error("ERROR al comprobar la ruta: %s" % path)
logger.error("ERROR when checking the path: %s" % path)
if not silent:
logger.error(traceback.format_exc())
return False
@@ -458,7 +458,7 @@ def isfile(path, silent=False, vfs=True):
else:
return os.path.isfile(path)
except:
logger.error("ERROR al comprobar el archivo: %s" % path)
logger.error("ERROR when checking file: %s" % path)
if not silent:
logger.error(traceback.format_exc())
return False
@@ -490,7 +490,7 @@ def isdir(path, silent=False, vfs=True):
else:
return os.path.isdir(path)
except:
logger.error("ERROR al comprobar el directorio: %s" % path)
logger.error("ERROR when checking the directory: %s" % path)
if not silent:
logger.error(traceback.format_exc())
return False
@@ -517,7 +517,7 @@ def getsize(path, silent=False, vfs=True):
else:
return os.path.getsize(path)
except:
logger.error("ERROR al obtener el tamaño: %s" % path)
logger.error("ERROR when getting the size: %s" % path)
if not silent:
logger.error(traceback.format_exc())
return long(0)
@@ -540,10 +540,10 @@ def remove(path, silent=False, vfs=True):
else:
os.remove(path)
except:
logger.error("ERROR al eliminar el archivo: %s" % path)
logger.error("ERROR deleting file: %s" % path)
if not silent:
logger.error(traceback.format_exc())
platformtools.dialog_notification("Error al eliminar el archivo", path)
platformtools.dialog_notification("ERROR deleting file", path)
return False
else:
return True
@@ -580,10 +580,10 @@ def rmdirtree(path, silent=False, vfs=True):
import shutil
shutil.rmtree(path, ignore_errors=True)
except:
logger.error("ERROR al eliminar el directorio: %s" % path)
logger.error("ERROR deleting directory: %s" % path)
if not silent:
logger.error(traceback.format_exc())
platformtools.dialog_notification("Error al eliminar el directorio", path)
platformtools.dialog_notification("ERROR deleting directory", path)
return False
else:
return not exists(path)
@@ -608,10 +608,10 @@ def rmdir(path, silent=False, vfs=True):
else:
os.rmdir(path)
except:
logger.error("ERROR al eliminar el directorio: %s" % path)
logger.error("ERROR deleting directory: %s" % path)
if not silent:
logger.error(traceback.format_exc())
platformtools.dialog_notification("Error al eliminar el directorio", path)
platformtools.dialog_notification("ERROR deleting directory", path)
return False
else:
return True
@@ -641,10 +641,10 @@ def mkdir(path, silent=False, vfs=True):
else:
os.mkdir(path)
except:
logger.error("ERROR al crear el directorio: %s" % path)
logger.error("ERROR when creating directory: %s" % path)
if not silent:
logger.error(traceback.format_exc())
platformtools.dialog_notification("Error al crear el directorio", path)
platformtools.dialog_notification("ERROR when creating directory", path)
return False
else:
return True
@@ -724,7 +724,7 @@ def listdir(path, silent=False, vfs=True):
else:
return decode(os.listdir(path))
except:
logger.error("ERROR al leer el directorio: %s" % path)
logger.error("ERROR when reading the directory: %s" % path)
if not silent:
logger.error(traceback.format_exc())
return False
@@ -740,14 +740,13 @@ def join(*paths):
list_path = []
if paths[0].startswith("/"):
list_path.append("")
for path in paths:
if path:
if xbmc_vfs:
if xbmc_vfs and type(path) != str:
path = encode(path)
list_path += path.replace("\\", "/").strip("/").split("/")
if scrapertools.find_single_match(paths[0], '(^\w+:\/\/)'):
if scrapertools.find_single_match(paths[0], r'(^\w+:\/\/)'):
return str("/".join(list_path))
else:
return str(os.sep.join(list_path))
@@ -812,8 +811,8 @@ def remove_tags(title):
return title_without_tags
else:
return title
def remove_smb_credential(path):
"""
devuelve el path sin contraseña/usuario para paths de SMB
@@ -823,10 +822,10 @@ def remove_smb_credential(path):
@rtype: str
"""
logger.info()
if not scrapertools.find_single_match(path, '(^\w+:\/\/)'):
return path
protocol = scrapertools.find_single_match(path, '(^\w+:\/\/)')
path_without_credentials = scrapertools.find_single_match(path, '^\w+:\/\/(?:[^;\n]+;)?(?:[^:@\n]+[:|@])?(?:[^@\n]+@)?(.*?$)')

View File

@@ -10,26 +10,26 @@ from platformcode import logger
try:
import json
except:
logger.info("json incluido en el interprete **NO** disponible")
logger.info("json included in the interpreter **NOT** available")
try:
import simplejson as json
except:
logger.info("simplejson incluido en el interprete **NO** disponible")
logger.info("simplejson included in the interpreter **NOT** available")
try:
from lib import simplejson as json
except:
logger.info("simplejson en el directorio lib **NO** disponible")
logger.error("No se ha encontrado un parser de JSON valido")
logger.info("simplejson in lib directory **NOT** available")
logger.error("A valid JSON parser was not found")
json = None
else:
logger.info("Usando simplejson en el directorio lib")
logger.info("Using simplejson in the lib directory")
else:
logger.info("Usando simplejson incluido en el interprete")
logger.info("Using simplejson included in the interpreter")
# ~ else:
# ~ logger.info("Usando json incluido en el interprete")
# ~ logger.info("Usando json incluido en el interprete")
import sys
PY3 = False
if sys.version_info[0] >= 3: PY3 = True; unicode = str; unichr = chr; long = int
@@ -41,7 +41,7 @@ def load(*args, **kwargs):
try:
value = json.loads(*args, **kwargs)
except:
logger.error("**NO** se ha podido cargar el JSON")
logger.error("**NOT** able to load the JSON")
logger.error(traceback.format_exc())
value = {}
@@ -55,7 +55,7 @@ def dump(*args, **kwargs):
try:
value = json.dumps(*args, **kwargs)
except:
logger.error("**NO** se ha podido guardar el JSON")
logger.error("JSON could **NOT** be saved")
logger.error(traceback.format_exc())
value = ""
return value
@@ -112,7 +112,7 @@ def get_node_from_file(name_file, node, path=None):
if node in dict_data:
dict_node = dict_data[node]
# logger.debug("dict_node: %s" % dict_node)
#logger.debug("dict_node: %s" % dict_node)
return dict_node
@@ -132,18 +132,18 @@ def check_to_backup(data, fname, dict_data):
logger.info()
if not dict_data:
logger.error("Error al cargar el json del fichero %s" % fname)
logger.error("Error loading json from file %s" % fname)
if data != "":
# se crea un nuevo fichero
from core import filetools
title = filetools.write("%s.bk" % fname, data)
if title != "":
logger.error("Ha habido un error al guardar el fichero: %s.bk" % fname)
logger.error("There was an error saving the file: %s.bk" % fname)
else:
logger.debug("Se ha guardado una copia con el nombre: %s.bk" % fname)
logger.debug("A copy with the name has been saved: %s.bk" % fname)
else:
logger.debug("Está vacío el fichero: %s" % fname)
logger.debug("The file is empty: %s" % fname)
def update_node(dict_node, name_file, node, path=None):
@@ -183,18 +183,18 @@ def update_node(dict_node, name_file, node, path=None):
# es un dict
if dict_data:
if node in dict_data:
logger.debug(" existe el key %s" % node)
logger.debug(" the key exists %s" % node)
dict_data[node] = dict_node
else:
logger.debug(" NO existe el key %s" % node)
logger.debug(" The key does NOT exist %s" % node)
new_dict = {node: dict_node}
dict_data.update(new_dict)
else:
logger.debug(" NO es un dict")
logger.debug(" It is NOT a dict")
dict_data = {node: dict_node}
json_data = dump(dict_data)
result = filetools.write(fname, json_data)
except:
logger.error("No se ha podido actualizar %s" % fname)
logger.error("Could not update %s" % fname)
return result, json_data
return result, json_data

View File

@@ -759,7 +759,7 @@ def typo(string, typography=''):
if '{}' in string:
string = '{' + re.sub(r'\s\{\}','',string) + '}'
if 'submenu' in string:
string = u"\u2022\u2022 ".encode('utf-8') + re.sub(r'\ssubmenu','',string)
string = "•• " + re.sub(r'\ssubmenu','',string)
if 'color' in string:
color = scrapertools.find_single_match(string, 'color ([a-z]+)')
if color == 'kod' or '': color = kod_color
@@ -773,7 +773,7 @@ def typo(string, typography=''):
if '--' in string:
string = ' - ' + re.sub(r'\s--','',string)
if 'bullet' in string:
string = '[B]' + u"\u2022".encode('utf-8') + '[/B] ' + re.sub(r'\sbullet','',string)
string = '[B][/B] ' + re.sub(r'\sbullet','',string)
return string

View File

@@ -465,9 +465,8 @@ def set_infoLabels_item(item, seekTmdb=True, idioma_busqueda=def_lang, lock=None
# Busqueda de pelicula por titulo...
if item.infoLabels['year'] or item.infoLabels['filtro']:
# ...y año o filtro
if item.contentTitle:
titulo_buscado = item.contentTitle
otmdb = Tmdb(texto_buscado=titulo_buscado, tipo=tipo_busqueda, idioma_busqueda=idioma_busqueda,
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):

View File

@@ -11,7 +11,10 @@ import re
import os
import sys
import urllib
import urlparse
try:
import urlparse
except:
import urllib.parse as urlparse
import datetime
import time
import traceback

View File

@@ -44,10 +44,10 @@ def start():
# se ha problemi di DNS avvia ma lascia entrare
# se tutto ok: entra nell'addon
from specials.checkhost import test_conn
import threading
threading.Thread(target=test_conn,
args=(True, not config.get_setting('resolver_dns'), True, [], [], True)).start()
# from specials.checkhost import test_conn
# import threading
# threading.Thread(target=test_conn,
# args=(True, not config.get_setting('resolver_dns'), True, [], [], True)).start()
def run(item=None):
logger.info()
@@ -100,7 +100,7 @@ def run(item=None):
# If item has no action, stops here
if item.action == "":
logger.info("Item sin accion")
logger.info("Item without action")
return
# Action for main menu in channelselector
@@ -332,21 +332,20 @@ def run(item=None):
# Grab inner and third party errors
if hasattr(e, 'reason'):
logger.error("Razon del error, codigo: %s | Razon: %s" % (str(e.reason[0]), str(e.reason[1])))
logger.error("Reason for the error, code: %s | Reason: %s" % (str(e.reason[0]), str(e.reason[1])))
texto = config.get_localized_string(30050) # "No se puede conectar con el sitio web"
platformtools.dialog_ok(config.get_localized_string(20000), texto)
# Grab server response errors
elif hasattr(e, 'code'):
logger.error("Codigo de error HTTP : %d" % e.code)
logger.error("HTTP error code: %d" % e.code)
# "El sitio web no funciona correctamente (error http %d)"
platformtools.dialog_ok(config.get_localized_string(20000), config.get_localized_string(30051) % e.code)
except WebErrorException as e:
import traceback
logger.error(traceback.format_exc())
patron = 'File "' + os.path.join(config.get_runtime_path(), "channels", "").replace("\\",
"\\\\") + '([^.]+)\.py"'
patron = 'File "' + os.path.join(config.get_runtime_path(), "channels", "").replace("\\", "\\\\") + '([^.]+)\.py"'
canal = scrapertools.find_single_match(traceback.format_exc(), patron)
platformtools.dialog_ok(
@@ -426,7 +425,7 @@ def reorder_itemlist(itemlist):
new_list.extend(mod_list)
new_list.extend(not_mod_list)
logger.info("Titulos modificados:%i | No modificados:%i" % (modified, not_modified))
logger.info("Modified Titles:%i |Unmodified:%i" % (modified, not_modified))
if len(new_list) == 0:
new_list = itemlist