Merge pull request #960 from croneter/fix-attributeerror
Fix rare AttributeError when shutting down Kodi
This commit is contained in:
commit
7ff4baac3a
2 changed files with 8 additions and 5 deletions
|
@ -502,6 +502,8 @@ def update_playlist_from_PMS(playlist, playlist_id=None, xml=None):
|
||||||
need to fetch a new playqueue
|
need to fetch a new playqueue
|
||||||
|
|
||||||
If an xml is passed in, the playlist will be overwritten with its info
|
If an xml is passed in, the playlist will be overwritten with its info
|
||||||
|
|
||||||
|
Raises PlaylistError if something went wront
|
||||||
"""
|
"""
|
||||||
if xml is None:
|
if xml is None:
|
||||||
xml = get_PMS_playlist(playlist, playlist_id)
|
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,
|
xml = DU().downloadUrl(url="{server}/%ss" % playlist.kind,
|
||||||
action_type="POST",
|
action_type="POST",
|
||||||
parameters=params)
|
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)
|
get_playlist_details_from_xml(playlist, xml)
|
||||||
# Need to get the details for the playlist item
|
# Need to get the details for the playlist item
|
||||||
item = playlist_item_from_xml(xml[0])
|
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
|
Fetches the PMS playlist/playqueue as an XML. Pass in playlist_id if we
|
||||||
need to fetch a new playlist
|
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
|
playlist_id = playlist_id if playlist_id else playlist.id
|
||||||
if playlist.kind == 'playList':
|
if playlist.kind == 'playList':
|
||||||
|
@ -731,7 +735,7 @@ def get_PMS_playlist(playlist, playlist_id=None):
|
||||||
try:
|
try:
|
||||||
xml.attrib
|
xml.attrib
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
xml = None
|
raise PlaylistError('Did not get a valid xml')
|
||||||
return xml
|
return xml
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -49,10 +49,9 @@ def update_playqueue_from_PMS(playqueue,
|
||||||
if transient_token is None:
|
if transient_token is None:
|
||||||
transient_token = playqueue.plex_transient_token
|
transient_token = playqueue.plex_transient_token
|
||||||
with app.APP.lock_playqueues:
|
with app.APP.lock_playqueues:
|
||||||
xml = PL.get_PMS_playlist(playqueue, playqueue_id)
|
|
||||||
try:
|
try:
|
||||||
xml.attrib
|
xml = PL.get_PMS_playlist(playqueue, playqueue_id)
|
||||||
except AttributeError:
|
except PL.PlaylistError:
|
||||||
LOG.error('Could now download playqueue %s', playqueue_id)
|
LOG.error('Could now download playqueue %s', playqueue_id)
|
||||||
return
|
return
|
||||||
if playqueue.id == playqueue_id:
|
if playqueue.id == playqueue_id:
|
||||||
|
|
Loading…
Reference in a new issue