Greatly speed up displaying context menu

This commit is contained in:
tomkat83 2017-09-10 15:09:32 +02:00
parent cb39dbd19d
commit 47675bc60f
3 changed files with 28 additions and 30 deletions

View file

@ -1,52 +1,44 @@
# -*- coding: utf-8 -*-
###############################################################################
from logging import getLogger
from os import path as os_path
from sys import path as sys_path
import logging
import os
import sys
from xbmcaddon import Addon
from xbmc import translatePath, sleep
from xbmcgui import Window
import xbmc
import xbmcaddon
###############################################################################
_addon = xbmcaddon.Addon(id='plugin.video.plexkodiconnect')
_addon = Addon(id='plugin.video.plexkodiconnect')
try:
_addon_path = _addon.getAddonInfo('path').decode('utf-8')
except TypeError:
_addon_path = _addon.getAddonInfo('path').decode()
try:
_base_resource = xbmc.translatePath(os.path.join(
_base_resource = translatePath(os_path.join(
_addon_path,
'resources',
'lib')).decode('utf-8')
except TypeError:
_base_resource = xbmc.translatePath(os.path.join(
_base_resource = translatePath(os_path.join(
_addon_path,
'resources',
'lib')).decode()
sys.path.append(_base_resource)
sys_path.append(_base_resource)
from pickler import unpickle_me, pickl_window
###############################################################################
import loghandler
from context_entry import ContextMenu
###############################################################################
loghandler.config()
log = logging.getLogger("PLEX.contextmenu")
log = getLogger("PLEX."+__name__)
###############################################################################
if __name__ == "__main__":
try:
# Start the context menu
ContextMenu()
except Exception as error:
log.error(error)
import traceback
log.error("Traceback:\n%s" % traceback.format_exc())
raise
win = Window(10000)
while win.getProperty('plex_command'):
sleep(20)
win.setProperty('plex_command', 'CONTEXT_menu')
while not pickl_window('plex_result'):
sleep(50)
result = unpickle_me()
if result is None:
log.error('Error encountered, aborting')

View file

@ -62,6 +62,8 @@ class Monitor_Window(Thread):
value.replace('PLEX_USERNAME-', '') or None
elif value.startswith('RUN_LIB_SCAN-'):
state.RUN_LIB_SCAN = value.replace('RUN_LIB_SCAN-', '')
elif value == 'CONTEXT_menu':
queue.put('dummy?mode=context_menu')
else:
raise NotImplementedError('%s not implemented' % value)
else:

View file

@ -17,6 +17,7 @@ import variables as v
from downloadutils import DownloadUtils
from PKC_listitem import convert_PKC_to_listitem
import plexdb_functions as plexdb
from context_entry import ContextMenu
import state
###############################################################################
@ -142,6 +143,9 @@ class Playback_Starter(Thread):
params.get('view_offset'),
directplay=True if params.get('play_directly') else False,
node=False if params.get('node') == 'false' else True)
elif mode == 'context_menu':
ContextMenu()
result = Playback_Successful()
except:
log.error('Error encountered for mode %s, params %s'
% (mode, params))