Update filtertools.py

This commit is contained in:
Alfa
2018-05-29 16:10:21 -05:00
committed by GitHub
parent 3f03905f4d
commit b210b06b26
+73 -59
View File
@@ -7,6 +7,7 @@ from core import jsontools
from core.item import Item from core.item import Item
from platformcode import config, logger from platformcode import config, logger
from platformcode import platformtools from platformcode import platformtools
from core import channeltools
TAG_TVSHOW_FILTER = "TVSHOW_FILTER" TAG_TVSHOW_FILTER = "TVSHOW_FILTER"
TAG_NAME = "name" TAG_NAME = "name"
@@ -405,74 +406,87 @@ def config_item(item):
dict_series = jsontools.get_node_from_file(item.from_channel, TAG_TVSHOW_FILTER) dict_series = jsontools.get_node_from_file(item.from_channel, TAG_TVSHOW_FILTER)
tvshow = item.show.lower().strip() tvshow = item.show.lower().strip()
default_lang = ''
lang_selected = dict_series.get(tvshow, {}).get(TAG_LANGUAGE, 'Español') channel_parameters = channeltools.get_channel_parameters(item.from_channel)
list_quality = dict_series.get(tvshow, {}).get(TAG_QUALITY_ALLOWED, [x.lower() for x in item.list_quality]) list_language = channel_parameters["filter_languages"]
# logger.info("lang selected {}".format(lang_selected)) try:
# logger.info("list quality {}".format(list_quality)) if channel_parameters["filter_languages"] != '' and len(list_language) > 0:
default_lang = list_language[1]
except:
pass
active = True if default_lang == '':
custom_button = {'visible': False} platformtools.dialog_notification("FilterTools", "No hay idiomas definidos")
allow_option = False return
if item.show.lower().strip() in dict_series: else:
allow_option = True lang_selected = dict_series.get(tvshow, {}).get(TAG_LANGUAGE, default_lang)
active = dict_series.get(item.show.lower().strip(), {}).get(TAG_ACTIVE, False) list_quality = dict_series.get(tvshow, {}).get(TAG_QUALITY_ALLOWED, [x.lower() for x in item.list_quality])
custom_button = {'label': 'Borrar', 'function': 'delete', 'visible': True, 'close': True} # logger.info("lang selected {}".format(lang_selected))
# logger.info("list quality {}".format(list_quality))
list_controls = [] 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}
if allow_option: list_controls = []
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 = { if allow_option:
"id": "language", active_control = {
"type": "list", "id": "active",
"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", "type": "bool",
"label": element, "label": "¿Activar/Desactivar filtro?",
"default": (False, True)[element.lower() in list_quality], "color": "",
"enabled": True, "default": active,
"visible": True, "enabled": allow_option,
}) "visible": allow_option,
}
list_controls.append(active_control)
# concatenamos list_controls con list_controls_calidad language_option = {
list_controls.extend(list_controls_calidad) "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)
title = "Filtrado de enlaces para: [COLOR %s]%s[/COLOR]" % (COLOR.get("selected", "auto"), item.show) 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,
})
platformtools.show_channel_settings(list_controls=list_controls, callback='save', item=item, # concatenamos list_controls con list_controls_calidad
caption=title, custom_button=custom_button) 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)
def delete(item, dict_values): def delete(item, dict_values):