mirror of
https://github.com/beetbox/beets.git
synced 2026-01-30 03:54:21 +01:00
Add 429 API error handling
This commit is contained in:
parent
c25e7ad511
commit
71be6d5138
1 changed files with 5 additions and 0 deletions
|
|
@ -164,6 +164,11 @@ class SpotifyPlugin(MetadataSourcePlugin, BeetsPlugin):
|
|||
)
|
||||
self._authenticate()
|
||||
return self._handle_response(request_type, url, params=params)
|
||||
elif response.status_code == 429:
|
||||
seconds = response.headers['Retry-After']
|
||||
time.sleep(int(seconds))
|
||||
self._log.info('Too many API requests. Retrying after {} seconds.', seconds)
|
||||
return self._handle_response(request_type, url, params=params)
|
||||
else:
|
||||
raise ui.UserError(
|
||||
'{} API error:\n{}\nURL:\n{}\nparams:\n{}'.format(
|
||||
|
|
|
|||
Loading…
Reference in a new issue