diff --git a/plugin.video.alfa/channels/setting.py b/plugin.video.alfa/channels/setting.py index cc1b95b1..47770941 100644 --- a/plugin.video.alfa/channels/setting.py +++ b/plugin.video.alfa/channels/setting.py @@ -327,6 +327,9 @@ def conf_tools(item): # Activar o desactivar canales if item.extra == "channels_onoff": + if config.get_platform(True)['num_version'] >= 17.0: # A partir de Kodi 16 se puede usar multiselect, y de 17 con preselect + return channels_onoff(item) + import channelselector from core import channeltools @@ -529,6 +532,59 @@ def conf_tools(item): return itemlist +def channels_onoff(item): + import channelselector, xbmcgui + from core import channeltools + + # Cargar lista de opciones + # ------------------------ + lista = []; ids = [] + channels_list = channelselector.filterchannels('allchannelstatus') + for channel in channels_list: + channel_parameters = channeltools.get_channel_parameters(channel.channel) + lbl = '%s' % channel_parameters['language'] + lbl += ' %s' % [config.get_localized_category(categ) for categ in channel_parameters['categories']] + + it = xbmcgui.ListItem(channel.title, lbl) + it.setArt({ 'thumb': channel.thumbnail, 'fanart': channel.fanart }) + lista.append(it) + ids.append(channel.channel) + + # Diálogo para pre-seleccionar + # ---------------------------- + preselecciones = ['Pre-seleccionar activados actualmente', 'Pre-seleccionar todos', 'No pre-seleccionar ninguno'] + ret = platformtools.dialog_select(config.get_localized_string(60545), preselecciones) + if ret == -1: return False # pedido cancel + if ret == 2: preselect = [] + elif ret == 1: preselect = range(len(ids)) + else: + preselect = [] + for i, canal in enumerate(ids): + channel_status = config.get_setting('enabled', canal) + if channel_status is None: channel_status = True + if channel_status: + preselect.append(i) + + # Diálogo para seleccionar + # ------------------------ + ret = xbmcgui.Dialog().multiselect(config.get_localized_string(60545), lista, preselect=preselect, useDetails=True) + if ret == None: return False # pedido cancel + seleccionados = [ids[i] for i in ret] + + # Guardar cambios en canales activados + # ------------------------------------ + for canal in ids: + channel_status = config.get_setting('enabled', canal) + if channel_status is None: channel_status = True + + if channel_status and canal not in seleccionados: + config.set_setting('enabled', False, canal) + elif not channel_status and canal in seleccionados: + config.set_setting('enabled', True, canal) + + return False + + def channel_status(item, dict_values): try: for k in dict_values: diff --git a/plugin.video.alfa/channelselector.py b/plugin.video.alfa/channelselector.py index d4a64f1e..f2414b8c 100644 --- a/plugin.video.alfa/channelselector.py +++ b/plugin.video.alfa/channelselector.py @@ -63,11 +63,6 @@ def getchanneltypes(view="thumb_"): # Lista de categorias channel_types = ["movie", "tvshow", "anime", "documentary", "vos", "direct", "torrent"] - dict_types_lang = {'movie': config.get_localized_string(30122), 'tvshow': config.get_localized_string(30123), - 'anime': config.get_localized_string(30124), 'documentary': config.get_localized_string(30125), - 'vos': config.get_localized_string(30136), 'adult': config.get_localized_string(30126), - 'direct': config.get_localized_string(30137)} - if config.get_setting("adult_mode") != 0: channel_types.append("adult") @@ -83,7 +78,7 @@ def getchanneltypes(view="thumb_"): for channel_type in channel_types: logger.info("channel_type=%s" % channel_type) - title = dict_types_lang.get(channel_type, channel_type) + title = config.get_localized_category(channel_type) itemlist.append(Item(title=title, channel="channelselector", action="filterchannels", category=title, channel_type=channel_type, viewmode="thumbnails", thumbnail=get_thumb("channels_%s.png" % channel_type, view))) diff --git a/plugin.video.alfa/platformcode/config.py b/plugin.video.alfa/platformcode/config.py index 278bde5c..227a5262 100644 --- a/plugin.video.alfa/platformcode/config.py +++ b/plugin.video.alfa/platformcode/config.py @@ -299,6 +299,14 @@ def get_localized_string(code): return dev +def get_localized_category(categ): + categories = {'movie': get_localized_string(30122), 'tvshow': get_localized_string(30123), + 'anime': get_localized_string(30124), 'documentary': get_localized_string(30125), + 'vos': get_localized_string(30136), 'adult': get_localized_string(30126), + 'direct': get_localized_string(30137), 'torrent': get_localized_string(70015)} + return categories[categ] if categ in categories else categ + + def get_videolibrary_config_path(): value = get_setting("videolibrarypath")