From f590067983c9b6a85d857d19204e089caba22b1b Mon Sep 17 00:00:00 2001 From: Alhaziel01 Date: Sat, 20 Aug 2022 11:32:22 +0200 Subject: [PATCH] Migliorie contextmenu --- contextmenu.py | 14 +------------- platformcode/contextmenu/contextmenu.json | 3 ++- platformcode/contextmenu/show_servers.py | 23 +++++++++++++++++++++++ 3 files changed, 26 insertions(+), 14 deletions(-) create mode 100644 platformcode/contextmenu/show_servers.py diff --git a/contextmenu.py b/contextmenu.py index 46e3c8b0..f3b86a0d 100644 --- a/contextmenu.py +++ b/contextmenu.py @@ -43,14 +43,6 @@ def build_menu(): contextmenuitems.extend([item for item, fn in module_item_actions]) contextmenuactions.extend([fn for item, fn in module_item_actions]) - if 'kod' in filePath and mediatype in ['movie', 'episode'] and config.get_setting('autoplay'): - logger.debug('Add Select server menu item') - contextmenuitems.append(config.get_localized_string(70192)) - from core import filetools - item = Item().fromurl(filetools.read(filePath)) - item.disableAutoplay = True - contextmenuactions.append(item) - if len(contextmenuitems) == 0: logger.debug('No contextmodule found, build an empty one') contextmenuitems.append(empty_item()) @@ -60,11 +52,7 @@ def build_menu(): if ret > -1: logger.debug('Contextmenu module index', ret, ', label=' + contextmenuitems[ret]) - if type(contextmenuactions[ret]) == Item: - from platformcode.launcher import run - run(contextmenuactions[ret]) - else: - contextmenuactions[ret]() + contextmenuactions[ret]() def empty_item(): diff --git a/platformcode/contextmenu/contextmenu.json b/platformcode/contextmenu/contextmenu.json index 3acd6121..a5b2787f 100644 --- a/platformcode/contextmenu/contextmenu.json +++ b/platformcode/contextmenu/contextmenu.json @@ -1,5 +1,6 @@ [ "platformcode.contextmenu.search", "platformcode.contextmenu.tvshow_options", - "platformcode.contextmenu.trailer" + "platformcode.contextmenu.trailer", + "platformcode.contextmenu.show_servers" ] \ No newline at end of file diff --git a/platformcode/contextmenu/show_servers.py b/platformcode/contextmenu/show_servers.py new file mode 100644 index 00000000..cd128de9 --- /dev/null +++ b/platformcode/contextmenu/show_servers.py @@ -0,0 +1,23 @@ +import xbmc + +from core.item import Item +from platformcode import config + + +def get_menu_items(): + mediatype = xbmc.getInfoLabel('ListItem.DBTYPE') + filePath = xbmc.getInfoLabel('ListItem.FileNameAndPath') + res = [] + if 'kod' in filePath and mediatype in ['movie', 'episode'] and config.get_setting('autoplay'): + res = [(config.get_localized_string(70192), execute)] + return res + + +def execute(): + from core import filetools + from platformcode.launcher import run + filePath = xbmc.getInfoLabel('ListItem.FileNameAndPath') + item = Item().fromurl(filetools.read(filePath)) + item.disableAutoplay = True + + run(item)