Skip to content

Commit

Permalink
Deezer: Improve requests error handling (beetbox#5421)
Browse files Browse the repository at this point in the history
This PR adds gracefully handling requests error in teh Deezer plugin.
  • Loading branch information
snejus authored Sep 17, 2024
2 parents 5785522 + 7f74d3d commit c13f0f2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
20 changes: 14 additions & 6 deletions beetsplug/deezer.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,20 @@ def _search_api(self, query_type, filters=None, keywords=""):
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 '{}'",
Expand Down
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit c13f0f2

Please sign in to comment.