From 337e5f454809e00c535aae22153bd2481da566a3 Mon Sep 17 00:00:00 2001 From: Alok Saboo Date: Sat, 7 Oct 2023 18:19:58 -0400 Subject: [PATCH] gracefully handle Spotify timeout error --- beetsplug/spotify.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/beetsplug/spotify.py b/beetsplug/spotify.py index 0ada97e8b..55e0fe2ed 100644 --- a/beetsplug/spotify.py +++ b/beetsplug/spotify.py @@ -171,11 +171,16 @@ class SpotifyPlugin(MetadataSourcePlugin, BeetsPlugin): :return: JSON data for the class:`Response ` object. :rtype: dict """ - response = request_type( - url, - headers={'Authorization': f'Bearer {self.access_token}'}, - params=params, - ) + try: + response = request_type( + url, + headers={'Authorization': f'Bearer {self.access_token}'}, + params=params, + ) + response.raise_for_status() + except requests.exceptions.ReadTimeout: + self._log.debug('ReadTimeout. Retrying.') + return self._handle_response(request_type, url, params=params) if response.status_code != 200: if 'token expired' in response.text: self._log.debug(