From 435902fea60774c17d28ede65e13ffe7dafff8bc Mon Sep 17 00:00:00 2001
From: alaquepasa <39385022+alaquepasa@users.noreply.github.com>
Date: Sat, 26 May 2018 17:50:28 +0200
Subject: [PATCH] =?UTF-8?q?A=C3=B1adir=20opci=C3=B3n=20para=20reduir=20el?=
=?UTF-8?q?=20item=20en=20context?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Se añade una opción que permite activar o desactivar (por defecto desactivado)
la posibilidad de generar Items con menos elementos en el método de set_context_menu.
Esto genera un speedup considerable (aprox 2x) y parece que no daña mucho las funcionalidades
actuales al realizar este filtrado.
---
.../platformcode/platformtools.py | 42 ++++++++++++++++++-
.../resources/language/Spanish/strings.po | 4 ++
plugin.video.alfa/resources/settings.xml | 1 +
3 files changed, 45 insertions(+), 2 deletions(-)
diff --git a/plugin.video.alfa/platformcode/platformtools.py b/plugin.video.alfa/platformcode/platformtools.py
index 7c934e31..88866089 100644
--- a/plugin.video.alfa/platformcode/platformtools.py
+++ b/plugin.video.alfa/platformcode/platformtools.py
@@ -372,6 +372,44 @@ def set_context_commands(item, parent_item):
else:
context = []
+ if config.get_setting("faster_item_serialization"):
+ # logger.info("Reducing serialization!")
+ itemBK = item
+ item = Item()
+ item.action = itemBK.action
+ item.channel = itemBK.channel
+ infoLabels = {}
+ if itemBK.infoLabels["year"]: infoLabels["year"] = itemBK.infoLabels["year"]
+ if itemBK.infoLabels["imdb_id"]: infoLabels["imdb_id"] = itemBK.infoLabels["imdb_id"]
+ if itemBK.infoLabels["tmdb_id"]: infoLabels["tmdb_id"] = itemBK.infoLabels["tmdb_id"]
+ if itemBK.infoLabels["tvdb_id"]: infoLabels["tvdb_id"] = itemBK.infoLabels["tvdb_id"]
+ if itemBK.infoLabels["noscrap_id"]: infoLabels["noscrap_id"] = itemBK.infoLabels["noscrap_id"]
+ if len(infoLabels) > 0: item.infoLabels = infoLabels
+
+ if itemBK.thumbnail: item.thumbnail = itemBK.thumbnail
+ if itemBK.extra: item.extra = itemBK.extra
+ if itemBK.contentEpisodeNumber: item.contentEpisodeNumber = itemBK.contentEpisodeNumber
+ if itemBK.contentEpisodeTitle: item.contentEpisodeTitle = itemBK.contentEpisodeTitle
+ if itemBK.contentPlot: item.contentPlot = itemBK.contentPlot
+ if itemBK.contentQuality: item.contentQuality = itemBK.contentQuality
+ if itemBK.contentSeason: item.contentSeason = itemBK.contentSeason
+ if itemBK.contentSerieName: item.contentSerieName = itemBK.contentSerieName
+ if itemBK.contentThumbnail: item.contentThumbnail = itemBK.contentThumbnail
+ if itemBK.contentTitle: item.contentTitle = itemBK.contentTitle
+ if itemBK.contentType: item.contentType = itemBK.contentType
+ if itemBK.duration: item.duration = itemBK.duration
+ if itemBK.fulltitle: item.fulltitle = itemBK.fulltitle
+ if itemBK.plot: item.plot = itemBK.plot
+ if itemBK.quality: item.quality = itemBK.quality
+ if itemBK.show: item.show = itemBK.show
+ if itemBK.title: item.title = itemBK.title
+ if itemBK.viewcontent: item.viewcontent = itemBK.viewcontent
+
+ # itemJson = item.tojson()
+ # logger.info("Elemento: {0} bytes".format(len(itemJson)))
+ # logger.info(itemJson)
+ # logger.info("--------------------------------------------------------------")
+
# Opciones segun item.context
for command in context:
# Predefinidos
@@ -507,14 +545,14 @@ def set_context_commands(item, parent_item):
from_action=item.action).tourl())))
# Descargar episodio
- if item.contentType == "episode":
+ elif item.contentType == "episode":
context_commands.append(("Descargar Episodio", "XBMC.RunPlugin(%s?%s)" %
(sys.argv[0], item.clone(channel="downloads", action="save_download",
from_channel=item.channel,
from_action=item.action).tourl())))
# Descargar temporada
- if item.contentType == "season":
+ elif item.contentType == "season":
context_commands.append(("Descargar Temporada", "XBMC.RunPlugin(%s?%s)" %
(sys.argv[0], item.clone(channel="downloads", action="save_download",
from_channel=item.channel,
diff --git a/plugin.video.alfa/resources/language/Spanish/strings.po b/plugin.video.alfa/resources/language/Spanish/strings.po
index bc41ec1b..38cecf4d 100644
--- a/plugin.video.alfa/resources/language/Spanish/strings.po
+++ b/plugin.video.alfa/resources/language/Spanish/strings.po
@@ -251,6 +251,10 @@ msgctxt "#30164"
msgid "Delete this file"
msgstr "Borrar este fichero"
+msgctxt "#30300"
+msgid "Faster context menus"
+msgstr "Menús contextuales rápidos (puede causar que algunas opciones no funcionen)"
+
msgctxt "#30501"
msgid "Paths"
msgstr "Rutas"
diff --git a/plugin.video.alfa/resources/settings.xml b/plugin.video.alfa/resources/settings.xml
index 950bf63b..719cd5e6 100644
--- a/plugin.video.alfa/resources/settings.xml
+++ b/plugin.video.alfa/resources/settings.xml
@@ -7,6 +7,7 @@
+