示例#1
0
def configuracion(item):
    from platformcode import platformtools

    platformtools.show_channel_settings()
    if config.is_xbmc():
        import xbmc

        xbmc.executebuiltin("Container.Refresh")
def channel_config(item):
    from platformcode import platformtools
    import os

    return platformtools.show_channel_settings(
        channelpath=os.path.join(config.get_runtime_path(), "channels", item.config)
    )
示例#3
0
def filtro(item):
    logger.info()

    list_controls = []
    valores = {}

    dict_values = None
    list_controls.append({'id': 'search', 'label': 'Texto a buscar', 'enabled': True, 'color': '0xFFC52020',
                          'type': 'text', 'default': '', 'visible': True})
    list_controls.append({'id': 'tipo', 'label': 'Tipo de búsqueda', 'enabled': True, 'color': '0xFFFF8000',
                          'type': 'list', 'default': -1, 'visible': True})
    list_controls[1]['lvalues'] = ['Aplicación', 'Archivo', 'Documento', 'Imagen', 'Música', 'Vídeo', 'Todos']
    valores['tipo'] = ['Application', 'Archive', 'Document', 'Image', 'Music', 'Video', '']

    list_controls.append({'id': 'ext', 'label': 'Extensión', 'enabled': True, 'color': '0xFFF4FA58',
                          'type': 'text', 'default': '', 'visible': True})
    list_controls.append({'id': 'tmin', 'label': 'Tamaño mínimo (MB)', 'enabled': True, 'color': '0xFFCC2EFA',
                          'type': 'text', 'default': '0', 'visible': True})
    list_controls.append({'id': 'tmax', 'label': 'Tamaño máximo (MB)', 'enabled': True, 'color': '0xFF2ECCFA',
                          'type': 'text', 'default': '0', 'visible': True})

    # Se utilizan los valores por defecto/guardados
    web = "copiapop"
    if "diskokosmiko" in item.extra:
        web = "diskokosmiko"
    valores_guardados = config.get_setting("filtro_defecto_" + web, item.channel)
    if valores_guardados:
        dict_values = valores_guardados
    item.valores = valores
    from platformcode import platformtools
    return platformtools.show_channel_settings(list_controls=list_controls, dict_values=dict_values,
                                               caption="Filtra la búsqueda", item=item, callback='filtrado')
示例#4
0
def searchbycat(item):
    # Only in xbmc/kodi
    # Abre un cuadro de dialogo con las categorías en las que hacer la búsqueda

    categories = ["Películas", "Series", "Anime", "Documentales", "VOS", "Latino"]
    categories_id = ["movie", "serie", "anime", "documentary", "vos", "latino"]
    list_controls = []
    for i, category in enumerate(categories):
        control = {'id': categories_id[i],
                   'type': "bool",
                   'label': category,
                   'default': False,
                   'enabled': True,
                   'visible': True}

        list_controls.append(control)
    control = {'id': "separador",
               'type': "label",
               'label': '',
               'default': "",
               'enabled': True,
               'visible': True}
    list_controls.append(control)
    control = {'id': "torrent",
               'type': "bool",
               'label': 'Incluir en la búsqueda canales Torrent',
               'default': True,
               'enabled': True,
               'visible': True}
    list_controls.append(control)

    return platformtools.show_channel_settings(list_controls=list_controls, caption="Elegir categorías",
                                               callback="search_cb", item=item)
示例#5
0
def settingCanal(item):
    channels_path = os.path.join(config.get_runtime_path(), "channels", '*.xml')
    channel_language = config.get_setting("channel_language")

    if channel_language == "":
        channel_language = "all"

    list_controls = []
    for infile in sorted(glob.glob(channels_path)):
        channel_name = os.path.basename(infile)[:-4]
        channel_parameters = channeltools.get_channel_parameters(channel_name)

        # No incluir si es un canal inactivo
        if channel_parameters["active"] != "true":
            continue

        # 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

        # No incluir si en la configuracion del canal no existe "include_in_global_search"
        include = channel_parameters["include_in_global_search"]
        if include not in ["", "true"]:
            continue
        else:
            # Se busca en la configuración del canal el valor guardado
            include_in_global_search = config.get_setting("include_in_global_search", channel_name)

        # Si no hay valor en la configuración del canal se coloca como True ya que así estaba por defecto
        if include_in_global_search == "":
            include_in_global_search = True

        control = {'id': channel_name,
                   'type': "bool",
                   'label': channel_parameters["title"],
                   'default': include_in_global_search,
                   'enabled': True,
                   'visible': True}

        list_controls.append(control)

    return platformtools.show_channel_settings(list_controls=list_controls,
                                               caption="Canales incluidos en la búsqueda global",
                                               callback="save_settings", item=item, custom_button={'visible': False})
def settingCanal(item):
    channels_path = os.path.join(config.get_runtime_path(), "channels", '*.xml')
    channel_language = config.get_setting("channel_language")

    if channel_language == "":
        channel_language = "all"

    list_controls = []
    for infile in sorted(glob.glob(channels_path)):
        channel_name = os.path.basename(infile)[:-4]
        channel_parameters = channeltools.get_channel_parameters(channel_name)

        # No incluir si es un canal inactivo
        if channel_parameters["active"] != "true":
            continue

        # 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

        # No incluir si en la configuracion del canal no existe "include_in_global_search"
        include_in_global_search = config.get_setting("include_in_global_search", channel_name)
        if include_in_global_search == "":
            continue

        control = {'id': channel_name,
                   'type': "bool",
                   'label': channel_parameters["title"],
                   'default': include_in_global_search,
                   'enabled': True,
                   'visible': True}

        list_controls.append(control)

    return platformtools.show_channel_settings(list_controls=list_controls,
                                               caption="Canali inclusi nella ricerca globale",
                                               callback="save_settings", item=item)
示例#7
0
def settingCanal(item):
    channels_path = os.path.join(config.get_runtime_path(), "channels", '*.xml')
    channel_language = config.get_setting("channel_language")

    if channel_language == "":
        channel_language = "all"

    list_controls = []
    for infile in sorted(glob.glob(channels_path)):
        channel_id = os.path.basename(infile)[:-4]
        channel_parameters = channeltools.get_channel_parameters(channel_id)

        # No incluir si es un canal inactivo
        if channel_parameters["active"] != "true":
            continue

        # 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

        # No incluir si en su configuracion el canal no existe 'include_in_newest'
        include_in_newest = config.get_setting("include_in_newest_" + item.extra, channel_id)
        if include_in_newest == "":
            continue

        control = {'id': channel_id,
                      'type': "bool",
                      'label': channel_parameters["title"],
                      'default': include_in_newest,
                      'enabled': True,
                      'visible': True}

        list_controls.append(control)

    caption = "Canales incluidos en Novedades " + item.title.replace("Canales incluidos en: ","- ").strip()
    return platformtools.show_channel_settings(list_controls=list_controls, callback="save_settings", item=item,
                                               caption= caption,custom_button={"visible":False})
示例#8
0
def channel_config(item):
    from platformcode import platformtools
    return platformtools.show_channel_settings(channelpath=filetools.join(
        config.get_runtime_path(), "channels", item.config))
示例#9
0
文件: search.py 项目: d3v3l0p1n/addon
def settings(item):
    return platformtools.show_channel_settings(caption="configuración -- Buscador")
