Simplify loop and update changelog entry

This commit is contained in:
Alok Saboo 2023-10-21 16:16:51 -04:00
parent b9da57481f
commit f79fd64aeb
2 changed files with 10 additions and 11 deletions

View file

@ -196,7 +196,8 @@ class SpotifyPlugin(MetadataSourcePlugin, BeetsPlugin):
raise SpotifyAPIError(f'API Error: {e.response.status_code}\n' raise SpotifyAPIError(f'API Error: {e.response.status_code}\n'
f'URL: {url}\nparams: {params}') f'URL: {url}\nparams: {params}')
elif e.response.status_code == 429: elif e.response.status_code == 429:
if retry_count < max_retries: if retry_count >= max_retries:
raise SpotifyAPIError('Maximum retries reached.')
seconds = response.headers.get('Retry-After', seconds = response.headers.get('Retry-After',
DEFAULT_WAITING_TIME) DEFAULT_WAITING_TIME)
self._log.debug(f'Too many API requests. Retrying after ' self._log.debug(f'Too many API requests. Retrying after '
@ -205,8 +206,6 @@ class SpotifyPlugin(MetadataSourcePlugin, BeetsPlugin):
return self._handle_response(request_type, url, return self._handle_response(request_type, url,
params=params, params=params,
retry_count=retry_count + 1) retry_count=retry_count + 1)
else:
raise SpotifyAPIError('Maximum retries reached.')
elif e.response.status_code == 503: elif e.response.status_code == 503:
self._log.error('Service Unavailable.') self._log.error('Service Unavailable.')
raise SpotifyAPIError('Service Unavailable.') raise SpotifyAPIError('Service Unavailable.')

View file

@ -142,7 +142,7 @@ New features:
Bug fixes: Bug fixes:
* Fix retry-logic for Spotify plugin. * :doc:`/plugins/spotify`: Add a limit of 3 retries, instead of retrying endlessly when the API is not available.
* Fix a crash when the Spotify API timeouts or does not return a `Retry-After` interval. * Fix a crash when the Spotify API timeouts or does not return a `Retry-After` interval.
:bug:`4942` :bug:`4942`
* :doc:`/plugins/scrub`: Fixed the import behavior where scrubbed database tags * :doc:`/plugins/scrub`: Fixed the import behavior where scrubbed database tags