diff --git a/addon.xml b/addon.xml index c9928aa2..a8aa2fc6 100644 --- a/addon.xml +++ b/addon.xml @@ -3,8 +3,8 @@ - - + + video audio image diff --git a/default.py b/default.py index 2da11307..79b07fb3 100644 --- a/default.py +++ b/default.py @@ -171,8 +171,12 @@ class Main(): """ Start up playback_starter in main Python thread """ + request = '%s&handle=%s' % (argv[2], HANDLE) # Put the request into the 'queue' - plex_command('PLAY', argv[2]) + plex_command('PLAY', request) + if HANDLE == -1: + # Handle -1 received, not waiting for main thread + return # Wait for the result while not pickl_window('plex_result'): sleep(50) diff --git a/resources/lib/PlexCompanion.py b/resources/lib/PlexCompanion.py index eb63ccec..0f9162fb 100644 --- a/resources/lib/PlexCompanion.py +++ b/resources/lib/PlexCompanion.py @@ -94,8 +94,7 @@ class PlexCompanion(Thread): params = { 'mode': 'plex_node', 'key': '{server}%s' % data.get('key'), - 'offset': data.get('offset'), - 'play_directly': 'true' + 'offset': data.get('offset') } executebuiltin('RunPlugin(plugin://%s?%s)' % (v.ADDON_ID, urlencode(params))) diff --git a/resources/lib/playback_starter.py b/resources/lib/playback_starter.py index db280915..f1d991db 100644 --- a/resources/lib/playback_starter.py +++ b/resources/lib/playback_starter.py @@ -24,28 +24,31 @@ class PlaybackStarter(Thread): """ @staticmethod def _triage(item): - try: - _, params = item.split('?', 1) - except ValueError: + _, params = item.split('?', 1) + params = dict(parse_qsl(params)) + mode = params.get('mode') + resolve = False if params.get('handle') == '-1' else True + LOG.debug('Received mode: %s, params: %s', mode, params) + if mode == 'play': + playback.playback_triage(plex_id=params.get('plex_id'), + plex_type=params.get('plex_type'), + path=params.get('path'), + resolve=resolve) + elif mode == 'plex_node': + playback.process_indirect(params['key'], + params['offset'], + resolve=resolve) + elif mode == 'navigation': # e.g. when plugin://...tvshows is called for entire season with kodidb.GetKodiDB('video') as kodi_db: - show_id = kodi_db.show_id_from_path(item) + show_id = kodi_db.show_id_from_path(params.get('path')) if show_id: js.activate_window('videos', 'videodb://tvshows/titles/%s' % show_id) else: LOG.error('Could not find tv show id for %s', item) - pickle_me(Playback_Successful()) - return - params = dict(parse_qsl(params)) - mode = params.get('mode') - LOG.debug('Received mode: %s, params: %s', mode, params) - if mode == 'play': - playback.playback_triage(plex_id=params.get('plex_id'), - plex_type=params.get('plex_type'), - path=params.get('path')) - elif mode == 'plex_node': - playback.process_indirect(params['key'], params['offset']) + if resolve: + pickle_me(Playback_Successful()) elif mode == 'context_menu': ContextMenu(kodi_id=params['kodi_id'], kodi_type=params['kodi_type'])