예제 #1
0
def delete(item, dict_values):
    logger.info()

    if item:
        dict_series = filetools.get_node_from_data_json(
            item.from_channel, TAG_TVSHOW_FILTER)
        tvshow = item.show.strip().lower()

        heading = "¿Está seguro que desea eliminar el filtro?"
        line1 = "Pulse 'Si' para eliminar el filtro de [COLOR %s]%s[/COLOR], pulse 'No' o cierre la ventana para " \
                "no hacer nada." % (COLOR.get("selected", "auto"), item.show.strip())

        if platformtools.dialog_yesno(heading, line1) == 1:
            lang_selected = dict_series.get(tvshow, {}).get(TAG_LANGUAGE, "")
            dict_series.pop(tvshow, None)

            fname, json_data = filetools.update_json_data(
                dict_series, item.from_channel, TAG_TVSHOW_FILTER)
            result = filetools.write(fname, json_data)

            sound = False
            if result:
                message = "FILTRO ELIMINADO"
            else:
                message = "Error al guardar en disco"
                sound = True

            heading = "%s [%s]" % (item.show.strip(), lang_selected)
            platformtools.dialog_notification(heading, message, sound=sound)

            if item.action in ["findvideos", "play"]:
                platformtools.itemlist_refresh()
예제 #2
0
def save_from_context(item):
    """
    Salva el filtro a través del menú contextual

    @param item: item
    @type item: item
    """
    logger.info()

    dict_series = filetools.get_node_from_data_json(item.from_channel, TAG_TVSHOW_FILTER)
    tvshow = item.show.strip().lower()

    dict_filter = {TAG_NAME: item.show, TAG_ACTIVE: True, TAG_LANGUAGE: item.language, TAG_QUALITY_ALLOWED: []}
    dict_series[tvshow] = dict_filter

    fname, json_data = filetools.update_json_data(dict_series, item.from_channel, TAG_TVSHOW_FILTER)
    result = filetools.write(fname, json_data)

    sound = False
    if result:
        message = "FILTRO GUARDADO"
    else:
        message = "Error al guardar en disco"
        sound = True

    heading = "%s [%s]" % (item.show.strip(), item.language)
    platformtools.dialog_notification(heading, message, sound=sound)

    if item.from_action in ["findvideos", "play"]:
        platformtools.itemlist_refresh()
예제 #3
0
def delete_from_context(item):
    """
    Elimina el filtro a través del menú contextual

    @param item: item
    @type item: item
    """
    logger.info()

    # venimos desde get_links y no se ha obtenido ningún resultado, en menu contextual y damos a borrar
    if item.to_channel != "":
        item.from_channel = item.to_channel

    dict_series = filetools.get_node_from_data_json(item.from_channel, TAG_TVSHOW_FILTER)
    tvshow = item.show.strip().lower()

    lang_selected = dict_series.get(tvshow, {}).get(TAG_LANGUAGE, "")
    dict_series.pop(tvshow, None)

    fname, json_data = filetools.update_json_data(dict_series, item.from_channel, TAG_TVSHOW_FILTER)
    result = filetools.write(fname, json_data)

    sound = False
    if result:
        message = "FILTRO ELIMINADO"
    else:
        message = "Error al guardar en disco"
        sound = True

    heading = "%s [%s]" % (item.show.strip(), lang_selected)
    platformtools.dialog_notification(heading, message, sound=sound)

    if item.from_action in ["findvideos", "play", "no_filter"]:  # 'no_filter' es el mismo caso que L#601
        platformtools.itemlist_refresh()
예제 #4
0
def save(item, dict_data_saved):
    """
    Guarda los valores configurados en la ventana

    @param item: item
    @type item: Item
    @param dict_data_saved: diccionario con los datos salvados
    @type dict_data_saved: dict
    """
    logger.info()

    if item and dict_data_saved:
        logger.debug('item: %s\ndatos: %s' %
                     (item.tostring(), dict_data_saved))

        if item.from_channel == "biblioteca":
            item.from_channel = item.contentChannel
        dict_series = filetools.get_node_from_data_json(
            item.from_channel, TAG_TVSHOW_FILTER)
        tvshow = item.show.strip().lower()

        logger.info("Se actualiza los datos")

        list_quality = []
        for _id, value in dict_data_saved.items():
            if _id in item.list_quality and value:
                list_quality.append(_id.lower())

        lang_selected = item.list_language[dict_data_saved[TAG_LANGUAGE]]
        dict_filter = {
            TAG_NAME: item.show,
            TAG_ACTIVE: dict_data_saved.get(TAG_ACTIVE, True),
            TAG_LANGUAGE: lang_selected,
            TAG_QUALITY_ALLOWED: list_quality
        }
        dict_series[tvshow] = dict_filter

        fname, json_data = filetools.update_json_data(dict_series,
                                                      item.from_channel,
                                                      TAG_TVSHOW_FILTER)
        result = filetools.write(fname, json_data)

        sound = False
        if result:
            message = "FILTRO GUARDADO"
        else:
            message = "Error al guardar en disco"
            sound = True

        heading = "%s [%s]" % (item.show.strip(), lang_selected)
        platformtools.dialog_notification(heading, message, sound=sound)

        if item.from_action in ["findvideos", "play"]:
            platformtools.itemlist_refresh()
예제 #5
0
def upgrade_version(channel, list_quality):

    if channel in ['seriesblanco', 'seriesdanko', 'seriespapaya']:
        if not config.get_setting("var_temp_filtertools_v2_%s" % channel):
            dict_series = filetools.get_node_from_data_json(channel, TAG_TVSHOW_FILTER)

            if dict_series:
                # Informamos al usuario
                platformtools.dialog_notification("Espere por favor", "Actualizando filtros al nuevo formato")

                # Hacemos backup del fichero
                original = filetools.join(config.get_data_path(), "settings_channels", channel + "_data.json")
                backup = filetools.join(config.get_data_path(), "settings_channels", channel + "_data.bk_ft")
                filetools.copy(original, backup)

                try:
                    for serie in dict_series.keys():

                        logger.debug("serie %s" % serie)
                        quality_not_allowed = dict_series[serie]["quality_not_allowed"]
                        # Eliminamos el nodo antiguo
                        dict_series[serie].pop("quality_not_allowed", None)

                        # ponemos en minúsculas
                        quality_allowed = [x.lower() for x in list_quality]

                        for quality in quality_not_allowed:
                            if quality in quality_allowed:
                                quality_allowed.remove(quality)

                        # añadimos el nuevo nodo con los datos correctos
                        dict_series[serie][TAG_QUALITY_ALLOWED] = quality_allowed

                    fname, json_data = filetools.update_json_data(dict_series, channel, TAG_TVSHOW_FILTER)
                    result = filetools.write(fname, json_data)

                except:
                    logger.error("Se ha producido un error al convertir los filtros")
                    logger.error("Debe suministrar el fichero '%s'" % backup)
                    result = False

                if result:
                    message = "Conversión correcta"
                    config.set_setting("var_temp_filtertools_v2_%s" % channel, "s")
                else:
                    message = "Error, reporte en el foro"

                heading = "Proceso terminado"
                platformtools.dialog_notification(heading, message)

            else:
                config.set_setting("var_temp_filtertools_v2_%s" % channel, "s")