示例#10
0
def filtro(item):
    logger.info("pelisalacarta.channels.inkapelis filtro")

    list_controls = []
    valores = {}
    strings = {}
    # Se utilizan los valores por defecto/guardados o los del filtro personalizado
    if not item.values:
        valores_guardados = config.get_setting("filtro_defecto_peliculas", item.channel)
    else:
        valores_guardados = item.values
        item.values = ""

    if valores_guardados:
        dict_values = valores_guardados
    else:
        dict_values = None
    if dict_values:
        dict_values["filtro_per"] = 0

    list_controls.append(
        {"id": "texto", "label": "Cadena de búsqueda", "enabled": True, "type": "text", "default": "", "visible": True}
    )
    data = scrapertools.downloadpage(item.url)
    data = re.sub(r"\n|\r|\t|\s{2}| ", "", data)
    matches = scrapertools.find_multiple_matches(data, 'option value="">([^<]+)</option>(.*?)</select>')
    i = 1
    for filtro_title, values in matches:
        id = filtro_title.replace("A\xc3\xb1o", "year").lower()
        filtro_title = filtro_title.replace("A\xc3\xb1o", "Año")
        list_controls.append(
            {"id": id, "label": filtro_title, "enabled": True, "type": "list", "default": 0, "visible": True}
        )
        valores[id] = []
        valores[id].append("")
        strings[filtro_title] = []
        list_controls[i]["lvalues"] = []
        list_controls[i]["lvalues"].append("Cualquiera")
        strings[filtro_title].append("Cualquiera")
        patron = '<option value="([^"]+)">([^<]+)</option>'
        matches_v = scrapertools.find_multiple_matches(values, patron)
        for value, key in matches_v:
            list_controls[i]["lvalues"].append(key)
            valores[id].append(value)
            strings[filtro_title].append(key)

        i += 1

    item.valores = valores
    item.strings = strings
    if "Filtro Personalizado" in item.title:
        return filtrado(item, valores_guardados)

    list_controls.append(
        {"id": "espacio", "label": "", "enabled": False, "type": "label", "default": "", "visible": True}
    )
    list_controls.append(
        {
            "id": "save",
            "label": "Establecer como filtro por defecto",
            "enabled": True,
            "type": "bool",
            "default": False,
            "visible": True,
        }
    )
    list_controls.append(
        {
            "id": "filtro_per",
            "label": "Guardar filtro en acceso directo...",
            "enabled": True,
            "type": "list",
            "default": 0,
            "visible": True,
            "lvalues": ["No guardar", "Filtro 1", "Filtro 2", "Filtro 3"],
        }
    )
    list_controls.append(
        {
            "id": "remove",
            "label": "Eliminar filtro personalizado...",
            "enabled": True,
            "type": "list",
            "default": 0,
            "visible": True,
            "lvalues": ["No eliminar", "Filtro 1", "Filtro 2", "Filtro 3"],
        }
    )

    from platformcode import platformtools

    return platformtools.show_channel_settings(
        list_controls=list_controls,
        dict_values=dict_values,
        caption="Filtra los resultados",
        item=item,
        callback="filtrado",
    )
示例#11
0
def settings(item):
    return platformtools.show_channel_settings()
示例#12
0
def config_item(item):
    """
    muestra una serie filtrada para su configuración

    @param item: item
    @type item: Item
    """
    logger.info()
    logger.info("item %s" % item.tostring())

    # OBTENEMOS LOS DATOS DEL JSON
    dict_series = jsontools.get_node_from_file(item.from_channel,
                                               TAG_TVSHOW_FILTER)

    tvshow = item.show.lower().strip()
    default_lang = ''

    channel_parameters = channeltools.get_channel_parameters(item.from_channel)
    list_language = channel_parameters["filter_languages"]
    try:
        if channel_parameters["filter_languages"] != '' and len(
                list_language) > 0:
            default_lang = list_language[1]
    except:
        pass

    if default_lang == '':
        platformtools.dialog_notification("FilterTools",
                                          "No hay idiomas definidos")
        return
    else:
        lang_selected = dict_series.get(tvshow,
                                        {}).get(TAG_LANGUAGE, default_lang)
        list_quality = dict_series.get(tvshow, {}).get(
            TAG_QUALITY_ALLOWED, [x.lower() for x in item.list_quality])
        # logger.info("lang selected {}".format(lang_selected))
        # logger.info("list quality {}".format(list_quality))

        active = True
        custom_button = {'visible': False}
        allow_option = False
        if item.show.lower().strip() in dict_series:
            allow_option = True
            active = dict_series.get(item.show.lower().strip(),
                                     {}).get(TAG_ACTIVE, False)
            custom_button = {
                'label': 'Borrar',
                'function': 'delete',
                'visible': True,
                'close': True
            }

        list_controls = []

        if allow_option:
            active_control = {
                "id": "active",
                "type": "bool",
                "label": "¿Activar/Desactivar filtro?",
                "color": "",
                "default": active,
                "enabled": allow_option,
                "visible": allow_option,
            }
            list_controls.append(active_control)

        language_option = {
            "id": "language",
            "type": "list",
            "label": "Idioma",
            "color": "0xFFee66CC",
            "default": item.list_language.index(lang_selected),
            "enabled": True,
            "visible": True,
            "lvalues": item.list_language
        }
        list_controls.append(language_option)

        if item.list_quality:
            list_controls_calidad = [
                {
                    "id": "textoCalidad",
                    "type": "label",
                    "label": "Calidad permitida",
                    "color": "0xffC6C384",
                    "enabled": True,
                    "visible": True,
                },
            ]
            for element in sorted(item.list_quality, key=str.lower):
                list_controls_calidad.append({
                    "id":
                    element,
                    "type":
                    "bool",
                    "label":
                    element,
                    "default": (False, True)[element.lower() in list_quality],
                    "enabled":
                    True,
                    "visible":
                    True,
                })

            # concatenamos list_controls con list_controls_calidad
            list_controls.extend(list_controls_calidad)

        title = "Filtrado de enlaces para: [COLOR %s]%s[/COLOR]" % (COLOR.get(
            "selected", "auto"), item.show)

        platformtools.show_channel_settings(list_controls=list_controls,
                                            callback='save',
                                            item=item,
                                            caption=title,
                                            custom_button=custom_button)
示例#13
0
def settings(item):
    return platformtools.show_channel_settings(
        caption="configuración -- Novedades")
示例#14
0
def setting_channel(item):
    channels_path = os.path.join(config.get_runtime_path(), "channels",
                                 '*.json')
    channel_language = config.get_setting("channel_language", default="auto")
    if channel_language == 'auto':
        channel_language = auto_filter()

    list_controls = []
    for infile in sorted(glob.glob(channels_path)):
        channel_id = os.path.basename(infile)[:-5]
        channel_parameters = channeltools.get_channel_parameters(channel_id)

        # No incluir si es un canal inactivo
        if not channel_parameters["active"]:
            continue

        # No incluir si es un canal para adultos, y el modo adulto está desactivado
        if channel_parameters["adult"] and config.get_setting(
                "adult_mode") == 0:
            continue

        # No incluir si el canal es en un idioma filtrado
        if channel_language != "all" and channel_language not in channel_parameters["language"] \
                and "*" not in channel_parameters["language"]:
            continue

        # No incluir si en su configuracion el canal no existe 'include_in_newest'
        include_in_newest = config.get_setting(
            "include_in_newest_" + item.extra, channel_id)
        if include_in_newest is None:
            continue

        control = {
            'id': channel_id,
            'type': "bool",
            'label': channel_parameters["title"],
            'default': include_in_newest,
            'enabled': True,
            'visible': True
        }

        list_controls.append(control)

    caption = config.get_localized_string(60533) + item.title.replace(
        config.get_localized_string(60525), "- ").strip()
    if config.get_setting("custom_button_value_news", item.channel):
        custom_button_label = config.get_localized_string(59992)
    else:
        custom_button_label = config.get_localized_string(59991)

    return platformtools.show_channel_settings(list_controls=list_controls,
                                               caption=caption,
                                               callback="save_settings",
                                               item=item,
                                               custom_button={
                                                   'visible': True,
                                                   'function':
                                                   "cb_custom_button",
                                                   'close': False,
                                                   'label': custom_button_label
                                               })
示例#15
0
文件: search.py 项目: wrlopez/addon
def settings(item):
    return platformtools.show_channel_settings(
        caption=config.get_localized_string(59993))
示例#16
0
文件: search.py 项目: wrlopez/addon
def setting_channel_old(item):
    channels_path = os.path.join(config.get_runtime_path(), "channels",
                                 '*.json')
    channel_language = config.get_setting("channel_language", default="all")

    list_controls = []
    for infile in sorted(glob.glob(channels_path)):
        channel_name = os.path.basename(infile)[:-5]
        channel_parameters = channeltools.get_channel_parameters(channel_name)

        # No incluir si es un canal inactivo
        if not channel_parameters["active"]:
            continue

        # No incluir si es un canal para adultos, y el modo adulto está desactivado
        if channel_parameters["adult"] and config.get_setting(
                "adult_mode") == 0:
            continue

        # No incluir si el canal es en un idioma filtrado
        if channel_language != "all" and channel_language not in channel_parameters["language"] \
                and "*" not in channel_parameters["language"]:
            continue

        # No incluir si en la configuracion del canal no existe "include_in_global_search"
        include_in_global_search = channel_parameters[
            "include_in_global_search"]

        if not include_in_global_search:
            continue
        else:
            # Se busca en la configuración del canal el valor guardado
            include_in_global_search = config.get_setting(
                "include_in_global_search", channel_name)

        control = {
            'id': channel_name,
            'type': "bool",
            'label': channel_parameters["title"],
            'default': include_in_global_search,
            'enabled': True,
            'visible': True
        }

        list_controls.append(control)

    if config.get_setting("custom_button_value", item.channel):
        custom_button_label = config.get_localized_string(59992)
    else:
        custom_button_label = config.get_localized_string(59991)

    return platformtools.show_channel_settings(
        list_controls=list_controls,
        caption=config.get_localized_string(59990),
        callback="save_settings",
        item=item,
        custom_button={
            'visible': True,
            'function': "cb_custom_button",
            'close': False,
            'label': custom_button_label
        })
示例#17
0
def autoplay_config(item):
    logger.info()
    global autoplay_node
    dict_values = {}
    list_controls = []
    channel_parameters = channeltools.get_channel_parameters(item.from_channel)
    channel_name = channel_parameters['title']

    if not autoplay_node:
        # Obtiene el nodo AUTOPLAY desde el json
        autoplay_node = jsontools.get_node_from_file('autoplay', 'AUTOPLAY')

    channel_node = autoplay_node.get(item.from_channel, {})
    settings_node = channel_node.get('settings', {})

    allow_option = True

    active_settings = {
        "id": "active",
        "label": "AutoPlay (activar/desactivar la auto-reproduccion)",
        "color": "0xffffff99",
        "type": "bool",
        "default": False,
        "enabled": allow_option,
        "visible": allow_option
    }
    list_controls.append(active_settings)
    dict_values['active'] = settings_node.get('active', False)

    # Idioma
    status_language = config.get_setting("filter_languages", item.from_channel)
    if not status_language:
        status_language = 0

    set_language = {
        "id": "language",
        "label": "Idioma para AutoPlay (Opcional)",
        "color": "0xffffff99",
        "type": "list",
        "default": 0,
        "enabled": "eq(-1,true)",
        "visible": True,
        "lvalues": get_languages(item.from_channel)
    }

    list_controls.append(set_language)
    dict_values['language'] = status_language

    separador = {
        "id": "label",
        "label": "         "
        "_________________________________________________________________________________________",
        "type": "label",
        "enabled": True,
        "visible": True
    }
    list_controls.append(separador)

    # Seccion servidores Preferidos
    server_list = channel_node.get("servers", [])
    if not server_list:
        enabled = False
        server_list = ["No disponible"]
    else:
        enabled = "eq(-3,true)"

    custom_servers_settings = {
        "id": "custom_servers",
        "label": "      Servidores Preferidos",
        "color": "0xff66ffcc",
        "type": "bool",
        "default": False,
        "enabled": enabled,
        "visible": True
    }
    list_controls.append(custom_servers_settings)
    if dict_values['active'] and enabled:
        dict_values['custom_servers'] = settings_node.get(
            'custom_servers', False)
    else:
        dict_values['custom_servers'] = False

    for num in range(1, 4):
        pos1 = num + 3
        default = num - 1
        if default > len(server_list) - 1:
            default = 0
        set_servers = {
            "id": "server_%s" % num,
            "label": u"          \u2665 Servidor Favorito %s" % num,
            "color": "0xfffcab14",
            "type": "list",
            "default": default,
            "enabled": "eq(-%s,true)+eq(-%s,true)" % (pos1, num),
            "visible": True,
            "lvalues": server_list
        }
        list_controls.append(set_servers)

        dict_values["server_%s" % num] = settings_node.get(
            "server_%s" % num, 0)
        if settings_node.get("server_%s" % num, 0) > len(server_list) - 1:
            dict_values["server_%s" % num] = 0

    # Seccion Calidades Preferidas
    quality_list = channel_node.get("quality", [])
    if not quality_list:
        enabled = False
        quality_list = ["No disponible"]
    else:
        enabled = "eq(-7,true)"

    custom_quality_settings = {
        "id": "custom_quality",
        "label": "      Calidades Preferidas",
        "color": "0xff66ffcc",
        "type": "bool",
        "default": False,
        "enabled": enabled,
        "visible": True
    }
    list_controls.append(custom_quality_settings)
    if dict_values['active'] and enabled:
        dict_values['custom_quality'] = settings_node.get(
            'custom_quality', False)
    else:
        dict_values['custom_quality'] = False

    for num in range(1, 4):
        pos1 = num + 7
        default = num - 1
        if default > len(quality_list) - 1:
            default = 0

        set_quality = {
            "id": "quality_%s" % num,
            "label": u"          \u2665 Calidad Favorita %s" % num,
            "color": "0xfff442d9",
            "type": "list",
            "default": default,
            "enabled": "eq(-%s,true)+eq(-%s,true)" % (pos1, num),
            "visible": True,
            "lvalues": quality_list
        }
        list_controls.append(set_quality)
        dict_values["quality_%s" % num] = settings_node.get(
            "quality_%s" % num, 0)
        if settings_node.get("quality_%s" % num, 0) > len(quality_list) - 1:
            dict_values["quality_%s" % num] = 0

    # Seccion Prioridades
    priority_list = ["Servidor y Calidad", "Calidad y Servidor"]
    set_priority = {
        "id": "priority",
        "label": "   Prioridad (Indica el orden para Auto-Reproducir)",
        "color": "0xffffff99",
        "type": "list",
        "default": 0,
        "enabled": True,
        "visible": "eq(-4,true)+eq(-8,true)+eq(-11,true)",
        "lvalues": priority_list
    }
    list_controls.append(set_priority)
    dict_values["priority"] = settings_node.get("priority", 0)

    # Abrir cuadro de dialogo
    platformtools.show_channel_settings(list_controls=list_controls,
                                        dict_values=dict_values,
                                        callback='save',
                                        item=item,
                                        caption='%s - AutoPlay' % channel_name)
示例#18
0
def channel_config(item):
    return platformtools.show_channel_settings(channelpath=os.path.join(config.get_runtime_path(),
                                                                        "channels", item.channel))
示例#19
0
def channel_config(item):
    return platformtools.show_channel_settings(
        channelpath=os.path.join(config.get_runtime_path(), "channels",
                                 item.channel),
        caption=config.get_localized_string(60598))
示例#20
0
def settings(item):
    ret = platformtools.show_channel_settings(
        caption=config.get_localized_string(70224))
    platformtools.itemlist_refresh()
    return ret
示例#21
0
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"))
示例#22
0
def settingCanal(item):
    from platformcode import platformtools
    platformtools.show_channel_settings()
    platformtools.itemlist_refresh()
    return
示例#23
0
def channel_config(item):
    return platformtools.show_channel_settings(channelpath=os.path.join(config.get_runtime_path(), "channels",
                                                                        item.channel),
                                               caption="configuración -- Videoteca")
