Deezer: Improve requests error handling (#5421)

This PR adds gracefully handling requests error in teh Deezer plugin.
This commit is contained in:
Šarūnas Nejus 2024-09-17 18:52:42 +01:00 committed by GitHub
commit c13f0f2f6e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 6 deletions

View file

@ -279,12 +279,20 @@ class DeezerPlugin(MetadataSourcePlugin, BeetsPlugin):
if not query:
return None
self._log.debug(f"Searching {self.data_source} for '{query}'")
response = requests.get(
self.search_url + query_type,
params={"q": query},
timeout=10,
)
response.raise_for_status()
try:
response = requests.get(
self.search_url + query_type,
params={"q": query},
timeout=10,
)
response.raise_for_status()
except requests.exceptions.RequestException as e:
self._log.error(
"Error fetching data from {} API\n Error: {}",
self.data_source,
e,
)
return None
response_data = response.json().get("data", [])
self._log.debug(
"Found {} result(s) from {} for '{}'",

View file

@ -240,6 +240,7 @@ New features:
Bug fixes:
* :doc:`/plugins/deezer`: Improve requests error handling.
* :doc:`/plugins/lastimport`: Improve error handling in the `process_tracks` function and enable it to be used with other plugins.
* :doc:`/plugins/spotify`: Improve handling of ConnectionError.
* :doc:`/plugins/deezer`: Improve Deezer plugin error handling and set requests timeout to 10 seconds.