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
This commit is contained in:
Šarūnas Nejus 2025-08-08 22:02:37 +01:00 committed by GitHub
commit d8d227eee1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 1 deletions

View file

@ -305,7 +305,14 @@ class DiscogsPlugin(MetadataSourcePlugin):
# Explicitly reload the `Release` fields, as they might not be yet
# present if the result is from a `discogs_client.search()`.
if not result.data.get("artists"):
result.refresh()
try:
result.refresh()
except CONNECTION_ERRORS:
self._log.debug(
"Connection error in release lookup: {0}",
result,
)
return None
# Sanity check for required fields. The list of required fields is
# defined at Guideline 1.3.1.a, but in practice some releases might be

View file

@ -55,6 +55,8 @@ Bug fixes:
e.g. non latin characters as 盗作. If you want to keep the legacy behavior
set the config option ``spotify.search_query_ascii: yes``.
:bug:`5699`
* :doc:`plugins/discogs`: Beets will no longer crash if a release has been
deleted, and returns a 404.
For packagers: