Fix playback from playlists for add-on paths
This commit is contained in:
parent
01d269f995
commit
108c88114b
1 changed files with 46 additions and 16 deletions
|
@ -65,23 +65,53 @@ def playback_triage(plex_id=None, plex_type=None, path=None, resolve=True):
|
||||||
try:
|
try:
|
||||||
pos = js.get_position(playqueue.playlistid)
|
pos = js.get_position(playqueue.playlistid)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
LOG.warning('No position returned from Kodi player! Assuming 0')
|
LOG.info('No position returned from Kodi player! Assuming playlist')
|
||||||
pos = 0
|
_playlist_playback(plex_id, plex_type, playqueue)
|
||||||
# Can return -1 (as in "no playlist")
|
else:
|
||||||
pos = pos if pos != -1 else 0
|
# Can return -1 (as in "no playlist")
|
||||||
LOG.debug('playQueue position %s for %s', pos, playqueue)
|
pos = pos if pos != -1 else 0
|
||||||
# Have we already initiated playback?
|
LOG.debug('playQueue position %s for %s', pos, playqueue)
|
||||||
|
# Have we already initiated playback?
|
||||||
|
try:
|
||||||
|
item = playqueue.items[pos]
|
||||||
|
except IndexError:
|
||||||
|
initiate = True
|
||||||
|
else:
|
||||||
|
initiate = True if item.plex_id != plex_id else False
|
||||||
|
if initiate:
|
||||||
|
_playback_init(plex_id, plex_type, playqueue, pos)
|
||||||
|
else:
|
||||||
|
# kick off playback on second pass
|
||||||
|
_conclude_playback(playqueue, pos)
|
||||||
|
|
||||||
|
|
||||||
|
def _playlist_playback(plex_id, plex_type, playqueue):
|
||||||
|
"""
|
||||||
|
Really annoying Kodi behavior: Kodi will throw the ENTIRE playlist some-
|
||||||
|
where, causing Playlist.onAdd to fire for each item like this:
|
||||||
|
Playlist.OnAdd Data: {u'item': {u'type': u'episode', u'id': 164},
|
||||||
|
u'playlistid': 0,
|
||||||
|
u'position': 2}
|
||||||
|
This does NOT work for Addon paths, type and id will be unknown
|
||||||
|
At the end, only the element being played actually shows up in the Kodi
|
||||||
|
playqueue.
|
||||||
|
Hence: if we fail the first addon paths call, Kodi will start playback
|
||||||
|
for the next item in line :-)
|
||||||
|
"""
|
||||||
|
playqueue.clear(kodi=False)
|
||||||
|
xml = GetPlexMetadata(plex_id)
|
||||||
try:
|
try:
|
||||||
item = playqueue.items[pos]
|
xml[0].attrib
|
||||||
except IndexError:
|
except (IndexError, TypeError, AttributeError):
|
||||||
initiate = True
|
LOG.error('Could not get a PMS xml for plex id %s', plex_id)
|
||||||
else:
|
# "Play error"
|
||||||
initiate = True if item.plex_id != plex_id else False
|
dialog('notification', lang(29999), lang(30128), icon='{error}')
|
||||||
if initiate:
|
_ensure_resolve(abort=True)
|
||||||
_playback_init(plex_id, plex_type, playqueue, pos)
|
return
|
||||||
else:
|
playlist_item = PL.playlist_item_from_xml(xml[0])
|
||||||
# kick off playback on second pass
|
playlist_item.part = 0
|
||||||
_conclude_playback(playqueue, pos)
|
playqueue.items.append(playlist_item)
|
||||||
|
_conclude_playback(playqueue, pos=0)
|
||||||
|
|
||||||
|
|
||||||
def _playback_init(plex_id, plex_type, playqueue, pos):
|
def _playback_init(plex_id, plex_type, playqueue, pos):
|
||||||
|
|
Loading…
Add table
Reference in a new issue