From d794c3c8dc25b659a1825ed4b8cfb1e4da68ee98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Harrault?= <benoit@harrault.fr> Date: Thu, 10 Mar 2022 11:04:07 +0100 Subject: [PATCH] Fix get track data --- addon.xml | 2 +- gui.py | 21 +++++++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/addon.xml b/addon.xml index 2228ceb..93297b6 100644 --- a/addon.xml +++ b/addon.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <addon id="script.spotify.screensaver" name="Spotify Screensaver" - version="0.0.6" + version="0.0.7" provider-name="Benoît Harrault"> <requires> <import addon="xbmc.python" version="2.25.0"/> diff --git a/gui.py b/gui.py index 6f75fb0..3968a75 100644 --- a/gui.py +++ b/gui.py @@ -153,16 +153,21 @@ class GUI(xbmcgui.WindowXMLDialog): ) data = response.json() - track_name = data['name'] + track_name = data.get('name', '') # album/track image - album = data['album'] - images = album['images'] - image_url = images[0]['url'] - - imageLST.append( - xbmcgui.ListItem(track_name, thumbnailImage=image_url) - ) + album = data.get('album') + if album is not None: + images = album.get('images') + if images is not None: + image = images[0] + if image is not None: + image_url = image.get('url') + if image_url is not None: + imageLST.append( + xbmcgui.ListItem( + track_name, thumbnailImage=image_url) + ) except Exception as e: self.log('failed to get track data ' + str(e), xbmc.LOGERROR) -- GitLab