1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00

Third party improvements

This commit is contained in:
Krateng 2021-01-21 17:38:37 +01:00
parent c2f8ecc2df
commit 23cc1ac341
2 changed files with 19 additions and 13 deletions

View File

@ -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))

View File

@ -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