示例#24
0
def cuadro_completar(item):
    logger.info()

    global dict_default
    dict_default = {}

    COLOR = ["0xFF8A4B08", "0xFFF7BE81"]
    # Creamos la lista de campos del infoLabel
    controls = [("title", "text", "Titolo:"),
                ("originaltitle", "text", "Titolo originale"),
                ("year", "text", "Anno"),
                ("identificadores", "label", "Identificatori:"),
                ("tmdb_id", "text", "    The Movie Database ID"),
                ("url_tmdb", "text", "        URL Tmdb", "+!eq(-1,'')"),
                ("tvdb_id", "text", "    The TVDB ID", "+eq(-7,'Serie')"),
                ("url_tvdb", "text", "        URL TVDB", "+!eq(-1,'')+eq(-8,'Serie')"),
                ("imdb_id", "text", "    IMDb ID"),
                ("otro_id", "text", "    Altro ID", "+eq(-1,'')"),
                ("urls", "label", "Immagini (urls):"),
                ("fanart", "text", "    Sfondo"),
                ("thumbnail", "text", "    Miniatura")]

    if item.infoLabels["mediatype"] == "movie":
        mediatype_default = 0
    else:
        mediatype_default = 1

    listado_controles = [{'id': "mediatype",
                          'type': "list",
                          'label': "Tipo di contenuto",
                          'color': COLOR[1],
                          'default': mediatype_default,
                          'enabled': True,
                          'visible': True,
                          'lvalues': ["Película", "Serie"]
                          }]

    for i, c in enumerate(controls):
        color = COLOR[0]
        dict_default[c[0]] = item.infoLabels.get(c[0], '')

        enabled = True

        if i > 0 and c[1] != 'label':
            color = COLOR[1]
            enabled = "!eq(-%s,'')" % i
            if len(c) > 3:
                enabled += c[3]

        # default para casos especiales
        if c[0] == "url_tmdb" and item.infoLabels["tmdb_id"] and 'tmdb' in item.infoLabels["url_scraper"]:
            dict_default[c[0]] = item.infoLabels["url_scraper"]

        elif c[0] == "url_tvdb" and item.infoLabels["tvdb_id"] and 'thetvdb.com' in item.infoLabels["url_scraper"]:
            dict_default[c[0]] = item.infoLabels["url_scraper"]

        if not dict_default[c[0]] or dict_default[c[0]] == 'None' or dict_default[c[0]] == 0:
            dict_default[c[0]] = ''
        elif isinstance(dict_default[c[0]], (int, float, long)):
            # Si es numerico lo convertimos en str
            dict_default[c[0]] = str(dict_default[c[0]])

        listado_controles.append({'id': c[0],
                                  'type': c[1],
                                  'label': c[2],
                                  'color': color,
                                  'default': dict_default[c[0]],
                                  'enabled': enabled,
                                  'visible': True})

    # logger.debug(dict_default)
    if platformtools.show_channel_settings(listado_controles, caption="Informazioni complete", item=item,
                                           callback="core.scraper.callback_cuadro_completar",
                                           custom_button={"visible": False}):
        return True

    else:
        return False
示例#25
0
def server_config(item):
    return platformtools.show_channel_settings(channelpath=filetools.join(config.get_runtime_path(), "servers",
                                                                          item.config))
示例#26
0
def configuracion(item):
    ret = platformtools.show_channel_settings()
    platformtools.itemlist_refresh()
    return ret
示例#27
0
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 = ['url',
                             'search',
                             'videolibrary',
                             'setting',
                             'news',
                             # 'help',
                             'downloads']

        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 channel.json tiene "settings",
        # pero por si acaso se deja
        excluded_channels = ['url',
                             'setting',
                             'help']

        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
                    list_controls, dict_settings = channeltools.get_channel_controls_settings(channel.channel)

                    if not list_controls:
                        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(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.json
                        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(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
示例#28
0
def autoplay_config(item):
    logger.info()
    global autoplay_node
    dict_values = {}
    list_controls = []
    channel_parameters = channeltools.get_channel_parameters(item.from_channel)
    channel_name = channel_parameters['title']

    if not autoplay_node:
        # Obtiene el nodo AUTOPLAY desde el json
        autoplay_node = jsontools.get_node_from_file('autoplay', 'AUTOPLAY')

    channel_node = autoplay_node.get(item.from_channel, {})
    settings_node = channel_node.get('settings', {})

    allow_option = True

    active_settings = {
        "id": "active",
        "label": config.get_localized_string(60079),
        "color": "0xffffff99",
        "type": "bool",
        "default": False,
        "enabled": allow_option,
        "visible": allow_option
    }
    list_controls.append(active_settings)
    dict_values['active'] = settings_node.get('active', False)

    # Idioma
    status_language = config.get_setting("filter_languages", item.from_channel)
    if not status_language:
        status_language = 0

    set_language = {
        "id": "language",
        "label": config.get_localized_string(60080),
        "color": "0xffffff99",
        "type": "list",
        "default": 0,
        "enabled": "eq(-1,true)",
        "visible": True,
        "lvalues": get_languages(item.from_channel)
    }

    list_controls.append(set_language)
    dict_values['language'] = status_language

    separador = {
        "id": "label",
        "label": "         "
        "_________________________________________________________________________________________",
        "type": "label",
        "enabled": True,
        "visible": True
    }
    list_controls.append(separador)

    # Seccion servidores favoritos
    server_list = channel_node.get("servers", [])
    if not server_list:
        enabled = False
        server_list = ["No disponible"]
    else:
        enabled = "eq(-3,true)"

    custom_servers_settings = {
        "id": "custom_servers",
        "label": config.get_localized_string(60081),
        "color": "0xff66ffcc",
        "type": "bool",
        "default": False,
        "enabled": enabled,
        "visible": True
    }
    list_controls.append(custom_servers_settings)
    if dict_values['active'] and enabled:
        dict_values['custom_servers'] = settings_node.get(
            'custom_servers', False)
    else:
        dict_values['custom_servers'] = False

    for num in range(1, 4):
        pos1 = num + 3
        default = num - 1
        if default > len(server_list) - 1:
            default = 0
        set_servers = {
            "id": "server_%s" % num,
            "label":
            u"          \u2665" + config.get_localized_string(60082) % num,
            "color": "0xfffcab14",
            "type": "list",
            "default": default,
            "enabled": "eq(-%s,true)+eq(-%s,true)" % (pos1, num),
            "visible": True,
            "lvalues": server_list
        }
        list_controls.append(set_servers)

        dict_values["server_%s" % num] = settings_node.get(
            "server_%s" % num, 0)
        if settings_node.get("server_%s" % num, 0) > len(server_list) - 1:
            dict_values["server_%s" % num] = 0

    # Seccion Calidades favoritas
    quality_list = channel_node.get("quality", [])
    if not quality_list:
        enabled = False
        quality_list = ["No disponible"]
    else:
        enabled = "eq(-7,true)"

    custom_quality_settings = {
        "id": "custom_quality",
        "label": config.get_localized_string(60083),
        "color": "0xff66ffcc",
        "type": "bool",
        "default": False,
        "enabled": enabled,
        "visible": True
    }
    list_controls.append(custom_quality_settings)
    if dict_values['active'] and enabled:
        dict_values['custom_quality'] = settings_node.get(
            'custom_quality', False)
    else:
        dict_values['custom_quality'] = False

    for num in range(1, 4):
        pos1 = num + 7
        default = num - 1
        if default > len(quality_list) - 1:
            default = 0

        set_quality = {
            "id": "quality_%s" % num,
            "label": u"          \u2665 Calidad Favorita %s" % num,
            "color": "0xfff442d9",
            "type": "list",
            "default": default,
            "enabled": "eq(-%s,true)+eq(-%s,true)" % (pos1, num),
            "visible": True,
            "lvalues": quality_list
        }
        list_controls.append(set_quality)
        dict_values["quality_%s" % num] = settings_node.get(
            "quality_%s" % num, 0)
        if settings_node.get("quality_%s" % num, 0) > len(quality_list) - 1:
            dict_values["quality_%s" % num] = 0

    # Plan B
    dict_values['plan_b'] = settings_node.get('plan_b', False)
    enabled = "eq(-4,true)|eq(-8,true)"
    plan_b = {
        "id": "plan_b",
        "label": config.get_localized_string(70172),
        "color": "0xffffff99",
        "type": "bool",
        "default": False,
        "enabled": enabled,
        "visible": True
    }
    list_controls.append(plan_b)

    # Seccion Prioridades
    priority_list = [
        config.get_localized_string(70174),
        config.get_localized_string(70175)
    ]
    set_priority = {
        "id": "priority",
        "label": config.get_localized_string(60085),
        "color": "0xffffff99",
        "type": "list",
        "default": 0,
        "enabled": True,
        "visible": "eq(-5,true)+eq(-9,true)+eq(-12,true)",
        "lvalues": priority_list
    }
    list_controls.append(set_priority)
    dict_values["priority"] = settings_node.get("priority", 0)

    # Abrir cuadro de dialogo
    platformtools.show_channel_settings(list_controls=list_controls,
                                        dict_values=dict_values,
                                        callback='save',
                                        item=item,
                                        caption='%s - AutoPlay' % channel_name,
                                        custom_button={
                                            'visible': True,
                                            'function': "reset",
                                            'close': True,
                                            'label': 'Reset'
                                        })
示例#29
0
def cuadro_completar(item):
    logger.debug()

    global dict_default
    dict_default = {}

    COLOR = ["0xFF65B3DA", "0xFFFFFFFF"]
    # We create the list of infoLabel fields
    controls = [("title", "text", config.get_localized_string(60230)),
                ("originaltitle", "text", config.get_localized_string(60231)),
                ("year", "text", config.get_localized_string(60232)),
                ("identificadores", "label", config.get_localized_string(60233)),
                ("tmdb_id", "text", config.get_localized_string(60234)),
                ("url_tmdb", "text", config.get_localized_string(60235), "+!eq(-1,'')"),
                ("tvdb_id", "text", config.get_localized_string(60236), "+eq(-7,'Serie')"),
                ("url_tvdb", "text", config.get_localized_string(60237), "+!eq(-1,'')+eq(-8,'Serie')"),
                ("imdb_id", "text", config.get_localized_string(60238)),
                ("otro_id", "text", config.get_localized_string(60239), "+eq(-1,'')"),
                ("urls", "label", config.get_localized_string(60240)),
                ("fanart", "text", config.get_localized_string(60241)),
                ("thumbnail", "text", config.get_localized_string(60242))]

    if item.infoLabels["mediatype"] == "movie":
        mediatype_default = 0
    else:
        mediatype_default = 1

    listado_controles = [{'id': "mediatype",
                          'type': "list",
                          'label': config.get_localized_string(60243),
                          'color': COLOR[1],
                          'default': mediatype_default,
                          'enabled': True,
                          'visible': True,
                          'lvalues': [config.get_localized_string(60244), config.get_localized_string(70136)]
                          }]

    for i, c in enumerate(controls):
        color = COLOR[0]
        dict_default[c[0]] = item.infoLabels.get(c[0], '')

        enabled = True

        if i > 0 and c[1] != 'label':
            color = COLOR[1]
            enabled = "!eq(-%s,'')" % i
            if len(c) > 3:
                enabled += c[3]

        # default for special cases
        if c[0] == "url_tmdb" and item.infoLabels["tmdb_id"] and 'tmdb' in item.infoLabels["url_scraper"]:
            dict_default[c[0]] = item.infoLabels["url_scraper"]

        elif c[0] == "url_tvdb" and item.infoLabels["tvdb_id"] and 'thetvdb.com' in item.infoLabels["url_scraper"]:
            dict_default[c[0]] = item.infoLabels["url_scraper"]

        if not dict_default[c[0]] or dict_default[c[0]] == 'None' or dict_default[c[0]] == 0:
            dict_default[c[0]] = ''
        elif isinstance(dict_default[c[0]], (int, float)) or (not PY3 and isinstance(dict_default[c[0]], (int, float, long))):
            # If it is numerical we convert it into str
            dict_default[c[0]] = str(dict_default[c[0]])

        listado_controles.append({'id': c[0],
                                  'type': c[1],
                                  'label': c[2],
                                  'color': color,
                                  'default': dict_default[c[0]],
                                  'enabled': enabled,
                                  'visible': True})

    # logger.debug(dict_default)
    if platformtools.show_channel_settings(list_controls=listado_controles, caption=config.get_localized_string(60246), item=item,
                                           callback="core.scraper.callback_cuadro_completar",
                                           custom_button={"visible": False}):
        return True

    else:
        return False
示例#30
0
def configuracion(item):
    from platformcode import platformtools
    ret = platformtools.show_channel_settings()
    platformtools.itemlist_refresh()
    return ret
示例#31
0
def filtro(item):
    logger.info("pelisalacarta.channels.cinefox filtro")

    list_controls = []
    valores = {}
    strings = {}
    # Se utilizan los valores por defecto/guardados o los del filtro personalizado
    if not item.values:
        valores_guardados = config.get_setting("filtro_defecto_" + item.extra,
                                               item.channel)
    else:
        valores_guardados = item.values
        item.values = ""

    dict_values = valores_guardados if valores_guardados else None
    if dict_values:
        dict_values["filtro_per"] = 0

    excluidos = ['País', 'Películas', 'Series', 'Destacar']
    data = scrapertools.downloadpage(item.url)
    matches = scrapertools.find_multiple_matches(
        data, '<div class="dropdown-sub[^>]+>(\S+)(.*?)</ul>')
    i = 0
    for filtro_title, values in matches:
        if filtro_title in excluidos: continue

        filtro_title = filtro_title.replace("Tendencia", "Ordenar por")
        id = filtro_title.replace("Género",
                                  "genero").replace("Año", "year").replace(
                                      " ", "_").lower()
        list_controls.append({
            'id': id,
            'label': filtro_title,
            'enabled': True,
            'type': 'list',
            'default': 0,
            'visible': True
        })
        valores[id] = []
        valores[id].append('')
        strings[filtro_title] = []
        list_controls[i]['lvalues'] = []
        if filtro_title == "Ordenar por":
            list_controls[i]['lvalues'].append('Más recientes')
            strings[filtro_title].append('Más recientes')
        else:
            list_controls[i]['lvalues'].append('Cualquiera')
            strings[filtro_title].append('Cualquiera')
        patron = '<li>.*?(?:genre|release|quality|language|order)=([^"]+)">([^<]+)<'
        matches_v = scrapertools.find_multiple_matches(values, patron)
        for value, key in matches_v:
            if value == "action-adventure": continue
            list_controls[i]['lvalues'].append(key)
            valores[id].append(value)
            strings[filtro_title].append(key)

        i += 1

    item.valores = valores
    item.strings = strings
    if "Filtro Personalizado" in item.title:
        return filtrado(item, valores_guardados)

    list_controls.append({
        'id': 'espacio',
        'label': '',
        'enabled': False,
        'type': 'label',
        'default': '',
        'visible': True
    })
    list_controls.append({
        'id': 'save',
        'label': 'Establecer como filtro por defecto',
        'enabled': True,
        'type': 'bool',
        'default': False,
        'visible': True
    })
    list_controls.append({
        'id':
        'filtro_per',
        'label':
        'Guardar filtro en acceso directo...',
        'enabled':
        True,
        'type':
        'list',
        'default':
        0,
        'visible':
        True,
        'lvalues': ['No guardar', 'Filtro 1', 'Filtro 2', 'Filtro 3']
    })
    list_controls.append({
        'id':
        'remove',
        'label':
        'Eliminar filtro personalizado...',
        'enabled':
        True,
        'type':
        'list',
        'default':
        0,
        'visible':
        True,
        'lvalues': ['No eliminar', 'Filtro 1', 'Filtro 2', 'Filtro 3']
    })

    from platformcode import platformtools
    return platformtools.show_channel_settings(list_controls=list_controls,
                                               dict_values=dict_values,
                                               caption="Filtra los resultados",
                                               item=item,
                                               callback='filtrado')
def cuadro_completar(item):
    logger.info()

    global dict_default
    dict_default = {}

    COLOR = ["0xFF8A4B08", "0xFFF7BE81"]
    # Creamos la lista de campos del infoLabel
    controls = [("title", "text", "Titolo:"),
                ("originaltitle", "text", "Titolo originale"),
                ("year", "text", "Anno"),
                ("identificadores", "label", "Identificatori:"),
                ("tmdb_id", "text", "    The Movie Database ID"),
                ("url_tmdb", "text", "        URL Tmdb", "+!eq(-1,'')"),
                ("tvdb_id", "text", "    The TVDB ID", "+eq(-7,'Serie')"),
                ("url_tvdb", "text", "        URL TVDB", "+!eq(-1,'')+eq(-8,'Serie')"),
                ("imdb_id", "text", "    IMDb ID"),
                ("otro_id", "text", "    Altro ID", "+eq(-1,'')"),
                ("urls", "label", "Immagini (urls):"),
                ("fanart", "text", "    Sfondo"),
                ("thumbnail", "text", "    Miniatura")]

    if item.infoLabels["mediatype"] == "movie":
        mediatype_default = 0
    else:
        mediatype_default = 1

    listado_controles = [{'id': "mediatype",
                          'type': "list",
                          'label': "Tipo di contenuto",
                          'color': COLOR[1],
                          'default': mediatype_default,
                          'enabled': True,
                          'visible': True,
                          'lvalues': ["Película", "Serie"]
                          }]

    for i, c in enumerate(controls):
        color = COLOR[0]
        dict_default[c[0]] = item.infoLabels.get(c[0], '')

        enabled = True

        if i > 0 and c[1] != 'label':
            color = COLOR[1]
            enabled = "!eq(-%s,'')" % i
            if len(c) > 3:
                enabled += c[3]

        # default para casos especiales
        if c[0] == "url_tmdb" and item.infoLabels["tmdb_id"] and 'tmdb' in item.infoLabels["url_scraper"]:
            dict_default[c[0]] = item.infoLabels["url_scraper"]

        elif c[0] == "url_tvdb" and item.infoLabels["tvdb_id"] and 'thetvdb.com' in item.infoLabels["url_scraper"]:
            dict_default[c[0]] = item.infoLabels["url_scraper"]

        if not dict_default[c[0]] or dict_default[c[0]] == 'None' or dict_default[c[0]] == 0:
            dict_default[c[0]] = ''
        elif isinstance(dict_default[c[0]], (int, float, long)):
            # Si es numerico lo convertimos en str
            dict_default[c[0]] = str(dict_default[c[0]])

        listado_controles.append({'id': c[0],
                                  'type': c[1],
                                  'label': c[2],
                                  'color': color,
                                  'default': dict_default[c[0]],
                                  'enabled': enabled,
                                  'visible': True})

    # logger.debug(dict_default)
    if platformtools.show_channel_settings(listado_controles, caption="Informazioni complete", item=item,
                                           callback="core.scraper.callback_cuadro_completar",
                                           custom_button={"visible": False}):
        return True

    else:
        return False
def config_filter(item):
    """
    muestra una serie filtrada para su configuración

    :param item: item
    :type item: Item
    """
    logger.info("[filtertools.py] config_filter")
    logger.info("item {0}".format(item.tostring()))

    # OBTENEMOS LOS DATOS DEL JSON
    dict_series = get_filtered_tvshows(item.from_channel)

    tvshow = item.show.lower().strip()

    lang_selected = dict_series.get(tvshow, {}).get(TAG_LANGUAGE, 'Español')
    list_quality = dict_series.get(tvshow, {}).get(TAG_QUALITY_NOT_ALLOWED, "")
    # logger.info("lang selected {}".format(lang_selected))
    # logger.info("list quality {}".format(list_quality))

    active = True
    custom_method = ""
    allow_option = False
    if item.show.lower().strip() in dict_series:
        allow_option = True
        custom_method = "borrar_filtro"
        active = dict_series.get(item.show.lower().strip(), {}).get(TAG_ACTIVE, False)

    list_controls = []

    if allow_option:
        active_control = {
            "id": "active",
            "type": "bool",
            "label": "¿Activar/Desactivar filtro?",
            "color": "",
            "default": active,
            "enabled": allow_option,
            "visible": allow_option,
        }
        list_controls.append(active_control)

    language_option = {
        "id": "language",
        "type": "list",
        "label": "Idioma",
        "color": "0xFFee66CC",
        "default": item.list_idiomas.index(lang_selected),
        "enabled": True,
        "visible": True,
        "lvalues": item.list_idiomas
    }
    list_controls.append(language_option)

    if item.list_calidad:
        list_controls_calidad = [
            {
                "id": "textoCalidad",
                "type": "label",
                "label": "Calidad NO permitida",
                "color": "0xffC6C384",
                "enabled": True,
                "visible": True,
            },
        ]
        for element in sorted(item.list_calidad, key=str.lower):
            list_controls_calidad.append({
                "id": element,
                "type": "bool",
                "label": element,
                "default": (False, True)[element.lower() in list_quality],
                "enabled": True,
                "visible": True,
            })

        # concatenamos list_controls con list_controls_calidad
        list_controls.extend(list_controls_calidad)

    custom_button = {'name': 'Borrar', 'method': custom_method}

    platformtools.show_channel_settings(list_controls=list_controls, callback='guardar_valores', item=item,
                                        caption="Filtrado de enlaces para: [COLOR blue]{0}[/COLOR]".format(item.show),
                                        custom_button=custom_button)
示例#34
0
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"))
示例#35
0
def settingCanal(item):

    if config.OLD_PLATFORM:
        config.open_settings()
    else:
        return platformtools.show_channel_settings()
示例#36
0
def config_item(item):
    """
    displays a filtered series for your setup

    @param item: item
    @type item: Item
    """
    logger.info()
    logger.info("item %s" % item.tostring())

    # WE GET THE JSON DATA
    dict_series = jsontools.get_node_from_file(item.from_channel,
                                               TAG_TVSHOW_FILTER)

    tvshow = item.show.lower().strip()
    default_lang = ''

    channel_parameters = channeltools.get_channel_parameters(item.from_channel)
    list_language = channel_parameters["filter_languages"]
    try:
        if channel_parameters["filter_languages"] != '' and len(
                list_language) > 0:
            default_lang = list_language[1]
    except:
        pass

    if default_lang == '':
        platformtools.dialog_notification("FilterTools",
                                          "There are no defined languages")
        return
    else:
        lang_selected = dict_series.get(tvshow,
                                        {}).get(TAG_LANGUAGE, default_lang)
        list_quality = dict_series.get(tvshow, {}).get(
            TAG_QUALITY_ALLOWED, [x.lower() for x in item.list_quality])
        # logger.info("lang selected {}".format(lang_selected))
        # logger.info("list quality {}".format(list_quality))

        active = True
        custom_button = {'visible': False}
        allow_option = False
        if item.show.lower().strip() in dict_series:
            allow_option = True
            active = dict_series.get(item.show.lower().strip(),
                                     {}).get(TAG_ACTIVE, False)
            custom_button = {
                'label': config.get_localized_string(60437),
                'function': 'delete',
                'visible': True,
                'close': True
            }

        list_controls = []

        if allow_option:
            active_control = {
                "id": "active",
                "type": "bool",
                "label": config.get_localized_string(60438),
                "color": "",
                "default": active,
                "enabled": allow_option,
                "visible": allow_option,
            }
            list_controls.append(active_control)

        language_option = {
            "id": "language",
            "type": "list",
            "label": config.get_localized_string(60439),
            # "color": "0xFFee66CC",
            "default": item.list_language.index(lang_selected),
            "enabled": True,
            "visible": True,
            "lvalues": item.list_language
        }
        list_controls.append(language_option)

        if item.list_quality:
            list_controls_calidad = [
                {
                    "id": "textoCalidad",
                    "type": "label",
                    "label": "Calidad permitida",
                    "color": "0xffC6C384",
                    "enabled": True,
                    "visible": True,
                },
            ]
            for element in sorted(item.list_quality, key=str.lower):
                list_controls_calidad.append({
                    "id":
                    element,
                    "type":
                    "bool",
                    "label":
                    element,
                    "default": (False, True)[element.lower() in list_quality],
                    "enabled":
                    True,
                    "visible":
                    True,
                })

            # we concatenate list_controls with list_controls_quality
            list_controls.extend(list_controls_calidad)

        title = config.get_localized_string(60441) % (COLOR.get(
            "selected", "auto"), item.show)

        platformtools.show_channel_settings(list_controls=list_controls,
                                            callback='save',
                                            item=item,
                                            caption=title,
                                            custom_button=custom_button)
示例#37
0
文件: kbagi.py 项目: vguardiola/addon
def filtro(item):
    logger.info()

    list_controls = []
    valores = {}

    dict_values = None
    list_controls.append({
        'id': 'search',
        'label': 'Texto a buscar',
        'enabled': True,
        'color': '0xFFC52020',
        'type': 'text',
        'default': '',
        'visible': True
    })
    list_controls.append({
        'id': 'tipo',
        'label': 'Tipo de búsqueda',
        'enabled': True,
        'color': '0xFFFF8000',
        'type': 'list',
        'default': -1,
        'visible': True
    })
    list_controls[1]['lvalues'] = [
        'Aplicación', 'Archivo', 'Documento', 'Imagen', 'Música', 'Vídeo',
        'Todos'
    ]
    valores['tipo'] = [
        'Application', 'Archive', 'Document', 'Image', 'Music', 'Video', ''
    ]

    list_controls.append({
        'id': 'ext',
        'label': 'Extensión',
        'enabled': True,
        'color': '0xFFF4FA58',
        'type': 'text',
        'default': '',
        'visible': True
    })
    list_controls.append({
        'id': 'tmin',
        'label': 'Tamaño mínimo (MB)',
        'enabled': True,
        'color': '0xFFCC2EFA',
        'type': 'text',
        'default': '0',
        'visible': True
    })
    list_controls.append({
        'id': 'tmax',
        'label': 'Tamaño máximo (MB)',
        'enabled': True,
        'color': '0xFF2ECCFA',
        'type': 'text',
        'default': '0',
        'visible': True
    })

    # Se utilizan los valores por defecto/guardados
    web = "kbagi"
    if "diskokosmiko" in item.extra:
        web = "diskokosmiko"
    valores_guardados = config.get_setting("filtro_defecto_" + web,
                                           item.channel)
    if valores_guardados:
        dict_values = valores_guardados
    item.valores = valores
    from platformcode import platformtools
    return platformtools.show_channel_settings(list_controls=list_controls,
                                               dict_values=dict_values,
                                               caption="Filtra la búsqueda",
                                               item=item,
                                               callback='filtrado')
示例#38
0
def filtro(item):
    logger.info("pelisalacarta.channels.cinefox filtro")
    
    list_controls = []
    valores = {}
    strings = {}
    # Se utilizan los valores por defecto/guardados o los del filtro personalizado
    if not item.values:
        valores_guardados = config.get_setting("filtro_defecto_" + item.extra, item.channel)
    else:
        valores_guardados = item.values
        item.values = ""

    dict_values = valores_guardados if valores_guardados else None
    if dict_values:
        dict_values["filtro_per"] = 0
    
    excluidos = ['País', 'Películas', 'Series', 'Destacar']
    data = scrapertools.downloadpage(item.url)
    matches = scrapertools.find_multiple_matches(data, '<div class="dropdown-sub[^>]+>(\S+)(.*?)</ul>')
    i = 0
    for filtro_title, values in matches:
        if filtro_title in excluidos: continue

        filtro_title = filtro_title.replace("Tendencia", "Ordenar por")
        id = filtro_title.replace("Género", "genero").replace("Año", "year").replace(" ", "_").lower()
        list_controls.append({'id': id, 'label': filtro_title, 'enabled': True,
                              'type': 'list', 'default': 0, 'visible': True})
        valores[id] = []
        valores[id].append('')
        strings[filtro_title] = []
        list_controls[i]['lvalues'] = []
        if filtro_title == "Ordenar por":
            list_controls[i]['lvalues'].append('Más recientes')
            strings[filtro_title].append('Más recientes')
        else:
            list_controls[i]['lvalues'].append('Cualquiera')
            strings[filtro_title].append('Cualquiera')
        patron = '<li>.*?(?:genre|release|quality|language|order)=([^"]+)">([^<]+)<'
        matches_v = scrapertools.find_multiple_matches(values, patron)
        for value, key in matches_v:
            if value == "action-adventure": continue
            list_controls[i]['lvalues'].append(key)
            valores[id].append(value)
            strings[filtro_title].append(key)

        i += 1

    item.valores = valores
    item.strings = strings
    if "Filtro Personalizado" in item.title:
        return filtrado(item, valores_guardados)

    list_controls.append({'id': 'espacio', 'label': '', 'enabled': False,
                          'type': 'text', 'default': '', 'visible': True})
    list_controls.append({'id': 'save', 'label': 'Establecer como filtro por defecto', 'enabled': True,
                          'type': 'bool', 'default': False, 'visible': True})
    list_controls.append({'id': 'filtro_per', 'label': 'Guardar filtro en acceso directo...', 'enabled': True,
                          'type': 'list', 'default': 0, 'visible': True, 'lvalues': ['No guardar', 'Filtro 1',
                                                                                     'Filtro 2', 'Filtro 3']})
    list_controls.append({'id': 'remove', 'label': 'Eliminar filtro personalizado...', 'enabled': True,
                          'type': 'list', 'default': 0, 'visible': True, 'lvalues': ['No eliminar', 'Filtro 1',
                                                                                     'Filtro 2', 'Filtro 3']})

    from platformcode import platformtools
    return platformtools.show_channel_settings(list_controls=list_controls, dict_values=dict_values,
                                               caption="Filtra los resultados", item=item, callback='filtrado')
示例#39
0
def configuracion(item):
    from platformcode import platformtools
    ret = platformtools.show_channel_settings()
    platformtools.itemlist_refresh()
    return ret
示例#40
0
def configuracion(item):
    from platformcode import platformtools
    platformtools.show_channel_settings()
    if config.is_xbmc():
        import xbmc
        xbmc.executebuiltin("Container.Refresh")
示例#41
0
def filtro(item):
    logger.info()

    list_controls = []
    valores = {}
    strings = {}
    # Se utilizan los valores por defecto/guardados o los del filtro personalizado
    if not item.values:
        valores_guardados = config.get_setting("filtro_defecto_peliculas",
                                               item.channel)
    else:
        valores_guardados = item.values
        item.values = ""

    if valores_guardados:
        dict_values = valores_guardados
    else:
        dict_values = None
    if dict_values:
        dict_values["filtro_per"] = 0

    list_controls.append({
        'id': 'texto',
        'label': 'Cadena de búsqueda',
        'enabled': True,
        'type': 'text',
        'default': '',
        'visible': True
    })
    data = httptools.downloadpage(item.url).data
    data = re.sub(r"\n|\r|\t|\s{2}|&nbsp;", "", data)
    matches = scrapertools.find_multiple_matches(
        data, 'option value="">([^<]+)</option>(.*?)</select>')
    i = 1
    for filtro_title, values in matches:
        id = filtro_title.replace("A\xc3\xb1o", "year").lower()
        filtro_title = filtro_title.replace("A\xc3\xb1o", "Año")
        list_controls.append({
            'id': id,
            'label': filtro_title,
            'enabled': True,
            'type': 'list',
            'default': 0,
            'visible': True
        })
        valores[id] = []
        valores[id].append('')
        strings[filtro_title] = []
        list_controls[i]['lvalues'] = []
        list_controls[i]['lvalues'].append('Cualquiera')
        strings[filtro_title].append('Cualquiera')
        patron = '<option value="([^"]+)">([^<]+)</option>'
        matches_v = scrapertools.find_multiple_matches(values, patron)
        for value, key in matches_v:
            list_controls[i]['lvalues'].append(key)
            valores[id].append(value)
            strings[filtro_title].append(key)

        i += 1

    item.valores = valores
    item.strings = strings
    if "Filtro Personalizado" in item.title:
        return filtrado(item, valores_guardados)

    list_controls.append({
        'id': 'espacio',
        'label': '',
        'enabled': False,
        'type': 'label',
        'default': '',
        'visible': True
    })
    list_controls.append({
        'id': 'save',
        'label': 'Establecer como filtro por defecto',
        'enabled': True,
        'type': 'bool',
        'default': False,
        'visible': True
    })
    list_controls.append({
        'id':
        'filtro_per',
        'label':
        'Guardar filtro en acceso directo...',
        'enabled':
        True,
        'type':
        'list',
        'default':
        0,
        'visible':
        True,
        'lvalues': ['No guardar', 'Filtro 1', 'Filtro 2', 'Filtro 3']
    })
    list_controls.append({
        'id':
        'remove',
        'label':
        'Eliminar filtro personalizado...',
        'enabled':
        True,
        'type':
        'list',
        'default':
        0,
        'visible':
        True,
        'lvalues': ['No eliminar', 'Filtro 1', 'Filtro 2', 'Filtro 3']
    })

    from platformcode import platformtools
    return platformtools.show_channel_settings(list_controls=list_controls,
                                               dict_values=dict_values,
                                               caption="Filtra los resultados",
                                               item=item,
                                               callback='filtrado')
示例#42
0
def filtro(item):
    logger.info()
    
    list_controls = []
    valores = {}
    strings = {}
    # Se utilizan los valores por defecto/guardados o los del filtro personalizado
    if not item.values:
        valores_guardados = config.get_setting("filtro_defecto_peliculas", item.channel)
    else:
        valores_guardados = item.values
        item.values = ""

    if valores_guardados:
      dict_values = valores_guardados
    else:
      dict_values = None
    if dict_values:
        dict_values["filtro_per"] = 0
    
    list_controls.append({'id': 'texto', 'label': 'Cadena de búsqueda', 'enabled': True,
                          'type': 'text', 'default': '', 'visible': True})
    data = httptools.downloadpage(item.url).data
    data = re.sub(r"\n|\r|\t|\s{2}|&nbsp;", "", data)
    matches = scrapertools.find_multiple_matches(data, 'option value="">([^<]+)</option>(.*?)</select>')
    i = 1
    for filtro_title, values in matches:
        id = filtro_title.replace("A\xc3\xb1o", "year").lower()
        filtro_title = filtro_title.replace("A\xc3\xb1o", "Año")
        list_controls.append({'id': id, 'label': filtro_title, 'enabled': True,
                              'type': 'list', 'default': 0, 'visible': True})
        valores[id] = []
        valores[id].append('')
        strings[filtro_title] = []
        list_controls[i]['lvalues'] = []
        list_controls[i]['lvalues'].append('Cualquiera')
        strings[filtro_title].append('Cualquiera')
        patron = '<option value="([^"]+)">([^<]+)</option>'
        matches_v = scrapertools.find_multiple_matches(values, patron)
        for value, key in matches_v:
            list_controls[i]['lvalues'].append(key)
            valores[id].append(value)
            strings[filtro_title].append(key)

        i += 1

    item.valores = valores
    item.strings = strings
    if "Filtro Personalizado" in item.title:
        return filtrado(item, valores_guardados)

    list_controls.append({'id': 'espacio', 'label': '', 'enabled': False,
                          'type': 'label', 'default': '', 'visible': True})
    list_controls.append({'id': 'save', 'label': 'Establecer como filtro por defecto', 'enabled': True,
                          'type': 'bool', 'default': False, 'visible': True})
    list_controls.append({'id': 'filtro_per', 'label': 'Guardar filtro en acceso directo...', 'enabled': True,
                          'type': 'list', 'default': 0, 'visible': True, 'lvalues': ['No guardar', 'Filtro 1',
                                                                                     'Filtro 2', 'Filtro 3']})
    list_controls.append({'id': 'remove', 'label': 'Eliminar filtro personalizado...', 'enabled': True,
                          'type': 'list', 'default': 0, 'visible': True, 'lvalues': ['No eliminar', 'Filtro 1',
                                                                                     'Filtro 2', 'Filtro 3']})

    from platformcode import platformtools
    return platformtools.show_channel_settings(list_controls=list_controls, dict_values=dict_values,
                                               caption="Filtra los resultados", item=item, callback='filtrado')
示例#43
0
文件: hdfull.py 项目: xvacat/addon
def settingCanal(item):
    platformtools.show_channel_settings()
    #platformtools.itemlist_refresh()
    return
示例#44
0
def settings(item):
    return platformtools.show_channel_settings()
示例#45
0
def settings(item):
    ret = platformtools.show_channel_settings(
        caption="configuración -- Descargas")
    platformtools.itemlist_refresh()
    return ret
示例#46
0
def channel_config(item):
    return platformtools.show_channel_settings(channelpath=os.path.join(config.get_runtime_path(),"channels", item.channel))
示例#47
0
def config_item(item):
    """
    muestra una serie filtrada para su configuración

    :param item: item
    :type item: Item
    """
    logger.info()
    logger.info("item {0}".format(item.tostring()))

    # OBTENEMOS LOS DATOS DEL JSON
    dict_series = get_tvshows(item.from_channel)

    tvshow = item.show.lower().strip()

    lang_selected = dict_series.get(tvshow, {}).get(TAG_LANGUAGE, 'Español')
    list_quality = dict_series.get(tvshow, {}).get(TAG_QUALITY_NOT_ALLOWED, "")
    # logger.info("lang selected {}".format(lang_selected))
    # logger.info("list quality {}".format(list_quality))

    active = True
    custom_button = {'visible': False}
    allow_option = False
    if item.show.lower().strip() in dict_series:
        allow_option = True
        active = dict_series.get(item.show.lower().strip(), {}).get(TAG_ACTIVE, False)
        custom_button = {'label': 'Borrar', 'function': 'borrar_filtro', 'visible': True, 'close': True}

    list_controls = []

    if allow_option:
        active_control = {
            "id": "active",
            "type": "bool",
            "label": "¿Activar/Desactivar filtro?",
            "color": "",
            "default": active,
            "enabled": allow_option,
            "visible": allow_option,
        }
        list_controls.append(active_control)

    language_option = {
        "id": "language",
        "type": "list",
        "label": "Idioma",
        "color": "0xFFee66CC",
        "default": item.list_idiomas.index(lang_selected),
        "enabled": True,
        "visible": True,
        "lvalues": item.list_idiomas
    }
    list_controls.append(language_option)

    if item.list_calidad:
        list_controls_calidad = [
            {
                "id": "textoCalidad",
                "type": "label",
                "label": "Calidad NO permitida",
                "color": "0xffC6C384",
                "enabled": True,
                "visible": True,
            },
        ]
        for element in sorted(item.list_calidad, key=str.lower):
            list_controls_calidad.append({
                "id": element,
                "type": "bool",
                "label": element,
                "default": (False, True)[element.lower() in list_quality],
                "enabled": True,
                "visible": True,
            })

        # concatenamos list_controls con list_controls_calidad
        list_controls.extend(list_controls_calidad)

    title = "Filtrado de enlaces para: [COLOR {0}]{1}[/COLOR]".format(COLOR.get("selected", "auto"), item.show)

    platformtools.show_channel_settings(list_controls=list_controls, callback='guardar_valores', item=item,
                                        caption=title, custom_button=custom_button)