Skip to content

Commit d8d227e

Browse files
authored
discogs: don't crash if a release is deleted (#5893)
Before: ``` Traceback (most recent call last): File "/nix/store/yk2m7a9wdmh8fz8ywca0c73sc5ad2zm6-beets-2.3.1/lib/python3.13/site-packages/beetsplug/discogs.py", line 312, in get_album_info result.refresh() ~~~~~~~~~~~~~~^^ File "/nix/store/007cfg4f295dz064bl9a2cjw10vlpc83-python3.13-discogs-client-2.8/lib/python3.13/site-packages/discogs_client/models.py", line 204, in refresh data = self.client._get(self.data['resource_url']) File "/nix/store/007cfg4f295dz064bl9a2cjw10vlpc83-python3.13-discogs-client-2.8/lib/python3.13/site-packages/discogs_client/client.py", line 114, in _get return self._request('GET', url) ~~~~~~~~~~~~~^^^^^^^^^^^^ File "/nix/store/007cfg4f295dz064bl9a2cjw10vlpc83-python3.13-discogs-client-2.8/lib/python3.13/site-packages/discogs_client/client.py", line 111, in _request raise HTTPError(body['message'], status_code) discogs_client.exceptions.HTTPError: 404: That release does not exist or may have been deleted. ``` After: ``` Discogs release not found: <Release 20919814 'Kumi Tanioka, Yae - Final Fantasy Crystal Chronicles Original Soundtrack'>: 404: That release does not exist or may have been deleted. ``` Here's the link to the relevant release, which [shows up in search results](https://www.discogs.com/search?q=Kumi+Tanioka%2C+Yae+-+Final+Fantasy+Crystal+Chronicles+Original+Soundtrack&type=all) but 404s if you click on it: https://www.discogs.com/release/20919814-Kumi-Tanioka-Yae-Final-Fantasy-Crystal-Chronicles-Original-Soundtrack
2 parents e3574a7 + 9e4559b commit d8d227e

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

beetsplug/discogs.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,14 @@ def get_album_info(self, result):
305305
# Explicitly reload the `Release` fields, as they might not be yet
306306
# present if the result is from a `discogs_client.search()`.
307307
if not result.data.get("artists"):
308-
result.refresh()
308+
try:
309+
result.refresh()
310+
except CONNECTION_ERRORS:
311+
self._log.debug(
312+
"Connection error in release lookup: {0}",
313+
result,
314+
)
315+
return None
309316

310317
# Sanity check for required fields. The list of required fields is
311318
# defined at Guideline 1.3.1.a, but in practice some releases might be

docs/changelog.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ Bug fixes:
5555
e.g. non latin characters as 盗作. If you want to keep the legacy behavior
5656
set the config option ``spotify.search_query_ascii: yes``.
5757
:bug:`5699`
58+
* :doc:`plugins/discogs`: Beets will no longer crash if a release has been
59+
deleted, and returns a 404.
5860

5961
For packagers:
6062

0 commit comments

Comments
 (0)