Fix playback failing in certain cases

This commit is contained in:
croneter 2018-04-15 18:13:48 +02:00
parent b4b05b70ec
commit 83e85a3ea9
4 changed files with 26 additions and 20 deletions

View file

@ -3,8 +3,8 @@
<requires>
<import addon="xbmc.python" version="2.1.0"/>
<import addon="script.module.requests" version="2.9.1" />
<import addon="plugin.video.plexkodiconnect.movies" version="2.0.1" />
<import addon="plugin.video.plexkodiconnect.tvshows" version="2.0.2" />
<import addon="plugin.video.plexkodiconnect.movies" version="2.0.2" />
<import addon="plugin.video.plexkodiconnect.tvshows" version="2.0.3" />
</requires>
<extension point="xbmc.python.pluginsource" library="default.py">
<provides>video audio image</provides>

View file

@ -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)

View file

@ -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)))

View file

@ -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'])