Skip to content
Snippets Groups Projects
Commit 477f3cfd authored by Benoît Harrault's avatar Benoît Harrault
Browse files

Merge branch '20-fix-get-image-refresh-access-token' into 'master'

Resolve "Fix get image, refresh access token"

Closes #20

See merge request !16
parents b9d57f99 08169b72
No related branches found
No related tags found
1 merge request!16Resolve "Fix get image, refresh access token"
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.spotify.screensaver"
name="Spotify Screensaver"
version="0.0.11"
version="0.0.12"
provider-name="Benoît Harrault">
<requires>
<import addon="xbmc.python" version="2.25.0"/>
......
......@@ -161,8 +161,9 @@ class GUI(xbmcgui.WindowXMLDialog):
self.PanelItems = self.getControl(101)
self.PanelItems.reset()
def _get_track_data(self, track_id):
def _get_track_data(self, track_id, try_count=1):
self.log('track_id: [' + str(track_id) + ']')
self.log('(try: ' + str(try_count) + ')')
imageLST = []
......@@ -186,6 +187,14 @@ class GUI(xbmcgui.WindowXMLDialog):
if album is None:
self.log('failed to get album from API', xbmc.LOGERROR)
self.log(json.dumps(data), xbmc.LOGERROR)
if json.dumps(data) == '{"error": {"status": 401, "message": "The access token expired"}}':
self.log('trying to refresh access token')
self._init_spotify_access_token()
self.log('retry get image')
self._get_track_data(track_id, try_count + 1)
else:
self.log('unknown error getting image', xbmc.LOGERROR)
else:
self.log('ok got album from API')
self.log(json.dumps(album))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment