requests_cache compatibility

This commit is contained in:
Tim Jagenberg 2019-07-27 22:26:28 +02:00
parent 4c2c1d763a
commit 2252ea5cfa

View File

@ -128,7 +128,8 @@ class Spotify(object):
raise SpotifyException(r.status_code,
-1, '%s:\n %s' % (r.url, 'error'), headers=r.headers)
finally:
r.connection.close()
if hasattr(r, "connection"):
r.connection.close()
if r.text and len(r.text) > 0 and r.text != 'null':
results = r.json()
if self.trace: # pragma: no cover