fix adult with types and setting.xml
This commit is contained in:
@@ -101,7 +101,7 @@ def generos(item):
|
|||||||
matches = scrapertools.find_multiple_matches(data, '<li class="cat-item cat-item-.*?><a href="([^"]+)".*?>(.*?)<b>')
|
matches = scrapertools.find_multiple_matches(data, '<li class="cat-item cat-item-.*?><a href="([^"]+)".*?>(.*?)<b>')
|
||||||
|
|
||||||
for scrapedurl, scrapedtitle in matches:
|
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))
|
itemlist.append(item.clone(action="eroticas", title=scrapedtitle, url=scrapedurl))
|
||||||
elif (scrapedtitle != "Estrenos ") and (scrapedtitle != "Próximos Estrenos "):
|
elif (scrapedtitle != "Estrenos ") and (scrapedtitle != "Próximos Estrenos "):
|
||||||
itemlist.append(item.clone(action="entradas", title=scrapedtitle, url=scrapedurl))
|
itemlist.append(item.clone(action="entradas", title=scrapedtitle, url=scrapedurl))
|
||||||
|
|||||||
@@ -222,7 +222,7 @@ def show_result(item):
|
|||||||
if item.adult and config.get_setting("adult_request_password"):
|
if item.adult and config.get_setting("adult_request_password"):
|
||||||
# Solicitar contraseña
|
# Solicitar contraseña
|
||||||
tecleado = platformtools.dialog_input("", "Contraseña para canales de adultos", True)
|
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 []
|
return []
|
||||||
|
|
||||||
item.channel = item.__dict__.pop('from_channel')
|
item.channel = item.__dict__.pop('from_channel')
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import re
|
|||||||
|
|
||||||
import xbmc
|
import xbmc
|
||||||
import xbmcaddon
|
import xbmcaddon
|
||||||
import xbmcgui
|
|
||||||
|
|
||||||
PLUGIN_NAME = "alfa"
|
PLUGIN_NAME = "alfa"
|
||||||
|
|
||||||
@@ -112,18 +111,12 @@ def open_settings():
|
|||||||
# Cambio de contraseña
|
# Cambio de contraseña
|
||||||
if settings_post['adult_aux_new_password1']:
|
if settings_post['adult_aux_new_password1']:
|
||||||
if settings_post['adult_aux_new_password1'] == settings_post['adult_aux_new_password2']:
|
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:
|
else:
|
||||||
platformtools.dialog_ok("Canales para adultos",
|
platformtools.dialog_ok("Canales para adultos",
|
||||||
"Los campos 'Nueva contraseña' y 'Confirmar nueva contraseña' no coinciden.",
|
"Los campos 'Nueva contraseña' y 'Confirmar nueva contraseña' no coinciden.",
|
||||||
"Entre de nuevo en 'Preferencias' para cambiar la contraseña")
|
"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)
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
platformtools.dialog_ok("Canales para adultos", "La contraseña no es correcta.",
|
platformtools.dialog_ok("Canales para adultos", "La contraseña no es correcta.",
|
||||||
"Los cambios realizados en esta sección no se guardaran.")
|
"Los cambios realizados en esta sección no se guardaran.")
|
||||||
@@ -206,35 +199,20 @@ def get_setting(name, channel="", server="", default=None):
|
|||||||
value = xbmc.translatePath(value)
|
value = xbmc.translatePath(value)
|
||||||
|
|
||||||
# hack para devolver el tipo correspondiente
|
# hack para devolver el tipo correspondiente
|
||||||
settings_types = get_settings_types()
|
if value == "true":
|
||||||
|
return True
|
||||||
if settings_types.get(name) in ['enum', 'number']:
|
elif value == "false":
|
||||||
try:
|
return False
|
||||||
value = int(value)
|
else:
|
||||||
except Exception, ex:
|
# special case return as str
|
||||||
from platformcode import logger
|
if name in ["adult_password", "adult_aux_intro_password", "adult_aux_new_password1", "adult_aux_new_password2"]:
|
||||||
logger.error("Error al convertir '%s' de tipo 'enum','number' \n%s" % (name, ex))
|
return value
|
||||||
|
else:
|
||||||
elif settings_types.get(name) == 'bool':
|
try:
|
||||||
value = value == 'true'
|
value = int(value)
|
||||||
|
except ValueError:
|
||||||
elif name not in settings_types:
|
pass
|
||||||
try:
|
return value
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
def set_setting(name, value, channel="", server=""):
|
def set_setting(name, value, channel="", server=""):
|
||||||
@@ -269,25 +247,16 @@ def set_setting(name, value, channel="", server=""):
|
|||||||
return servertools.set_server_setting(name, value, server)
|
return servertools.set_server_setting(name, value, server)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
settings_types = get_settings_types()
|
if isinstance(value, bool):
|
||||||
|
|
||||||
if settings_types.get(name) == 'bool':
|
|
||||||
if value:
|
if value:
|
||||||
new_value = "true"
|
value = "true"
|
||||||
else:
|
else:
|
||||||
new_value = "false"
|
value = "false"
|
||||||
|
|
||||||
elif settings_types.get(name):
|
elif isinstance(value, (int, long)):
|
||||||
new_value = str(value)
|
value = str(value)
|
||||||
|
|
||||||
else:
|
__settings__.setSetting(name, value)
|
||||||
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)
|
|
||||||
|
|
||||||
except Exception, ex:
|
except Exception, ex:
|
||||||
from platformcode import logger
|
from platformcode import logger
|
||||||
@@ -297,28 +266,6 @@ def set_setting(name, value, channel="", server=""):
|
|||||||
return value
|
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('<setting id="([^"]*)" type="([^"]*)', data)
|
|
||||||
settings_types = "{%s}" % ",".join("'%s': '%s'" % tup for tup in matches)
|
|
||||||
|
|
||||||
win10000.setProperty(PLUGIN_NAME + "_settings_types", settings_types)
|
|
||||||
|
|
||||||
return eval(settings_types)
|
|
||||||
|
|
||||||
|
|
||||||
def get_localized_string(code):
|
def get_localized_string(code):
|
||||||
dev = __language__(code)
|
dev = __language__(code)
|
||||||
|
|
||||||
|
|||||||
@@ -129,9 +129,9 @@ def run(item=None):
|
|||||||
|
|
||||||
# Parental control
|
# Parental control
|
||||||
# If it is an adult channel, and user has configured pin, asks for it
|
# If it is an adult channel, and user has configured pin, asks for it
|
||||||
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)
|
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
|
return
|
||||||
|
|
||||||
# # Actualiza el canal individual
|
# # Actualiza el canal individual
|
||||||
|
|||||||
@@ -235,12 +235,10 @@ if __name__ == "__main__":
|
|||||||
import xbmc
|
import xbmc
|
||||||
|
|
||||||
# modo adulto:
|
# modo adulto:
|
||||||
# Conversion de False y True al sitema actual 0: Nunca, 1:Siempre, 2:Solo hasta que se reinicie Kodi
|
# sistema actual 0: Nunca, 1:Siempre, 2:Solo hasta que se reinicie Kodi
|
||||||
# y si es == 2 lo desactivamos.
|
# si es == 2 lo desactivamos.
|
||||||
if config.get_setting("adult_mode") == False or config.get_setting("adult_mode") == 2:
|
if config.get_setting("adult_mode") == 2:
|
||||||
config.set_setting("adult_mode", 0)
|
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]
|
update_wait = [0, 10000, 20000, 30000, 60000]
|
||||||
wait = update_wait[int(config.get_setting("update_wait", "videolibrary"))]
|
wait = update_wait[int(config.get_setting("update_wait", "videolibrary"))]
|
||||||
|
|||||||
Reference in New Issue
Block a user