Skip to content

Proposal: Refactor metadata source search API: Source + SearchQuery with legacy fallback - #6943

Draft
semohr wants to merge 2 commits into
masterfrom
change_candidates_api
Draft

Proposal: Refactor metadata source search API: Source + SearchQuery with legacy fallback#6943
semohr wants to merge 2 commits into
masterfrom
change_candidates_api

Conversation

@semohr

@semohr semohr commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Modernizes the metadata source plugin search API:

  • candidates(items, artist, album, va_likely)candidates(source, search_query)
  • item_candidates(item, artist, title)item_candidates(source, search_query)

This PR keeps the legacy signatures working during the transition: the dispatch layer detects plugins that still implement the old API, converts the new arguments for them, and emits a deprecation warning. Nothing in any plugin (built-in or third-party) needs to change for beets to keep working.

Why

The old search signatures hand plugins a handful of derived strings. The new API gives plugins the full search context instead:

  • Source: the items themselves (for barcode/ISRC/catalog-number lookups), the consensus artist/album and va_likely, and ID consensus.
  • SearchQuery: structured user-supplied search parameters, or None when no manual search was requested.

The old signature did not allow plugins to tell consensus values apart from user-supplied searches: the artist and album strings contained whichever was available, with no way to distinguish the two for plugins. This is, for example, an issue for Tidal, which checks for ISRCs and barcodes and uses them for lookups, which should not happen for manual search queries. This is currently impossible to detect.

As an alternative, these IDs could be extracted in the core layer as well (similar to the mb/spotify/tidal IDs), but that would require the same amount of refactoring and likely changes to albums_for_ids. A bit of a question how much control we want to give plugins during search.


This is still work in progress: the docs need updating and some tests are currently broken. Before investing more time, I'd like to check whether we are happy with this approach as it will break the plugin api at some point!

semohr added 2 commits August 19, 2026 13:57
unifies `tag_album` and`tag_item` quite a bit. We might be able to
combine the functions in the future.
@github-actions

Copy link
Copy Markdown

Thank you for the PR! The changelog has not been updated, so here is a friendly reminder to check if you need to add an entry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant