Fix PlexKodiConnect Play error in rare scenarios (an older PMS version?), where posting playqueues using an uri server://
is not possible and library://
is necessary
This commit is contained in:
parent
055fe9aaa7
commit
5fb2279c53
2 changed files with 30 additions and 5 deletions
|
@ -235,7 +235,10 @@ def _playback_init(plex_id, plex_type, playqueue, pos):
|
||||||
playqueue.clear()
|
playqueue.clear()
|
||||||
if plex_type != v.PLEX_TYPE_CLIP:
|
if plex_type != v.PLEX_TYPE_CLIP:
|
||||||
# Post to the PMS to create a playqueue - in any case due to Companion
|
# Post to the PMS to create a playqueue - in any case due to Companion
|
||||||
xml = PF.init_plex_playqueue(plex_id, plex_type, trailers=trailers)
|
xml = PF.init_plex_playqueue(plex_id,
|
||||||
|
plex_type,
|
||||||
|
xml.get('librarySectionUUID'),
|
||||||
|
trailers=trailers)
|
||||||
if xml is None:
|
if xml is None:
|
||||||
LOG.error('Could not get a playqueue xml for plex id %s', plex_id)
|
LOG.error('Could not get a playqueue xml for plex id %s', plex_id)
|
||||||
# "Play error"
|
# "Play error"
|
||||||
|
|
|
@ -820,7 +820,7 @@ def get_plex_sections():
|
||||||
return xml
|
return xml
|
||||||
|
|
||||||
|
|
||||||
def init_plex_playqueue(plex_id, plex_type, trailers=False):
|
def init_plex_playqueue(plex_id, plex_type, section_uuid, trailers=False):
|
||||||
"""
|
"""
|
||||||
Returns raw API metadata XML dump for a playlist with e.g. trailers.
|
Returns raw API metadata XML dump for a playlist with e.g. trailers.
|
||||||
"""
|
"""
|
||||||
|
@ -839,8 +839,30 @@ def init_plex_playqueue(plex_id, plex_type, trailers=False):
|
||||||
try:
|
try:
|
||||||
xml[0].tag
|
xml[0].tag
|
||||||
except (IndexError, TypeError, AttributeError):
|
except (IndexError, TypeError, AttributeError):
|
||||||
LOG.error("Error retrieving metadata for %s", url)
|
LOG.warn('Need to initialize Plex playqueue the old fashioned way')
|
||||||
return
|
xml = init_plex_playqueue_old_fashioned(plex_id, section_uuid, url, args)
|
||||||
|
return xml
|
||||||
|
|
||||||
|
|
||||||
|
def init_plex_playqueue_old_fashioned(plex_id, section_uuid, url, args):
|
||||||
|
"""
|
||||||
|
In rare cases (old PMS version?), the PMS does not allow to add media using
|
||||||
|
an uri
|
||||||
|
server://<machineIdentifier>/com.plexapp.plugins.library/library...
|
||||||
|
We need to use
|
||||||
|
library://<librarySectionUUID>/item/...
|
||||||
|
|
||||||
|
This involves an extra step to grab the librarySectionUUID for plex_id
|
||||||
|
"""
|
||||||
|
args['uri'] = 'library://{0}/item/%2Flibrary%2Fmetadata%2F{1}'.format(
|
||||||
|
section_uuid, plex_id)
|
||||||
|
xml = DU().downloadUrl(utils.extend_url(url, args), action_type="POST")
|
||||||
|
try:
|
||||||
|
xml[0].tag
|
||||||
|
except (IndexError, TypeError, AttributeError):
|
||||||
|
LOG.error('Error initializing the playqueue the old fashioned way %s',
|
||||||
|
utils.extend_url(url, args))
|
||||||
|
xml = None
|
||||||
return xml
|
return xml
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue