From 7a4df06090f712873abcdaf0713a637f809b4a5d Mon Sep 17 00:00:00 2001 From: Krateng Date: Thu, 30 Jul 2020 15:15:09 +0200 Subject: [PATCH] Spotify now re-authenticates --- maloja/thirdparty/spotify.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/maloja/thirdparty/spotify.py b/maloja/thirdparty/spotify.py index 6b46dee..ee685e8 100644 --- a/maloja/thirdparty/spotify.py +++ b/maloja/thirdparty/spotify.py @@ -2,6 +2,7 @@ from . import MetadataInterface, utf, b64 import hashlib import urllib.parse, urllib.request import json +from threading import Timer class Spotify(MetadataInterface): name = "Spotify" @@ -34,5 +35,8 @@ class Spotify(MetadataInterface): } req = urllib.request.Request(**keys) response = urllib.request.urlopen(req) - self.settings["token"] = json.loads(response.read())["access_token"] + responsedata = json.loads(response.read()) + expire = responsedata["expires_in"] + self.settings["token"] = responsedata["access_token"] + Timer(expire,self.authorize).start() return True