Improve Plex playQueue resiliance

- Partially fixes #566
This commit is contained in:
croneter 2018-12-22 15:06:28 +01:00
parent 16ff6a51f5
commit 6237d932d8

View file

@ -449,9 +449,9 @@ def _get_playListVersion_from_xml(playlist, xml):
Raises PlaylistError if unsuccessful Raises PlaylistError if unsuccessful
""" """
try: playlist.version = utils.cast(int,
playlist.version = int(xml.attrib['%sVersion' % playlist.kind]) xml.get('%sVersion' % playlist.kind))
except (TypeError, AttributeError, KeyError): if playlist.version is None:
raise PlaylistError('Could not get new playlist Version for playlist ' raise PlaylistError('Could not get new playlist Version for playlist '
'%s' % playlist) '%s' % playlist)
@ -463,13 +463,18 @@ def get_playlist_details_from_xml(playlist, xml):
Raises PlaylistError if something went wrong. Raises PlaylistError if something went wrong.
""" """
playlist.id = xml.get('%sID' % playlist.kind).decode('utf-8') playlist.id = utils.cast(int,
playlist.version = xml.get('%sVersion' % playlist.kind).decode('utf-8') xml.get('%sID' % playlist.kind))
playlist.shuffled = xml.get('%sShuffled' % playlist.kind).decode('utf-8') playlist.version = utils.cast(int,
playlist.selectedItemID = xml.get( xml.get('%sVersion' % playlist.kind))
'%sSelectedItemID' % playlist.kind).decode('utf-8') playlist.shuffled = utils.cast(int,
playlist.selectedItemOffset = xml.get( xml.get('%sShuffled' % playlist.kind))
'%sSelectedItemOffset' % playlist.kind).decode('utf-8') playlist.selectedItemID = utils.cast(int,
xml.get('%sSelectedItemID'
% playlist.kind))
playlist.selectedItemOffset = utils.cast(int,
xml.get('%sSelectedItemOffset'
% playlist.kind))
LOG.debug('Updated playlist from xml: %s', playlist) LOG.debug('Updated playlist from xml: %s', playlist)