From e151b4b49bb85cdf8074201b56fadfbc6079cab1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0ar=C5=ABnas=20Nejus?= Date: Mon, 19 May 2025 08:55:58 +0100 Subject: [PATCH] Implement track_for_id to allow fetching singletons by discogs id --- beetsplug/discogs.py | 8 ++++++++ docs/changelog.rst | 3 +++ 2 files changed, 11 insertions(+) diff --git a/beetsplug/discogs.py b/beetsplug/discogs.py index 34d8f21d1..696f1d1ac 100644 --- a/beetsplug/discogs.py +++ b/beetsplug/discogs.py @@ -241,6 +241,14 @@ class DiscogsPlugin(BeetsPlugin): return None return self.get_album_info(result) + def track_for_id(self, track_id: str) -> TrackInfo | None: + if album := self.album_for_id(track_id): + for track in album.tracks: + if track.track_id == track_id: + return track + + return None + def get_albums(self, query: str) -> Iterable[AlbumInfo]: """Returns a list of AlbumInfo objects for a discogs search query.""" # Strip non-word characters from query. Things like "!" and "-" can diff --git a/docs/changelog.rst b/docs/changelog.rst index ebb9880a9..825e287f6 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -19,6 +19,9 @@ New features: Media Session API to customize media notifications. * :doc:`plugins/discogs`: Add configurable ``search_limit`` option to limit the number of results returned by the Discogs metadata search queries. +* :doc:`plugins/discogs`: Implement ``track_for_id`` method to allow retrieving + singletons by their Discogs ID. + :bug:`4661` Bug fixes: