def mainlist(item): logger.info("tvalacarta.channels.configuracion mainlist") itemlist = [] itemlist.append(Item(channel=CHANNELNAME, title="Preferencias", action="settings", folder=False)) itemlist.append(Item(channel=CHANNELNAME, title="", action="", folder=False)) itemlist.append(Item(channel=CHANNELNAME, title="Ajustes especiales", action="", folder=False)) itemlist.append(Item(channel="novedades", title=" Ajustes de la sección 'Novedades'", action="menu_opciones", folder=True)) itemlist.append(Item(channel="buscador", title=" Ajustes del buscador global", action="opciones", folder=True)) if config.is_xbmc(): itemlist.append(Item(channel=item.channel, action="updatebiblio", title=" Buscar nuevos episodios y actualizar biblioteca", folder=False)) itemlist.append(Item(channel=CHANNELNAME, title=" Comprobar actualizaciones", action="check_for_updates", folder=False)) itemlist.append(Item(channel=CHANNELNAME, title=" Añadir o Actualizar canal/conector desde una URL", action="menu_addchannels")) itemlist.append(Item(channel=item.channel, action="", title="", folder=False)) itemlist.append(Item(channel=CHANNELNAME, title="Ajustes por canales", action="", folder=False)) import channelselector from core import channeltools channel_list = channelselector.filterchannels("all") for channel in channel_list: jsonchannel = channeltools.get_channel_json(channel.channel) if jsonchannel.get("settings"): setting = jsonchannel["settings"] if type(setting) == list: if len([s for s in setting if "id" in s and not "include_in_" in s["id"]]): itemlist.append(Item(channel=CHANNELNAME, title=" Configuración del canal '%s'" % channel.title, action="channel_config", config=channel.channel, folder=False)) return itemlist
def checkHost(item, itemlist): # nel caso non ci siano risultati puo essere che l'utente abbia cambiato manualmente l'host, pertanto lo riporta # al valore di default (fixa anche il problema del cambio di host da parte nostra) if len(itemlist) == 0: # trovo il valore di default defHost = None for s in channeltools.get_channel_json(item.channel)['settings']: if s['id'] == 'channel_host': defHost = s['default'] break # lo confronto con quello attuale if config.get_setting('channel_host', item.channel) != defHost: config.set_setting('channel_host', defHost, item.channel)
def mainlist(item): logger.info() itemlist = list() itemlist.append(Item(channel=CHANNELNAME, title="Preferencias", action="settings", folder=False, thumbnail=get_thumbnail_path("thumb_configuracion.png"))) itemlist.append(Item(channel=CHANNELNAME, title="", action="", folder=False, thumbnail=get_thumbnail_path("thumb_configuracion.png"))) itemlist.append(Item(channel=CHANNELNAME, title="Ajustes especiales", action="", folder=False, thumbnail=get_thumbnail_path("thumb_configuracion.png"))) itemlist.append(Item(channel="novedades", title=" Ajustes de la sección 'Novedades'", action="menu_opciones", folder=True, thumbnail=get_thumbnail_path("thumb_novedades.png"))) itemlist.append(Item(channel="buscador", title=" Ajustes del buscador global", action="opciones", folder=True, thumbnail=get_thumbnail_path("thumb_buscar.png"))) if config.get_library_support(): itemlist.append(Item(channel="biblioteca", title=" Ajustes de la biblioteca", action="channel_config", folder=True, thumbnail=get_thumbnail_path("thumb_biblioteca.png"))) itemlist.append(Item(channel="biblioteca", action="update_biblio", folder=False, thumbnail=get_thumbnail_path("thumb_biblioteca.png"), title=" Buscar nuevos episodios y actualizar biblioteca")) itemlist.append(Item(channel=CHANNELNAME, title=" Comprobar actualizaciones", action="check_for_updates", folder=False, thumbnail=get_thumbnail_path("Crystal_Clear_action_info.png"))) itemlist.append(Item(channel=CHANNELNAME, title=" Añadir o Actualizar canal/conector desde una URL", action="menu_addchannels")) itemlist.append(Item(channel=item.channel, action="", title="", folder=False, thumbnail=get_thumbnail_path("thumb_configuracion.png"))) itemlist.append(Item(channel=CHANNELNAME, title="Ajustes por canales", action="", folder=False, thumbnail=get_thumbnail_path("thumb_configuracion.png"))) import channelselector from core import channeltools channel_list = channelselector.filterchannels("all") for channel in channel_list: jsonchannel = channeltools.get_channel_json(channel.channel) if jsonchannel.get("settings"): setting = jsonchannel["settings"] if type(setting) == list: if len([s for s in setting if "id" in s and "include_in_" not in s["id"]]): itemlist.append(Item(channel=CHANNELNAME, title=" Configuración del canal '%s'" % channel.title, action="channel_config", config=channel.channel, folder=False, thumbnail=channel.thumbnail)) return itemlist
def conf_tools(item): logger.info() # Activar o desactivar canales if item.extra == "channels_onoff": import channelselector from core import channeltools channel_list = channelselector.filterchannels("allchannelstatus") excluded_channels = ['tengourl', 'buscador', 'biblioteca', 'configuracion', 'novedades', 'personal', 'ayuda', 'descargas'] list_controls = [] try: list_controls.append({'id': "all_channels", 'type': "list", 'label': "Todos los canales", 'default': 0, 'enabled': True, 'visible': True, 'lvalues': ['', 'Activar todos', 'Desactivar todos', 'Establecer estado por defecto']}) for channel in channel_list: # Si el canal esta en la lista de exclusiones lo saltamos if channel.channel not in excluded_channels: channel_parameters = channeltools.get_channel_parameters(channel.channel) status_control = "" status = config.get_setting("enabled", channel.channel) # si status no existe es que NO HAY valor en _data.json if status is None: status = channel_parameters["active"] logger.debug("%s | Status (XML): %s" % (channel.channel, status)) if not status: status_control = " [COLOR grey](Desactivado por defecto)[/COLOR]" else: logger.debug("%s | Status: %s" % (channel.channel, status)) control = {'id': channel.channel, 'type': "bool", 'label': channel_parameters["title"] + status_control, 'default': status, 'enabled': True, 'visible': True} list_controls.append(control) else: continue except: import traceback logger.error("Error: %s" % traceback.format_exc()) else: return platformtools.show_channel_settings(list_controls=list_controls, item=item.clone(channel_list=channel_list), caption="Canales", callback="channel_status", custom_button={"visible": False}) # Comprobacion de archivos channel_data.json elif item.extra == "lib_check_datajson": itemlist = [] import channelselector from core import channeltools channel_list = channelselector.filterchannels("allchannelstatus") # Tener una lista de exclusion no tiene mucho sentido por que se comprueba si # el xml tiene "settings", pero por si acaso se deja excluded_channels = ['tengourl', 'configuracion', 'personal', 'ayuda'] try: import os from core import jsontools for channel in channel_list: list_status = None default_settings = None # Se comprueba si el canal esta en la lista de exclusiones if channel.channel not in excluded_channels: # Se comprueba que tenga "settings", sino se salta jsonchannel = channeltools.get_channel_json(channel.channel) if not jsonchannel.get("settings"): itemlist.append(Item(channel=CHANNELNAME, title=channel.title + " - No tiene ajustes por defecto", action="", folder=False, thumbnail=channel.thumbnail)) continue # logger.info(channel.channel + " SALTADO!") # Se cargan los ajustes del archivo json del canal file_settings = os.path.join(config.get_data_path(), "settings_channels", channel.channel + "_data.json") dict_settings = {} dict_file = {} if filetools.exists(file_settings): # logger.info(channel.channel + " Tiene archivo _data.json") channeljson_exists = True # Obtenemos configuracion guardada de ../settings/channel_data.json try: dict_file = jsontools.load_json(open(file_settings, "rb").read()) if isinstance(dict_file, dict) and 'settings' in dict_file: dict_settings = dict_file['settings'] except EnvironmentError: logger.error("ERROR al leer el archivo: %s" % file_settings) else: # logger.info(channel.channel + " No tiene archivo _data.json") channeljson_exists = False if channeljson_exists == True: try: datajson_size = filetools.getsize(file_settings) except: import traceback logger.error(channel.title + " | Detalle del error: %s" % traceback.format_exc()) else: datajson_size = None # Si el _data.json esta vacio o no existe... if (len(dict_settings) and datajson_size) == 0 or channeljson_exists == False: # Obtenemos controles del archivo ../channels/channel.xml needsfix = True try: # Se cargan los ajustes por defecto list_controls, default_settings = channeltools.get_channel_controls_settings(channel.channel) # logger.info(channel.title + " | Default: %s" % default_settings) except: import traceback logger.error(channel.title + " | Detalle del error: %s" % traceback.format_exc()) # default_settings = {} # Si _data.json necesita ser reparado o no existe... if needsfix == True or channeljson_exists == False: if default_settings is not None: # Creamos el channel_data.json default_settings.update(dict_settings) dict_settings = default_settings dict_file['settings'] = dict_settings # Creamos el archivo ../settings/channel_data.json json_data = jsontools.dump_json(dict_file) try: open(file_settings, "wb").write(json_data) # logger.info(channel.channel + " - Archivo _data.json GUARDADO!") # El channel_data.json se ha creado/modificado list_status = " - [COLOR red] CORREGIDO!![/COLOR]" except EnvironmentError: logger.error("ERROR al salvar el archivo: %s" % file_settings) else: if default_settings is None: list_status = " - [COLOR red] Imposible cargar los ajustes por defecto![/COLOR]" else: # logger.info(channel.channel + " - NO necesita correccion!") needsfix = False # Si se ha establecido el estado del canal se añade a la lista if needsfix is not None: if needsfix == True: if channeljson_exists == False: list_status = " - Ajustes creados" list_colour = "red" else: list_status = " - No necesita corrección" list_colour = "green" else: # Si "needsfix" es "false" y "datjson_size" es None habra # ocurrido algun error if datajson_size is None: list_status = " - Ha ocurrido algun error" list_colour = "red" else: list_status = " - No necesita corrección" list_colour = "green" if list_status is not None: itemlist.append(Item(channel=CHANNELNAME, title=channel.title + list_status, action="", folder=False, thumbnail=channel.thumbnail, text_color=list_colour)) else: logger.error("Algo va mal con el canal %s" % channel.channel) # Si el canal esta en la lista de exclusiones lo saltamos else: continue except: import traceback logger.error("Error: %s" % traceback.format_exc()) return itemlist
def mainlist(item): logger.info() itemlist = list() itemlist.append(Item(channel=CHANNELNAME, title="Preferenze", action="settings", folder=False, thumbnail=get_thumbnail_path("thumb_configuracion.png"))) itemlist.append(Item(channel=CHANNELNAME, title="", action="", folder=False, thumbnail=get_thumbnail_path("thumb_configuracion.png"))) itemlist.append(Item(channel=CHANNELNAME, title="Impostazioni speciali", action="", folder=False, thumbnail=get_thumbnail_path("thumb_configuracion.png"))) itemlist.append(Item(channel="novedades", title=" Impostazioni 'Novità'", action="menu_opciones", folder=True, thumbnail=get_thumbnail_path("thumb_novedades.png"))) itemlist.append(Item(channel="buscador", title=" Impostazioni della ricerca globale", action="opciones", folder=True, thumbnail=get_thumbnail_path("thumb_buscar.png"))) if config.get_library_support(): itemlist.append(Item(channel="biblioteca", title=" Impostazioni libreria", action="channel_config", folder=True, thumbnail=get_thumbnail_path("thumb_biblioteca.png"))) itemlist.append(Item(channel="biblioteca", action="update_biblio", folder=False, thumbnail=get_thumbnail_path("thumb_biblioteca.png"), title=" Recupera nuovi episodi e aggiorna la libreria")) itemlist.append(Item(channel=CHANNELNAME, title="Avvia aggiornamenti", action="check_for_updates", folder=False)) itemlist.append(Item(channel=item.channel, action="", title="", folder=False, thumbnail=get_thumbnail_path("thumb_configuracion.png"))) itemlist.append(Item(channel=CHANNELNAME, title="Impostazioni canali", action="", folder=False, thumbnail=get_thumbnail_path("thumb_configuracion.png"))) import channelselector from core import channeltools channel_list = channelselector.filterchannels("all") for channel in channel_list: try: jsonchannel = channeltools.get_channel_json(channel.channel) except: continue if jsonchannel.get("settings"): setting = jsonchannel["settings"] if type(setting) == list: if len([s for s in setting if "id" in s and "include_in_" not in s["id"]]): active_status = None if config.get_setting("enabled", channel.channel): active_status = config.get_setting("enabled", channel.channel) else: channel_parameters = channeltools.get_channel_parameters(channel.channel) active_status = channel_parameters['active'] if active_status == "true": itemlist.append(Item(channel=CHANNELNAME, title=" Configurazione canale '%s'" % channel.title, action="channel_config", config=channel.channel, folder=False, thumbnail=channel.thumbnail)) return itemlist
def conf_tools(item): logger.info() # Activar o desactivar canales if item.extra == "channels_onoff": import channelselector from core import channeltools channel_list = channelselector.filterchannels("allchannelstatus") channel_language = config.get_setting("channel_language") if channel_language == "": channel_language = "all" excluded_channels = ['tengourl', 'buscador', 'libreria', 'configuracion', 'novedades', 'personal', 'ayuda', 'descargas'] list_controls = [] try: list_controls.append({'id': "all_channels", 'type': "list", 'label': "Todos los canales", 'default': 0, 'enabled': True, 'visible': True, 'lvalues': ['', 'Activar todos', 'Desactivar todos', 'Establecer estado por defecto']}) for channel in channel_list: # Si el canal esta en la lista de exclusiones lo saltamos if channel.channel not in excluded_channels: # Se cargan los ajustes del archivo json del canal jsonchannel = channeltools.get_channel_json(channel.channel) if jsonchannel.get("settings") or jsonchannel.get("active"): channel_parameters = channeltools.get_channel_parameters(channel.channel) # No incluir si es un canal para adultos, y el modo adulto está desactivado if (channel_parameters["adult"] == "true" and config.get_setting("adult_mode") == "0"): continue # No incluir si el canal es en un idioma filtrado if (channel_language != "all" and channel_parameters["language"] != channel_language): continue status = None xml_status = channel_parameters["active"].replace("t", "T").replace("f", "F") xml_status = eval(xml_status) if config.get_setting("enabled", channel.channel): status = config.get_setting("enabled", channel.channel) status = status.replace("t", "T").replace("f", "F") status = eval(status) # logger.info(channel.channel + " | Status: " + str(status)) else: status = xml_status # logger.info(channel.channel + " | Status (XML): " + str(status)) status_control = "" if not xml_status: status_control = " [COLOR grey](Desactivado por defecto)[/COLOR]" if status is not None: control = {'id': channel.channel, 'type': "bool", 'label': channel_parameters["title"] + status_control, 'default': status, 'enabled': True, 'visible': True} list_controls.append(control) else: logger.info("Algo va mal con el canal " + channel.channel) else: continue return platformtools.show_channel_settings(list_controls=list_controls, caption="Canales", callback="channel_status", custom_button={"visible": False}) except: import traceback logger.info(channel.title + " | Detalle del error: %s" % traceback.format_exc()) platformtools.dialog_notification("Error", "Se ha producido un error con el canal %s" % channel.title) # Comprobacion de archivos channel_data.json elif item.extra == "lib_check_datajson": itemlist = [] import channelselector from core import channeltools channel_list = channelselector.filterchannels("allchannelstatus") # Tener una lista de exclusion no tiene mucho sentido por que se comprueba si # el xml tiene "settings", pero por si acaso se deja excluded_channels = ['tengourl', 'configuracion', 'personal', 'ayuda'] try: import os from core import jsontools for channel in channel_list: needsfix = None list_status = None list_controls = None default_settings = None channeljson_exists = None # Se convierte el "channel.channel" del canal biblioteca para que no de error if channel.channel == "libreria": channel.channel = "biblioteca" # Se comprueba si el canal esta en la lista de exclusiones if channel.channel not in excluded_channels: # Se comprueba que tenga "settings", sino se salta jsonchannel = channeltools.get_channel_json(channel.channel) if not jsonchannel.get("settings"): itemlist.append(Item(channel=CHANNELNAME, title=channel.title + " - No tiene ajustes por defecto", action="", folder=False, thumbnail=channel.thumbnail)) continue # logger.info(channel.channel + " SALTADO!") # Se cargan los ajustes del archivo json del canal file_settings = os.path.join(config.get_data_path(), "settings_channels", channel.channel + "_data.json") dict_settings = {} dict_file = {} if filetools.exists(file_settings): # logger.info(channel.channel + " Tiene archivo _data.json") channeljson_exists = "true" # Obtenemos configuracion guardada de ../settings/channel_data.json try: dict_file = jsontools.load_json(open(file_settings, "rb").read()) if isinstance(dict_file, dict) and 'settings' in dict_file: dict_settings = dict_file['settings'] except EnvironmentError: logger.info("ERROR al leer el archivo: %s" % file_settings) else: # logger.info(channel.channel + " No tiene archivo _data.json") channeljson_exists = "false" if channeljson_exists == "true": try: datajson_size = filetools.getsize(file_settings) except: import traceback logger.info(channel.title + " | Detalle del error: %s" % traceback.format_exc()) else: datajson_size = None # Si el _data.json esta vacio o no existe... if (len(dict_settings) and datajson_size) == 0 or channeljson_exists == "false": # Obtenemos controles del archivo ../channels/channel.xml needsfix = "true" try: # Se cargan los ajustes por defecto list_controls, default_settings = channeltools.get_channel_controls_settings(channel.channel) # logger.info(channel.title + " | Default: %s" % default_settings) except: import traceback logger.info(channel.title + " | Detalle del error: %s" % traceback.format_exc()) # default_settings = {} # Si _data.json necesita ser reparado o no existe... if needsfix == "true" or channeljson_exists == "false": if default_settings is not None: # Creamos el channel_data.json default_settings.update(dict_settings) dict_settings = default_settings dict_file['settings'] = dict_settings # Creamos el archivo ../settings/channel_data.json json_data = jsontools.dump_json(dict_file) try: open(file_settings, "wb").write(json_data) # logger.info(channel.channel + " - Archivo _data.json GUARDADO!") # El channel_data.json se ha creado/modificado list_status = " - [COLOR red] CORREGIDO!![/COLOR]" except EnvironmentError: logger.info("ERROR al salvar el archivo: %s" % file_settings) else: if default_settings is None: list_status = " - [COLOR red] Imposible cargar los ajustes por defecto![/COLOR]" else: # logger.info(channel.channel + " - NO necesita correccion!") needsfix = "false" # Si se ha establecido el estado del canal se añade a la lista if needsfix is not None: if needsfix == "true": if channeljson_exists == "false": list_status = " - Ajustes creados" list_colour = "red" else: list_status = " - No necesita correccion" list_colour = "green" else: # Si "needsfix" es "false" y "datjson_size" es None habra # ocurrido algun error if datajson_size is None: list_status = " - Ha ocurrido algun error" list_colour = "red" else: list_status = " - No necesita correccion" list_colour = "green" if list_status is not None: itemlist.append(Item(channel=CHANNELNAME, title=channel.title + list_status, action="", folder=False, thumbnail=channel.thumbnail, text_color=list_colour)) else: logger.info("Algo va mal con el canal %s" % channel.channel) # Si el canal esta en la lista de exclusiones lo saltamos else: continue except: import traceback logger.info(channel.title + " | Detalle del error: %s" % traceback.format_exc()) platformtools.dialog_notification("Error", "Se ha producido un error con el canal %s" % channel.title) return itemlist else: platformtools.dialog_notification("pelisalacarta", "Error!") platformtools.itemlist_update(Item(channel=CHANNELNAME, action="submenu_tools"))
def mainlist(item): logger.info("tvalacarta.channels.configuracion mainlist") itemlist = [] itemlist.append( Item(channel=CHANNELNAME, title="Preferencias", action="settings", folder=False)) itemlist.append( Item(channel=CHANNELNAME, title="", action="", folder=False)) itemlist.append( Item(channel=CHANNELNAME, title="Ajustes especiales", action="", folder=False)) itemlist.append( Item(channel="novedades", title=" Ajustes de la sección 'Novedades'", action="menu_opciones", folder=True)) itemlist.append( Item(channel="buscador", title=" Ajustes del buscador global", action="opciones", folder=True)) if config.is_xbmc(): itemlist.append( Item(channel=item.channel, action="updatebiblio", title=" Buscar nuevos episodios y actualizar biblioteca", folder=False)) itemlist.append( Item(channel=CHANNELNAME, title=" Comprobar actualizaciones", action="check_for_updates", folder=False)) itemlist.append( Item(channel=CHANNELNAME, title=" Añadir o Actualizar canal/conector desde una URL", action="menu_addchannels")) itemlist.append( Item(channel=item.channel, action="", title="", folder=False)) itemlist.append( Item(channel=CHANNELNAME, title="Ajustes por canales", action="", folder=False)) import channelselector from core import channeltools channel_list = channelselector.filterchannels("all") for channel in channel_list: jsonchannel = channeltools.get_channel_json(channel.channel) if jsonchannel.get("settings"): setting = jsonchannel["settings"] if type(setting) == list: if len([ s for s in setting if "id" in s and not "include_in_" in s["id"] ]): itemlist.append( Item(channel=CHANNELNAME, title=" Configuración del canal '%s'" % channel.title, action="channel_config", config=channel.channel, folder=False)) return itemlist
def start(self, list_controls=None, dict_values=None, caption="", callback=None, item=None, custom_button=None, channelpath=None): log() # Media Path self.mediapath = os.path.join(config.get_runtime_path(), 'resources', 'skins', 'Default', 'media') # Params self.list_controls = list_controls self.values = dict_values self.caption = caption self.callback = callback self.item = item if isinstance(custom_button, dict): self.custom_button = {} self.custom_button["label"] = custom_button.get("label", "") self.custom_button["function"] = custom_button.get("function", "") self.custom_button["visible"] = bool( custom_button.get("visible", True)) self.custom_button["close"] = bool( custom_button.get("close", False)) else: self.custom_button = None # Load Channel Settings if not channelpath: channelpath = inspect.currentframe( ).f_back.f_back.f_code.co_filename self.channel = os.path.basename(channelpath).replace(".py", "") self.ch_type = os.path.basename(os.path.dirname(channelpath)) # If list_controls does not exist, it is removed from the channel json if not self.list_controls: # If the channel path is in the "channels" folder, we get the controls and values using chaneltools if os.path.join( config.get_runtime_path(), "channels") or os.path.join( config.get_runtime_path(), "specials") in channelpath: # The call is made from a channel self.list_controls, default_values = channeltools.get_channel_controls_settings( self.channel) self.kwargs = {"channel": self.channel} self.channelName = channeltools.get_channel_json( self.channel)['name'] # If the channel path is in the "servers" folder, we get the controls and values through servertools elif os.path.join(config.get_runtime_path(), "servers") in channelpath: # The call is made from a channel self.list_controls, default_values = servertools.get_server_controls_settings( self.channel) self.kwargs = {"server": self.channel} self.channelName = servertools.get_server_json( self.channel)['name'] # Else Exit else: return None # If dict_values are not passed, create a blank dict if self.values is None: self.values = {} # Make title if self.caption == "": self.caption = str( config.get_localized_string(30100)) + ' - ' + self.channelName matches = match(self.caption, patron=r'@(\d+)').matches if matches: for m in matches: self.caption = self.caption.replace( '@' + match, config.get_localized_string(int(m))) # Show Window self.return_value = None self.doModal() return self.return_value
def mainlist(item): logger.info() itemlist = list() itemlist.append( Item(channel=CHANNELNAME, title="Preferenze", action="settings", folder=False, thumbnail=get_thumbnail_path("thumb_configuracion.png"))) itemlist.append( Item(channel=CHANNELNAME, title="", action="", folder=False, thumbnail=get_thumbnail_path("thumb_configuracion.png"))) itemlist.append( Item(channel=CHANNELNAME, title="Impostazioni speciali", action="", folder=False, thumbnail=get_thumbnail_path("thumb_configuracion.png"))) itemlist.append( Item(channel="novedades", title=" Impostazioni 'Novità'", action="menu_opciones", folder=True, thumbnail=get_thumbnail_path("thumb_novedades.png"))) itemlist.append( Item(channel="buscador", title=" Impostazioni della ricerca globale", action="opciones", folder=True, thumbnail=get_thumbnail_path("thumb_buscar.png"))) if config.get_library_support(): itemlist.append( Item(channel="biblioteca", title=" Impostazioni libreria", action="channel_config", folder=True, thumbnail=get_thumbnail_path("thumb_biblioteca.png"))) itemlist.append( Item(channel="biblioteca", action="update_biblio", folder=False, thumbnail=get_thumbnail_path("thumb_biblioteca.png"), title=" Recupera nuovi episodi e aggiorna la libreria")) itemlist.append( Item(channel=CHANNELNAME, title="Avvia aggiornamenti", action="check_for_updates", folder=False)) itemlist.append( Item(channel=item.channel, action="", title="", folder=False, thumbnail=get_thumbnail_path("thumb_configuracion.png"))) itemlist.append( Item(channel=CHANNELNAME, title="Impostazioni canali", action="", folder=False, thumbnail=get_thumbnail_path("thumb_configuracion.png"))) import channelselector from core import channeltools channel_list = channelselector.filterchannels("all") for channel in channel_list: try: jsonchannel = channeltools.get_channel_json(channel.channel) except: continue if jsonchannel.get("settings"): setting = jsonchannel["settings"] if type(setting) == list: if len([ s for s in setting if "id" in s and "include_in_" not in s["id"] ]): active_status = None if config.get_setting("enabled", channel.channel): active_status = config.get_setting( "enabled", channel.channel) else: channel_parameters = channeltools.get_channel_parameters( channel.channel) active_status = channel_parameters['active'] if active_status == True: itemlist.append( Item(channel=CHANNELNAME, title=" Configurazione canale '%s'" % channel.title, action="channel_config", config=channel.channel, folder=False, thumbnail=channel.thumbnail)) return itemlist
def conf_tools(item): logger.info() # Activar/Desactivar canales if item.extra == "channels_onoff": import channelselector from core import channeltools from platformcode import platformtools channel_list = channelselector.filterchannels("allchannelstatus") channel_language = config.get_setting("channel_language") if channel_language == "": channel_language = "all" excluded_channels = ['tengourl', 'buscador', 'libreria', 'configuracion', 'novedades', 'personal', 'ayuda'] list_controls = [] try: list_controls.append({'id': "all_channels", 'type': "list", 'label': "Todos los canales", 'default': 0, 'enabled': True, 'visible': True, 'lvalues': ['', 'Activar todos', 'Desactivar todos', 'Establecer estado por defecto']}) for channel in channel_list: # Si el canal esta en la lista de exclusiones lo saltamos if channel.channel not in excluded_channels: # Se cargan los ajustes del archivo json del canal jsonchannel = channeltools.get_channel_json(channel.channel) if jsonchannel.get("settings") or jsonchannel.get("active"): channel_parameters = channeltools.get_channel_parameters(channel.channel) # No incluir si es un canal para adultos, y el modo adulto está desactivado if (channel_parameters["adult"] == "true" and config.get_setting("adult_mode") == "false"): continue # No incluir si el canal es en un idioma filtrado if (channel_language != "all" and channel_parameters["language"] != channel_language): continue xml_status = None status = None xml_status = channel_parameters["active"] status_control = "" if config.get_setting("enabled", channel.channel): status = config.get_setting("enabled", channel.channel) # logger.info(channel.channel + " | Status: " + str(status)) else: status = xml_status # logger.info(channel.channel + " | Status (XML): " + str(status)) # Se establece el estado if status == "false" or status is False: status = False elif status == "true" or status is True: status = True if xml_status == "false": status_control = " [COLOR grey](Desactivado por defecto)[/COLOR]" if status is not None: control = {'id': channel.channel, 'type': "bool", 'label': channel_parameters["title"] + status_control, 'default': status, 'enabled': True, 'visible': True} list_controls.append(control) else: logger.info("Algo va mal con el canal " + channel.channel) else: continue return platformtools.show_channel_settings(list_controls=list_controls, caption="Activar/Desactivar canales", callback="channel_status") except: import traceback from platformcode import platformtools logger.info(channel.title + " | Detalle del error: %s" % traceback.format_exc()) platformtools.dialog_notification("Error", "Se ha producido un error con el canal" + channel.title) # Comprobacion de archivos channel_data.json elif item.extra == "lib_check_datajson": itemlist = [] import channelselector from core import channeltools channel_list = channelselector.filterchannels("allchannelstatus") # Tener una lista de exclusion no tiene mucho sentido por que se comprueba si # el xml tiene "settings", pero por si acaso se deja excluded_channels = ['tengourl', 'configuracion', 'personal', 'ayuda'] try: import os from core import jsontools for channel in channel_list: needsfix = None list_status = None list_controls = None default_settings = None channeljson_exists = None # Se convierte el "channel.channel" del canal biblioteca para que no de error if channel.channel == "libreria": channel.channel = "biblioteca" # Se comprueba si el canal esta en la lista de exclusiones if channel.channel not in excluded_channels: # Se comprueba que tenga "settings", sino se salta jsonchannel = channeltools.get_channel_json(channel.channel) if not jsonchannel.get("settings"): itemlist.append(Item(channel=CHANNELNAME, title=channel.title + " - No tiene ajustes por defecto", action="", folder=False, thumbnail=channel.thumbnail)) continue # logger.info(channel.channel + " SALTADO!") # Se cargan los ajustes del archivo json del canal file_settings = os.path.join(config.get_data_path(), "settings_channels", channel.channel + "_data.json") dict_settings = {} dict_file = {} if filetools.exists(file_settings): # logger.info(channel.channel + " Tiene archivo _data.json") channeljson_exists = "true" # Obtenemos configuracion guardada de ../settings/channel_data.json try: dict_file = jsontools.load_json(open(file_settings, "rb").read()) if isinstance(dict_file, dict) and 'settings' in dict_file: dict_settings = dict_file['settings'] except EnvironmentError: logger.info("ERROR al leer el archivo: {0}".format(file_settings)) else: # logger.info(channel.channel + " No tiene archivo _data.json") channeljson_exists = "false" if channeljson_exists == "true": try: datajson_size = filetools.getsize(file_settings) except: import traceback logger.info(channel.title + " | Detalle del error: %s" % traceback.format_exc()) else: datajson_size = None # Si el _data.json esta vacio o no existe... if (len(dict_settings) and datajson_size) == 0 or channeljson_exists == "false": # Obtenemos controles del archivo ../channels/channel.xml needsfix = "true" try: # Se cargan los ajustes por defecto list_controls, default_settings = channeltools.get_channel_controls_settings(channel.channel) # logger.info(channel.title + " | Default: %s" % default_settings) except: import traceback logger.info(channel.title + " | Detalle del error: %s" % traceback.format_exc()) # default_settings = {} # Si _data.json necesita ser reparado o no existe... if needsfix == "true" or channeljson_exists == "false": if default_settings is not None: # Creamos el channel_data.json default_settings.update(dict_settings) dict_settings = default_settings dict_file['settings'] = dict_settings # Creamos el archivo ../settings/channel_data.json json_data = jsontools.dump_json(dict_file) try: open(file_settings, "wb").write(json_data) # logger.info(channel.channel + " - Archivo _data.json GUARDADO!") # El channel_data.json se ha creado/modificado list_status = " - [COLOR red] CORREGIDO!![/COLOR]" except EnvironmentError: logger.info("ERROR al salvar el archivo: {0}".format(file_settings)) else: if default_settings is None: list_status = " - [COLOR red] Imposible cargar los ajustes por defecto![/COLOR]" else: # logger.info(channel.channel + " - NO necesita correccion!") needsfix = "false" # Si se ha establecido el estado del canal se añade a la lista if needsfix is not None: if needsfix == "true": if channeljson_exists == "false": list_status = " - [COLOR red] Ajustes creados!![/COLOR]" else: list_status = " - [COLOR green] No necesita correccion[/COLOR]" else: # Si "needsfix" es "false" y "datjson_size" es None habra # ocurrido algun error if datajson_size is None: list_status = " - [COLOR red] Ha ocurrido algun error[/COLOR]" else: list_status = " - [COLOR green] No necesita correccion[/COLOR]" if list_status is not None: itemlist.append(Item(channel=CHANNELNAME, title=channel.title + list_status, action="", folder=False, thumbnail=channel.thumbnail)) else: logger.info("Algo va mal con el canal " + channel.channel) # Si el canal esta en la lista de exclusiones lo saltamos else: continue except: import traceback from platformcode import platformtools logger.info(channel.title + " | Detalle del error: %s" % traceback.format_exc()) platformtools.dialog_notification("Error", "Se ha producido un error con el canal" + channel.title) return itemlist else: from platformcode import platformtools platformtools.dialog_notification("pelisalacarta", "Error!") platformtools.itemlist_update(Item(channel=CHANNELNAME, action="submenu_tools"))
def mainlist(item): logger.info() itemlist = list() itemlist.append(Item(channel=CHANNELNAME, title="Preferencias", action="settings", folder=False, thumbnail=get_thumbnail_path("thumb_configuracion.png"))) if config.get_setting("plugin_updates_available")=="0": nuevas = "" elif config.get_setting("plugin_updates_available")=="1": nuevas = " (1 nueva)" else: nuevas = " ("+config.get_setting("plugin_updates_available")+" nuevas)" itemlist.append(Item(channel=CHANNELNAME, title="Descargar e instalar otras versiones"+nuevas, action="get_all_versions", folder=True)) itemlist.append(Item(channel=CHANNELNAME, title="", action="", folder=False, thumbnail=get_thumbnail_path("thumb_configuracion.png"))) itemlist.append(Item(channel=CHANNELNAME, title="Ajustes especiales", action="", folder=False, thumbnail=get_thumbnail_path("thumb_configuracion.png"))) itemlist.append(Item(channel="novedades", title=" Ajustes de la sección 'Novedades'", action="menu_opciones", folder=True, thumbnail=get_thumbnail_path("thumb_novedades.png"))) itemlist.append(Item(channel="buscador", title=" Ajustes del buscador global", action="opciones", folder=True, thumbnail=get_thumbnail_path("thumb_buscar.png"))) if config.get_library_support(): itemlist.append(Item(channel="biblioteca", title=" Ajustes de la biblioteca", action="channel_config", folder=True, thumbnail=get_thumbnail_path("thumb_biblioteca.png"))) itemlist.append(Item(channel="biblioteca", action="update_biblio", folder=False, thumbnail=get_thumbnail_path("thumb_biblioteca.png"), title=" Buscar nuevos episodios y actualizar biblioteca")) itemlist.append(Item(channel=CHANNELNAME, title=" Añadir o Actualizar canal/conector desde una URL", action="menu_addchannels")) itemlist.append(Item(channel=item.channel, action="", title="", folder=False, thumbnail=get_thumbnail_path("thumb_configuracion.png"))) itemlist.append(Item(channel=CHANNELNAME, title="Activar/Desactivar canales", action="conf_tools", folder=True, extra="channels_onoff", thumbnail=get_thumbnail_path("thumb_configuracion.png"))) itemlist.append(Item(channel=CHANNELNAME, title="Ajustes por canales", action="", folder=False, thumbnail=get_thumbnail_path("thumb_configuracion.png"))) import channelselector from core import channeltools channel_list = channelselector.filterchannels("all") for channel in channel_list: try: jsonchannel = channeltools.get_channel_json(channel.channel) except: continue if jsonchannel.get("settings"): setting = jsonchannel["settings"] if type(setting) == list: if len([s for s in setting if "id" in s and "include_in_" not in s["id"]]): active_status = None if config.get_setting("enabled", channel.channel): active_status = config.get_setting("enabled", channel.channel) else: channel_parameters = channeltools.get_channel_parameters(channel.channel) active_status = channel_parameters['active'] if active_status == "true": itemlist.append(Item(channel=CHANNELNAME, title=" Configuración del canal '%s'" % channel.title, action="channel_config", config=channel.channel, folder=False, thumbnail=channel.thumbnail)) itemlist.append(Item(channel=item.channel, action="", title="", folder=False, thumbnail=get_thumbnail_path("thumb_configuracion.png"))) itemlist.append(Item(channel=CHANNELNAME, title="Otras herramientas", action="submenu_tools", folder=True, thumbnail=get_thumbnail_path("thumb_configuracion.png"))) return itemlist
def mainlist(item): logger.info() itemlist = list() itemlist.append( Item(channel=CHANNELNAME, title="Preferencias", action="settings", folder=False, thumbnail=get_thumbnail_path("thumb_configuracion.png"))) itemlist.append( Item(channel=CHANNELNAME, title="", action="", folder=False, thumbnail=get_thumbnail_path("thumb_configuracion.png"))) itemlist.append( Item(channel=CHANNELNAME, title="Ajustes especiales", action="", folder=False, thumbnail=get_thumbnail_path("thumb_configuracion.png"))) itemlist.append( Item(channel="novedades", title=" Ajustes de la sección 'Novedades'", action="menu_opciones", folder=True, thumbnail=get_thumbnail_path("thumb_novedades.png"))) itemlist.append( Item(channel="buscador", title=" Ajustes del buscador global", action="opciones", folder=True, thumbnail=get_thumbnail_path("thumb_buscar.png"))) if config.get_library_support(): itemlist.append( Item(channel="biblioteca", title=" Ajustes de la biblioteca", action="channel_config", folder=True, thumbnail=get_thumbnail_path("thumb_biblioteca.png"))) itemlist.append( Item(channel="biblioteca", action="update_biblio", folder=False, thumbnail=get_thumbnail_path("thumb_biblioteca.png"), title=" Buscar nuevos episodios y actualizar biblioteca")) itemlist.append( Item(channel=CHANNELNAME, title=" Comprobar actualizaciones", action="check_for_updates", folder=False, thumbnail=get_thumbnail_path("Crystal_Clear_action_info.png"))) itemlist.append( Item(channel=CHANNELNAME, title=" Añadir o Actualizar canal/conector desde una URL", action="menu_addchannels")) itemlist.append( Item(channel=item.channel, action="", title="", folder=False, thumbnail=get_thumbnail_path("thumb_configuracion.png"))) itemlist.append( Item(channel=CHANNELNAME, title="Ajustes por canales", action="", folder=False, thumbnail=get_thumbnail_path("thumb_configuracion.png"))) import channelselector from core import channeltools channel_list = channelselector.filterchannels("all") for channel in channel_list: jsonchannel = channeltools.get_channel_json(channel.channel) if jsonchannel.get("settings"): setting = jsonchannel["settings"] if type(setting) == list: if len([ s for s in setting if "id" in s and "include_in_" not in s["id"] ]): itemlist.append( Item(channel=CHANNELNAME, title=" Configuración del canal '%s'" % channel.title, action="channel_config", config=channel.channel, folder=False, thumbnail=channel.thumbnail)) return itemlist