From 23cc1ac341d3edfd66828cae4166994ca22f5e55 Mon Sep 17 00:00:00 2001 From: Krateng Date: Thu, 21 Jan 2021 17:38:37 +0100 Subject: [PATCH] Third party improvements --- maloja/thirdparty/__init__.py | 30 ++++++++++++++++++------------ maloja/thirdparty/spotify.py | 2 +- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/maloja/thirdparty/__init__.py b/maloja/thirdparty/__init__.py index 31dae74..88b02b2 100644 --- a/maloja/thirdparty/__init__.py +++ b/maloja/thirdparty/__init__.py @@ -28,20 +28,26 @@ def proxy_scrobble_all(artists,title,timestamp): def get_image_track_all(track): for service in services["metadata"]: - res = service.get_image_track(track) - if res is not None: - log("Got track image for " + str(track) + " from " + service.name) - return res - else: - log("Could not get track image for " + str(track) + " from " + service.name) + try: + res = service.get_image_track(track) + if res is not None: + log("Got track image for " + str(track) + " from " + service.name) + return res + else: + log("Could not get track image for " + str(track) + " from " + service.name) + except Exception as e: + log("Error getting track image from " + service.name + ": " + str(e)) def get_image_artist_all(artist): for service in services["metadata"]: - res = service.get_image_artist(artist) - if res is not None: - log("Got artist image for " + str(artist) + " from " + service.name) - return res - else: - log("Could not get artist image for " + str(artist) + " from " + service.name) + try: + res = service.get_image_artist(artist) + if res is not None: + log("Got artist image for " + str(artist) + " from " + service.name) + return res + else: + log("Could not get artist image for " + str(artist) + " from " + service.name) + except Exception as e: + log("Error getting artist image from " + service.name + ": " + str(e)) diff --git a/maloja/thirdparty/spotify.py b/maloja/thirdparty/spotify.py index ee685e8..a046e48 100644 --- a/maloja/thirdparty/spotify.py +++ b/maloja/thirdparty/spotify.py @@ -36,7 +36,7 @@ class Spotify(MetadataInterface): req = urllib.request.Request(**keys) response = urllib.request.urlopen(req) responsedata = json.loads(response.read()) - expire = responsedata["expires_in"] + expire = responsedata.get("expires_in",3600) self.settings["token"] = responsedata["access_token"] Timer(expire,self.authorize).start() return True