Replace class SpotifyAuthorize with @must_be_authorized (#506)

* @must_be_authorized decorator for functions in spotify_tools.py

* We don't need this

* Add tests

* Update CHANGELOG.md
This commit is contained in:
Ritiek Malhotra
2019-02-27 09:48:18 -08:00
committed by GitHub
parent 1767899a8a
commit ac7d42535f
8 changed files with 282 additions and 252 deletions

View File

@@ -202,12 +202,8 @@ class ListDownloader:
try:
track_dl = Downloader(raw_song, number=number)
track_dl.download_single()
except spotipy.client.SpotifyException:
# token expires after 1 hour
self._regenerate_token()
track_dl.download_single()
# detect network problems
except (urllib.request.URLError, TypeError, IOError) as e:
# detect network problems
self._cleanup(raw_song, e)
# TODO: remove this sleep once #397 is fixed
# wait 0.5 sec to avoid infinite looping
@@ -233,11 +229,6 @@ class ListDownloader:
with open(self.write_successful_file, "a") as f:
f.write("\n" + raw_song)
@staticmethod
def _regenerate_token():
log.debug("Token expired, generating new one and authorizing")
spotify_tools.refresh_token()
def _cleanup(self, raw_song, exception):
self.tracks.append(raw_song)
# remove the downloaded song from file