Merge pull request #1001 from croneter/fix-playerror

Fix Play Error in scenarios (older PMS version?) where posting playqueues using an uri `server://` is not possible and `library://` is necessary
This commit is contained in:
croneter 2019-09-29 18:50:31 +02:00 committed by GitHub
commit eef8a94b35
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 5 deletions

View file

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

View file

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