Merge pull request #960 from croneter/fix-attributeerror

Fix rare AttributeError when shutting down Kodi
This commit is contained in:
croneter 2019-08-10 13:24:17 +02:00 committed by GitHub
commit 7ff4baac3a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View file

@ -502,6 +502,8 @@ def update_playlist_from_PMS(playlist, playlist_id=None, xml=None):
need to fetch a new playqueue
If an xml is passed in, the playlist will be overwritten with its info
Raises PlaylistError if something went wront
"""
if xml is None:
xml = get_PMS_playlist(playlist, playlist_id)
@ -538,6 +540,8 @@ def init_plex_playqueue(playlist, plex_id=None, kodi_item=None):
xml = DU().downloadUrl(url="{server}/%ss" % playlist.kind,
action_type="POST",
parameters=params)
if xml in (None, 401):
raise PlaylistError('Did not receive a valid xml from the PMS')
get_playlist_details_from_xml(playlist, xml)
# Need to get the details for the playlist item
item = playlist_item_from_xml(xml[0])
@ -721,7 +725,7 @@ def get_PMS_playlist(playlist, playlist_id=None):
Fetches the PMS playlist/playqueue as an XML. Pass in playlist_id if we
need to fetch a new playlist
Returns None if something went wrong
Raises PlaylistError if something went wrong
"""
playlist_id = playlist_id if playlist_id else playlist.id
if playlist.kind == 'playList':
@ -731,7 +735,7 @@ def get_PMS_playlist(playlist, playlist_id=None):
try:
xml.attrib
except AttributeError:
xml = None
raise PlaylistError('Did not get a valid xml')
return xml

View file

@ -49,10 +49,9 @@ def update_playqueue_from_PMS(playqueue,
if transient_token is None:
transient_token = playqueue.plex_transient_token
with app.APP.lock_playqueues:
xml = PL.get_PMS_playlist(playqueue, playqueue_id)
try:
xml.attrib
except AttributeError:
xml = PL.get_PMS_playlist(playqueue, playqueue_id)
except PL.PlaylistError:
LOG.error('Could now download playqueue %s', playqueue_id)
return
if playqueue.id == playqueue_id: