diff --git a/contextmenu.py b/contextmenu.py index 304032ce..29eb3b7d 100644 --- a/contextmenu.py +++ b/contextmenu.py @@ -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') diff --git a/resources/lib/command_pipeline.py b/resources/lib/command_pipeline.py index 13ec7be9..92c6cc57 100644 --- a/resources/lib/command_pipeline.py +++ b/resources/lib/command_pipeline.py @@ -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: diff --git a/resources/lib/playback_starter.py b/resources/lib/playback_starter.py index f0ac27f5..aabfc3ac 100644 --- a/resources/lib/playback_starter.py +++ b/resources/lib/playback_starter.py @@ -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))