diff --git a/mediaserver/IMPORTANTE LEEME en esta version.txt b/mediaserver/IMPORTANTE LEEME en esta version.txt
new file mode 100644
index 00000000..f62ce233
--- /dev/null
+++ b/mediaserver/IMPORTANTE LEEME en esta version.txt
@@ -0,0 +1,2 @@
+Debe ejecutar primero el archivo "script.py".
+Una vez realizado el proceso podrá ejecutar como siempre "alfa.py" para iniciar el addon.
\ No newline at end of file
diff --git a/mediaserver/alfa.py b/mediaserver/alfa.py
index 9aced495..f90710ee 100644
--- a/mediaserver/alfa.py
+++ b/mediaserver/alfa.py
@@ -22,7 +22,7 @@ websocket_port = config.get_setting("websocket.port")
myip = config.get_local_ip()
-def ThreadNameWrap(func):
+def thread_name_wrap(func):
@wraps(func)
def bar(*args, **kw):
if "name" not in kw:
@@ -32,7 +32,7 @@ def ThreadNameWrap(func):
return bar
-threading.Thread.__init__ = ThreadNameWrap(threading.Thread.__init__)
+threading.Thread.__init__ = thread_name_wrap(threading.Thread.__init__)
if sys.version_info < (2, 7, 11):
import ssl
@@ -40,7 +40,7 @@ if sys.version_info < (2, 7, 11):
ssl._create_default_https_context = ssl._create_unverified_context
-def MostrarInfo():
+def show_info():
os.system('cls' if os.name == 'nt' else 'clear')
print ("--------------------------------------------------------------------")
print ("Alfa Iniciado")
@@ -54,7 +54,6 @@ def MostrarInfo():
print ("Bookmark Path : " + config.get_setting("bookmarkpath"))
print ("Videolibrary Path : " + config.get_setting("videolibrarypath"))
print ("--------------------------------------------------------------------")
- conexiones = []
controllers = platformtools.controllers
for a in controllers:
try:
@@ -68,8 +67,8 @@ def start():
logger.info("server init...")
config.verify_directories_created()
try:
- HTTPServer.start(MostrarInfo)
- WebSocket.start(MostrarInfo)
+ HTTPServer.start(show_info)
+ WebSocket.start(show_info)
# Da por levantado el servicio
logger.info("--------------------------------------------------------------------")
@@ -84,10 +83,10 @@ def start():
logger.info("Bookmark Path : " + config.get_setting("bookmarkpath"))
logger.info("VideoLibrary Path : " + config.get_setting("videolibrarypath"))
logger.info("--------------------------------------------------------------------")
- MostrarInfo()
+ show_info()
- start = True
- while start:
+ flag = True
+ while flag:
time.sleep(1)
except KeyboardInterrupt:
@@ -96,7 +95,7 @@ def start():
print 'Deteniendo el servidor WebSocket...'
WebSocket.stop()
print 'Alfa Detenido'
- start = False
+ flag = False
# Inicia el programa
diff --git a/mediaserver/platformcode/config.py b/mediaserver/platformcode/config.py
index 50602a55..7376a814 100644
--- a/mediaserver/platformcode/config.py
+++ b/mediaserver/platformcode/config.py
@@ -5,13 +5,12 @@
import os
import re
-import threading
+import sys
PLATFORM_NAME = "mediaserver"
PLUGIN_NAME = "alfa"
settings_dic = {}
-settings_types = {}
adult_setting = {}
@@ -52,14 +51,14 @@ def get_system_platform():
def open_settings():
- Opciones = []
+ options = []
from xml.dom import minidom
settings = open(menufilepath, 'rb').read()
xmldoc = minidom.parseString(settings)
for category in xmldoc.getElementsByTagName("category"):
for setting in category.getElementsByTagName("setting"):
- Opciones.append(dict(setting.attributes.items() + [(u"category", category.getAttribute("label")),
- (u"value", get_setting(setting.getAttribute("id")))]))
+ options.append(dict(setting.attributes.items() + [(u"category", category.getAttribute("label")),
+ (u"value", get_setting(setting.getAttribute("id")))]))
from platformcode import platformtools
global adult_setting
@@ -69,7 +68,7 @@ def open_settings():
adult_mode = get_setting('adult_mode')
adult_request_password = get_setting('adult_request_password')
- platformtools.open_settings(Opciones)
+ platformtools.open_settings(options)
# Hemos accedido a la seccion de Canales para adultos
if get_setting('adult_aux_intro_password'):
@@ -82,22 +81,8 @@ def open_settings():
set_setting('adult_password', get_setting('adult_aux_new_password1'))
else:
platformtools.dialog_ok("Canales para adultos",
- "Los campos 'Nueva contraseña' y 'Confirmar nueva contraseña' no coinciden.",
- "Entre de nuevo en 'Preferencias' para cambiar la contraseña")
-
- # Fijar adult_pin
- adult_pin = ""
- if get_setting("adult_request_password") == True:
- adult_pin = get_setting("adult_password")
- set_setting("adult_pin", adult_pin)
-
- # Solo esta sesion:
- id = threading.current_thread().name
- if get_setting("adult_mode") == 2:
- adult_setting[id] = True
- set_setting("adult_mode", "0")
- else:
- adult_setting = {}
+ "Los campos 'Nueva contraseña' y 'Confirmar nueva contraseña' no coinciden."
+ , "Entre de nuevo en 'Preferencias' para cambiar la contraseña")
else:
platformtools.dialog_ok("Canales para adultos", "La contraseña no es correcta.",
@@ -112,24 +97,30 @@ def open_settings():
set_setting('adult_aux_new_password2', '')
-def get_setting(name, channel="", server=""):
+def get_setting(name, channel="", server="", default=None):
"""
Retorna el valor de configuracion del parametro solicitado.
- Devuelve el valor del parametro 'name' en la configuracion global o en la configuracion propia del canal 'channel'.
+ Devuelve el valor del parametro 'name' en la configuracion global, en la configuracion propia del canal 'channel'
+ o en la del servidor 'server'.
- Si se especifica el nombre del canal busca en la ruta \addon_data\plugin.video.alfa\settings_channels el
- archivo channel_data.json y lee el valor del parametro 'name'. Si el archivo channel_data.json no existe busca en la
- carpeta channels el archivo channel.xml y crea un archivo channel_data.json antes de retornar el valor solicitado.
- Si el parametro 'name' no existe en channel_data.json lo busca en la configuracion global y si ahi tampoco existe
- devuelve un str vacio.
+ Los parametros channel y server no deben usarse simultaneamente. Si se especifica el nombre del canal se devolvera
+ el resultado de llamar a channeltools.get_channel_setting(name, channel, default). Si se especifica el nombre del
+ servidor se devolvera el resultado de llamar a servertools.get_channel_setting(name, server, default). Si no se
+ especifica ninguno de los anteriores se devolvera el valor del parametro en la configuracion global si existe o
+ el valor default en caso contrario.
- Parametros:
- name -- nombre del parametro
- channel [opcional] -- nombre del canal
+ @param name: nombre del parametro
+ @type name: str
+ @param channel: nombre del canal
+ @type channel: str
+ @param server: nombre del servidor
+ @type server: str
+ @param default: valor devuelto en caso de que no exista el parametro name
+ @type default: any
- Retorna:
- value -- El valor del parametro 'name'
+ @return: El valor del parametro 'name'
+ @rtype: any
"""
@@ -138,7 +129,7 @@ def get_setting(name, channel="", server=""):
# logger.info("config.get_setting reading channel setting '"+name+"' from channel json")
from core import channeltools
- value = channeltools.get_channel_setting(name, channel)
+ value = channeltools.get_channel_setting(name, channel, default)
# logger.info("config.get_setting -> '"+repr(value)+"'")
return value
@@ -146,7 +137,7 @@ def get_setting(name, channel="", server=""):
elif server:
# logger.info("config.get_setting reading server setting '"+name+"' from server json")
from core import servertools
- value = servertools.get_server_setting(name, server)
+ value = servertools.get_server_setting(name, server, default)
# logger.info("config.get_setting -> '"+repr(value)+"'")
return value
@@ -155,31 +146,28 @@ def get_setting(name, channel="", server=""):
else:
# logger.info("config.get_setting reading main setting '"+name+"'")
global settings_dic
- value = settings_dic.get(name, "")
-
- if name == "adult_mode":
- global adult_setting
- id = threading.current_thread().name
- if adult_setting.get(id) == True:
- value = "2"
+ value = settings_dic.get(name, default)
+ if value == default:
+ return value
+ # logger.info("config.get_setting -> '"+value+"'")
# hack para devolver el tipo correspondiente
- global settings_types
+ if value == "true":
+ return True
+ elif value == "false":
+ return False
+ else:
+ # special case return as str
+ if name in ["adult_password", "adult_aux_intro_password", "adult_aux_new_password1",
+ "adult_aux_new_password2"]:
+ return value
+ else:
+ try:
+ value = int(value)
+ except ValueError:
+ pass
- if settings_types.get(name) in ['enum', 'number']:
- value = int(value)
-
- elif settings_types.get(name) == 'bool':
- value = value == 'true'
-
- elif not settings_types.has_key(name):
- try:
- t = eval(value)
- value = t[0](t[1])
- except:
- value = None
-
- return value
+ return value
def set_setting(name, value, channel="", server=""):
@@ -214,25 +202,16 @@ def set_setting(name, value, channel="", server=""):
return servertools.set_server_setting(name, value, server)
else:
global settings_dic
- global settings_types
- if settings_types.get(name) == 'bool':
+ if isinstance(value, bool):
if value:
- new_value = "true"
+ value = "true"
else:
- new_value = "false"
-
- elif settings_types.get(name):
- new_value = str(value)
-
- else:
- if isinstance(value, basestring):
- new_value = "(%s, %s)" % (type(value).__name__, repr(value))
- else:
- new_value = "(%s, %s)" % (type(value).__name__, value)
-
- settings_dic[name] = new_value
+ value = "false"
+ elif isinstance(value, (int, long)):
+ value = str(value)
+ settings_dic[name] = value
from xml.dom import minidom
# Crea un Nuevo XML vacio
new_settings = minidom.getDOMImplementation().createDocument(None, "settings", None)
@@ -339,11 +318,9 @@ def get_local_ip():
def load_settings():
global settings_dic
- global settings_types
defaults = {}
from xml.etree import ElementTree
- encontrado = False
# Lee el archivo XML (si existe)
if os.path.exists(configfilepath):
settings = open(configfilepath, 'rb').read()
@@ -357,10 +334,9 @@ def load_settings():
for target in category.findall("setting"):
if target.get("id"):
defaults[target.get("id")] = target.get("default")
- settings_types[target.get("id")] = target.get("type")
for key in defaults:
- if not key in settings_dic:
+ if key not in settings_dic:
settings_dic[key] = defaults[key]
set_settings(settings_dic)
@@ -387,7 +363,14 @@ def set_settings(JsonRespuesta):
# Fichero de configuración
menufilepath = os.path.join(get_runtime_path(), "resources", "settings.xml")
configfilepath = os.path.join(get_data_path(), "settings.xml")
-if not os.path.exists(get_data_path()): os.mkdir(get_data_path())
+if not os.path.exists(get_data_path()):
+ os.mkdir(get_data_path())
# Literales
TRANSLATION_FILE_PATH = os.path.join(get_runtime_path(), "resources", "language", "Spanish", "strings.xml")
load_settings()
+
+# modo adulto:
+# sistema actual 0: Nunca, 1:Siempre, 2:Solo hasta que se reinicie sesión
+# si es == 2 lo desactivamos.
+if get_setting("adult_mode") == 2:
+ set_setting("adult_mode", 0)
diff --git a/mediaserver/platformcode/launcher.py b/mediaserver/platformcode/launcher.py
index b8dfe6b3..81549e38 100644
--- a/mediaserver/platformcode/launcher.py
+++ b/mediaserver/platformcode/launcher.py
@@ -29,19 +29,20 @@ def start():
def run(item):
itemlist = []
# Muestra el item en el log:
- PrintItems(item)
+ print_items(item)
# Control Parental, comprueba si es adulto o no
if item.action == "mainlist":
# Parental control
- if channeltools.is_adult(item.channel) and config.get_setting("adult_pin") != "":
+ if channeltools.is_adult(item.channel) and config.get_setting("adult_request_password"):
tecleado = platformtools.dialog_input("", "Contraseña para canales de adultos", True)
- if tecleado is None or tecleado != config.get_setting("adult_pin"):
+ if tecleado is None or tecleado != config.get_setting("adult_password"):
platformtools.render_items(None, item)
return
# Importa el canal para el item, todo item debe tener un canal, sino sale de la función
- if item.channel: channelmodule = ImportarCanal(item)
+ if item.channel:
+ channelmodule = import_channel(item)
# If item has no action, stops here
if item.action == "":
@@ -153,13 +154,13 @@ def run(item):
itemlist = [Item(title="No hay elementos para mostrar", thumbnail=get_thumb("error.png"))]
# Imprime en el log el resultado
- PrintItems(itemlist)
+ print_items(itemlist)
# Muestra los resultados en pantalla
platformtools.render_items(itemlist, item)
-def ImportarCanal(item):
+def import_channel(item):
channel = item.channel
channelmodule = ""
if os.path.exists(os.path.join(config.get_runtime_path(), "channels", channel + ".py")):
@@ -171,7 +172,7 @@ def ImportarCanal(item):
return channelmodule
-def PrintItems(itemlist):
+def print_items(itemlist):
if type(itemlist) == list:
if len(itemlist) > 0:
logger.info("Items devueltos")
@@ -197,13 +198,13 @@ def add_pelicula_to_library(item):
def add_serie_to_library(item):
- channel = ImportarCanal(item)
+ channel = import_channel(item)
videolibrarytools.add_tvshow(item, channel)
def download_all_episodes(item, first_episode="", preferred_server="vidspot", filter_language=""):
logger.info("show=" + item.show)
- channel = ImportarCanal(item)
+ channel = import_channel(item)
show_title = item.show
# Obtiene el listado desde el que se llamó
diff --git a/mediaserver/resources/settings.xml b/mediaserver/resources/settings.xml
index 368aa850..5607fedd 100644
--- a/mediaserver/resources/settings.xml
+++ b/mediaserver/resources/settings.xml
@@ -16,15 +16,14 @@
-
+
-
+
-
@@ -32,20 +31,14 @@
-
+
-
-
-
+
+
+
-
\ No newline at end of file
+
diff --git a/mediaserver/script.py b/mediaserver/script.py
new file mode 100644
index 00000000..5936fd82
--- /dev/null
+++ b/mediaserver/script.py
@@ -0,0 +1,110 @@
+# -*- coding: utf-8 -*-
+import os
+import re
+import shutil
+
+from platformcode import config, logger, platformtools
+
+
+def conversion():
+ logger.info()
+ data = ""
+
+ try:
+ # do a backup
+ path_settings = os.path.join(config.get_data_path(), "settings.xml")
+ path_settings_backup = os.path.join(config.get_data_path(), "settings.backup.xml")
+ shutil.copy(path_settings, path_settings_backup)
+
+ # open file
+ f = open(path_settings, "r")
+ # copy = open(path_settings2, "w")
+
+ logger.info(" ---")
+ logger.info(" --- 1")
+ logger.info(" --- 2")
+ logger.info(" --- 3")
+ data_aux = ""
+
+ begin_tag = "\n"
+ end_tag = "\n"
+
+ adult_data = ' \n'
+ adult_data += ' \n'
+ adult_data += ' \n'
+ adult_data += ' \n'
+ adult_data += ' \n'
+ adult_data += ' \n'
+
+ for line in f:
+ matches = re.findall(' tag
+ # data += line
+ else:
+ logger.info("Matches")
+ for _id, value in matches:
+ logger.info(" dentro del for")
+ logger.info(" _id:%s value:%s" % (_id, value))
+
+ if _id not in ["adult_aux_intro_password", "adult_aux_new_password1", "adult_aux_new_password2",
+ "adult_mode", "adult_password", "adult_request_password", "adult_pin"]:
+ logger.info(" linea %s" % line)
+ logger.info(" value %s" % value)
+ if value:
+ # logger.info(" type value!! %s" % type(value))
+ logger.info(" antes value!! %s" % value)
+ if "(str, " in value:
+ if "(str, '" in value:
+ value = value.replace("(str, '", "")
+ value = value.replace("')", "")
+ elif "(str, '":
+ value = value.replace("(str, '", "")
+ value = value.replace("')", "")
+ elif "(bool, " in value:
+ value = value.replace("(bool, ", "")
+ if value == "True)":
+ value = "true"
+ else:
+ value = "false"
+ value = value.replace('\\\\', '\\')
+ logger.info(" despues value!! %s" % value)
+
+ aux_line = '\n' % (_id, value)
+ logger.info(" aux_line %s" % aux_line)
+ data_aux += " " + aux_line
+ f.close()
+
+ data = begin_tag + adult_data + data_aux + end_tag
+
+ copy_file = open(path_settings, "w")
+ copy_file.write(data)
+ copy_file.close()
+
+ while True:
+ import sys
+ logger.info("sys ve %s" % sys.version_info)
+ if sys.version_info > (3, 0):
+ value = input("Alfa\nCorregido un error en la seccion adultos, se ha reseteado la contrasena a por "
+ "defecto, tendra que cambiarla de nuevo si lo desea.\n Escriba 's', si lo ha entendido: ")
+ else:
+ value = raw_input("Alfa\nCorregido un error en la seccion adultos, se ha reseteado la contrasena a por "
+ "defecto, tendra que cambiarla de nuevo si lo desea.\n Escriba 's', si lo ha entendido: ")
+ logger.debug("value %s" % value)
+ if value.lower() == 's':
+ break
+ logger.info("En disclaimer clickó 'No'")
+
+ logger.info("En disclaimer clickó 'Si'")
+
+ except Exception, ex:
+ template = "An exception of type %s occured. Arguments:\n%r"
+ message = template % (type(ex).__name__, ex.args)
+ logger.info(message)
+ print("Alfa", "Error, en conversión")
+ logger.info("Datos a guardar %s" % data)
+
+if __name__ == "__main__":
+ conversion()
diff --git a/plugin.video.alfa/channels/inkapelis.py b/plugin.video.alfa/channels/inkapelis.py
index ca8863cf..29d7bf2f 100755
--- a/plugin.video.alfa/channels/inkapelis.py
+++ b/plugin.video.alfa/channels/inkapelis.py
@@ -101,7 +101,7 @@ def generos(item):
matches = scrapertools.find_multiple_matches(data, '(.*?)')
for scrapedurl, scrapedtitle in matches:
- if scrapedtitle == "Eroticas +18 " and config.get_setting("adult_mode") != "0":
+ if scrapedtitle == "Eroticas +18 " and config.get_setting("adult_mode") != 0:
itemlist.append(item.clone(action="eroticas", title=scrapedtitle, url=scrapedurl))
elif (scrapedtitle != "Estrenos ") and (scrapedtitle != "Próximos Estrenos "):
itemlist.append(item.clone(action="entradas", title=scrapedtitle, url=scrapedurl))
diff --git a/plugin.video.alfa/channels/search.py b/plugin.video.alfa/channels/search.py
index d9a05f5b..4ae621fc 100644
--- a/plugin.video.alfa/channels/search.py
+++ b/plugin.video.alfa/channels/search.py
@@ -222,7 +222,7 @@ def show_result(item):
if item.adult and config.get_setting("adult_request_password"):
# Solicitar contraseña
tecleado = platformtools.dialog_input("", "Contraseña para canales de adultos", True)
- if tecleado is None or tecleado != config.get_setting("adult_pin"):
+ if tecleado is None or tecleado != config.get_setting("adult_password"):
return []
item.channel = item.__dict__.pop('from_channel')
diff --git a/plugin.video.alfa/core/channeltools.py b/plugin.video.alfa/core/channeltools.py
index f6984f13..98235c24 100755
--- a/plugin.video.alfa/core/channeltools.py
+++ b/plugin.video.alfa/core/channeltools.py
@@ -138,17 +138,18 @@ def get_channel_parameters(channel_name):
def get_channel_json(channel_name):
# logger.info("channel_name=" + channel_name)
import filetools
+ channel_json = None
try:
channel_path = filetools.join(config.get_runtime_path(), "channels", channel_name + ".json")
- # logger.info("channel_data=" + channel_path)
- channel_json = jsontools.load(filetools.read(channel_path))
- # logger.info("channel_json= %s" % channel_json)
+ if filetools.isfile(channel_path):
+ # logger.info("channel_data=" + channel_path)
+ channel_json = jsontools.load(filetools.read(channel_path))
+ # logger.info("channel_json= %s" % channel_json)
except Exception, ex:
template = "An exception of type %s occured. Arguments:\n%r"
message = template % (type(ex).__name__, ex.args)
logger.error(" %s" % message)
- channel_json = None
return channel_json
@@ -187,10 +188,10 @@ def get_channel_setting(name, channel, default=None):
@param channel: nombre del canal
@type channel: str
@param default: valor devuelto en caso de que no exista el parametro name
- @type default: cualquiera
+ @type default: any
@return: El valor del parametro 'name'
- @rtype: El tipo del valor del parametro
+ @rtype: any
"""
file_settings = os.path.join(config.get_data_path(), "settings_channels", channel + "_data.json")
diff --git a/plugin.video.alfa/core/filetools.py b/plugin.video.alfa/core/filetools.py
index 4bfc111f..5d379ef2 100755
--- a/plugin.video.alfa/core/filetools.py
+++ b/plugin.video.alfa/core/filetools.py
@@ -446,7 +446,9 @@ def mkdir(path):
except:
logger.error("ERROR al crear el directorio: %s" % path)
logger.error(traceback.format_exc())
- platformtools.dialog_notification("Error al crear el directorio", path)
+ # platformtools.dialog_notification("Error al crear el directorio", path)
+ platformtools.dialog_ok("Alfa", "IMPORTANTE - Instale y Ejecute el script 'Alfa - fix settings', que se encuentra en el repositorio de Alfa y "
+ "vuelva a entrar en el addon, [B]si no lo hace tendrá problemas[/B]")
return False
else:
return True
diff --git a/plugin.video.alfa/core/servertools.py b/plugin.video.alfa/core/servertools.py
index ffd1698c..631101c8 100644
--- a/plugin.video.alfa/core/servertools.py
+++ b/plugin.video.alfa/core/servertools.py
@@ -565,10 +565,10 @@ def get_server_setting(name, server, default=None):
@param server: nombre del servidor
@type server: str
@param default: valor devuelto en caso de que no exista el parametro name
- @type default: cualquiera
+ @type default: any
@return: El valor del parametro 'name'
- @rtype: El tipo del valor del parametro
+ @rtype: any
"""
# Creamos la carpeta si no existe
diff --git a/plugin.video.alfa/core/versiontools.py b/plugin.video.alfa/core/versiontools.py
index 0469570c..b1390200 100755
--- a/plugin.video.alfa/core/versiontools.py
+++ b/plugin.video.alfa/core/versiontools.py
@@ -14,11 +14,11 @@ def get_current_plugin_version():
def get_current_plugin_version_tag():
- return "4.3.0-beta1"
+ return "1.5.7"
def get_current_plugin_date():
- return "30/06/2017"
+ return "22/08/2017"
def get_current_channels_version():
diff --git a/plugin.video.alfa/platformcode/config.py b/plugin.video.alfa/platformcode/config.py
index 47b19146..2ca5f15f 100644
--- a/plugin.video.alfa/platformcode/config.py
+++ b/plugin.video.alfa/platformcode/config.py
@@ -8,7 +8,6 @@ import re
import xbmc
import xbmcaddon
-import xbmcgui
PLUGIN_NAME = "alfa"
@@ -112,17 +111,11 @@ def open_settings():
# Cambio de contraseña
if settings_post['adult_aux_new_password1']:
if settings_post['adult_aux_new_password1'] == settings_post['adult_aux_new_password2']:
- adult_password = set_setting('adult_password', settings_post['adult_aux_new_password1'])
+ set_setting('adult_password', settings_post['adult_aux_new_password1'])
else:
platformtools.dialog_ok("Canales para adultos",
- "Los campos 'Nueva contraseña' y 'Confirmar nueva contraseña' no coinciden.",
- "Entre de nuevo en 'Preferencias' para cambiar la contraseña")
-
- # Fijar adult_pin
- adult_pin = ""
- if settings_post["adult_request_password"] == True:
- adult_pin = adult_password
- set_setting("adult_pin", adult_pin)
+ "Los campos 'Nueva contraseña' y 'Confirmar nueva contraseña' no coinciden."
+ , "Entre de nuevo en 'Preferencias' para cambiar la contraseña")
else:
platformtools.dialog_ok("Canales para adultos", "La contraseña no es correcta.",
@@ -140,8 +133,8 @@ def open_settings():
# si se ha cambiado la ruta de la videoteca llamamos a comprobar directorios para que lo cree y pregunte
# automaticamente si configurar la videoteca
if settings_pre.get("videolibrarypath", None) != settings_post.get("videolibrarypath", None) or \
- settings_pre.get("folder_movies", None) != settings_post.get("folder_movies", None) or \
- settings_pre.get("folder_tvshows", None) != settings_post.get("folder_tvshows", None):
+ settings_pre.get("folder_movies", None) != settings_post.get("folder_movies", None) or \
+ settings_pre.get("folder_tvshows", None) != settings_post.get("folder_tvshows", None):
verify_directories_created()
else:
@@ -156,13 +149,13 @@ def get_setting(name, channel="", server="", default=None):
"""
Retorna el valor de configuracion del parametro solicitado.
- Devuelve el valor del parametro 'name' en la configuracion global, en la configuracion propia del canal 'channel'
+ Devuelve el valor del parametro 'name' en la configuracion global, en la configuracion propia del canal 'channel'
o en la del servidor 'server'.
- Los parametros channel y server no deben usarse simultaneamente. Si se especifica el nombre del canal se devolvera
- el resultado de llamar a channeltools.get_channel_setting(name, channel, default). Si se especifica el nombre del
+ Los parametros channel y server no deben usarse simultaneamente. Si se especifica el nombre del canal se devolvera
+ el resultado de llamar a channeltools.get_channel_setting(name, channel, default). Si se especifica el nombre del
servidor se devolvera el resultado de llamar a servertools.get_channel_setting(name, server, default). Si no se
- especifica ninguno de los anteriores se devolvera el valor del parametro en la configuracion global si existe o
+ especifica ninguno de los anteriores se devolvera el valor del parametro en la configuracion global si existe o
el valor default en caso contrario.
@param name: nombre del parametro
@@ -172,10 +165,10 @@ def get_setting(name, channel="", server="", default=None):
@param server: nombre del servidor
@type server: str
@param default: valor devuelto en caso de que no exista el parametro name
- @type default: cualquiera
+ @type default: any
@return: El valor del parametro 'name'
- @rtype: El tipo del valor del parametro
+ @rtype: any
"""
@@ -206,35 +199,21 @@ def get_setting(name, channel="", server="", default=None):
value = xbmc.translatePath(value)
# hack para devolver el tipo correspondiente
- settings_types = get_settings_types()
-
- if settings_types.get(name) in ['enum', 'number']:
- try:
- value = int(value)
- except Exception, ex:
- from platformcode import logger
- logger.error("Error al convertir '%s' de tipo 'enum','number' \n%s" % (name, ex))
-
- elif settings_types.get(name) == 'bool':
- value = value == 'true'
-
- elif name not in settings_types:
- try:
- if value in ['true', 'false']:
- if value == 'true':
- aux_val = True
- else:
- aux_val = False
- value = bool(aux_val)
- else:
- t = eval(value)
- value = t[0](t[1])
- except Exception, ex:
- from platformcode import logger
- logger.error("Error al convertir '%s' se pasa como tipo 'None'\n%s" % (name, ex))
- value = None
-
- return value
+ if value == "true":
+ return True
+ elif value == "false":
+ return False
+ else:
+ # special case return as str
+ if name in ["adult_password", "adult_aux_intro_password", "adult_aux_new_password1",
+ "adult_aux_new_password2"]:
+ return value
+ else:
+ try:
+ value = int(value)
+ except ValueError:
+ pass
+ return value
def set_setting(name, value, channel="", server=""):
@@ -269,25 +248,16 @@ def set_setting(name, value, channel="", server=""):
return servertools.set_server_setting(name, value, server)
else:
try:
- settings_types = get_settings_types()
-
- if settings_types.get(name) == 'bool':
+ if isinstance(value, bool):
if value:
- new_value = "true"
+ value = "true"
else:
- new_value = "false"
+ value = "false"
- elif settings_types.get(name):
- new_value = str(value)
+ elif isinstance(value, (int, long)):
+ value = str(value)
- else:
- if isinstance(value, basestring):
- new_value = "(%s, %s)" % (type(value).__name__, repr(value))
-
- else:
- new_value = "(%s, %s)" % (type(value).__name__, value)
-
- __settings__.setSetting(name, new_value)
+ __settings__.setSetting(name, value)
except Exception, ex:
from platformcode import logger
@@ -297,28 +267,6 @@ def set_setting(name, value, channel="", server=""):
return value
-def get_settings_types():
- """
- Devuelve un diccionario con los parametros (key) de la configuracion global y sus tipos (value)
-
- :return: dict
- """
- win10000 = xbmcgui.Window(10000)
- settings_types = win10000.getProperty(PLUGIN_NAME + "_settings_types")
-
- if not settings_types:
- infile = open(os.path.join(get_runtime_path(), "resources", "settings.xml"))
- data = infile.read()
- infile.close()
-
- matches = re.findall('
-
@@ -30,13 +29,6 @@
-
-
@@ -54,14 +46,6 @@
-
diff --git a/plugin.video.alfa/videolibrary_service.py b/plugin.video.alfa/videolibrary_service.py
index a6f57dee..1252fd80 100644
--- a/plugin.video.alfa/videolibrary_service.py
+++ b/plugin.video.alfa/videolibrary_service.py
@@ -235,12 +235,10 @@ if __name__ == "__main__":
import xbmc
# modo adulto:
- # Conversion de False y True al sitema actual 0: Nunca, 1:Siempre, 2:Solo hasta que se reinicie Kodi
- # y si es == 2 lo desactivamos.
- if config.get_setting("adult_mode") == False or config.get_setting("adult_mode") == 2:
+ # sistema actual 0: Nunca, 1:Siempre, 2:Solo hasta que se reinicie Kodi
+ # si es == 2 lo desactivamos.
+ if config.get_setting("adult_mode") == 2:
config.set_setting("adult_mode", 0)
- elif config.get_setting("adult_mode") == True:
- config.set_setting("adult_mode", 1)
update_wait = [0, 10000, 20000, 30000, 60000]
wait = update_wait[int(config.get_setting("update_wait", "videolibrary"))]