From f5af67427fb87011e0dda7dd66c173572d79aad7 Mon Sep 17 00:00:00 2001 From: croneter Date: Fri, 30 Apr 2021 10:22:11 +0200 Subject: [PATCH] Fix a rare AttributeError when using playlists --- resources/lib/playlist_func.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/resources/lib/playlist_func.py b/resources/lib/playlist_func.py index 1e16b11b..f18e115c 100644 --- a/resources/lib/playlist_func.py +++ b/resources/lib/playlist_func.py @@ -402,9 +402,9 @@ def _get_playListVersion_from_xml(playlist, xml): Raises PlaylistError if unsuccessful """ - playlist.version = utils.cast(int, - xml.get('%sVersion' % playlist.kind)) - if playlist.version is None: + try: + playlist.version = int(xml.get('%sVersion' % playlist.kind)) + except (AttributeError, TypeError): raise PlaylistError('Could not get new playlist Version for playlist ' '%s' % playlist) @@ -416,6 +416,8 @@ def get_playlist_details_from_xml(playlist, xml): Raises PlaylistError if something went wrong. """ + if xml is None: + raise PlaylistError('No playlist received for playlist %s' % playlist) playlist.id = utils.cast(int, xml.get('%sID' % playlist.kind)) playlist.version = utils.cast(int, @@ -703,8 +705,8 @@ def delete_playlist_item_from_PMS(playlist, pos): playlist.items[pos].id, playlist.repeat), action_type="DELETE") - _get_playListVersion_from_xml(playlist, xml) del playlist.items[pos] + _get_playListVersion_from_xml(playlist, xml) # Functions operating on the Kodi playlist objects ##########