Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deezer: Improve requests error handling #5421

Merged
merged 3 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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", [])
snejus marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -238,6 +238,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