Skip to content

Refactor of metadata plugin and opt in all metadata plugins to new baseclass #5787

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

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

semohr
Copy link
Contributor

@semohr semohr commented May 17, 2025

Description

At the moment the MetaDataSourcePlugin has multiple responsibilities:

  • fetch data via _search api
  • defines contract for interaction within the beets autotag lookup

I propose splitting these responsibilities, as it would enable us to use the MetaDataSourcePlugin baseclass with plugins that use external packages to fetch data.

This follows from discussion in #5761 and #5748 (comment).

Feedback is highly appreciated, as this is mainly architectural decision and I would prefer if the new behavior is a shared consensus.

To Do

  • Opt in plugins into the new MetaDataSourcePlugin
    • Spotify
    • Musicbrainz
    • Deezer
    • Beatport
    • Chroma
    • Disccogs
  • Remove old MetaDataSourcePlugin and related functions
  • Documentation on the ontology of plugins
  • Changelog

This PR was initially #5764 and was accidentally closed as the target branch was deleted. Wasn't able to recover the original PR.

@Copilot Copilot AI review requested due to automatic review settings May 17, 2025 08:54
Copy link

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.

Copilot

This comment was marked as outdated.

@semohr semohr requested a review from Copilot May 18, 2025 13:54
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the metadata lookup architecture by introducing a new beets.metadata_plugins module with a single base interface and migrating all existing source plugins to use it.

  • Added beets/metadata_plugins.py defining MetadataSourcePluginNext and SearchApiMetadataSourcePluginNext
  • Updated all core and third-party plugins (Spotify, MusicBrainz, Discogs, Deezer, Beatport, Chroma/Acoustid, mbsync, missing) to inherit from the new base classes
  • Adjusted tests and documentation to patch and reference beets.metadata_plugins instead of the old beets.plugins metadata methods

Reviewed Changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/test_ui.py Adjusted plugin-loading assertion to use new API
test/test_importer.py Patches updated to beets.metadata_plugins lookups
test/plugins/test_mbsync.py References to plugins.track_for_id/album_for_id replaced
docs/dev/plugins.rst Documentation revised for new metadata plugin interface
docs/dev/index.rst Added Confuse library link
beets/util/id_extractors.py Fixed key lookup to use lowercase source names
beets/plugins.py Removed old metadata plugin base and helper methods
beets/metadata_plugins.py New metadata plugin interface and loader functions
beetsplug/spotify.py Migrated Spotify plugin to SearchApiMetadataSourcePluginNext
beetsplug/musicbrainz.py Updated MusicBrainz plugin to MetadataSourcePluginNext
beetsplug/missing.py Switched plugins.* calls to metadata_plugins.*
beetsplug/mbsync.py Updated track/album lookup to new API
beetsplug/discogs.py Refactored Discogs plugin to new metadata interface
beetsplug/deezer.py Migrated Deezer plugin to SearchApiMetadataSourcePluginNext
beetsplug/chroma.py Adapted Acoustid plugin to new base and import patterns
beetsplug/beatport.py Refactored Beatport plugin to new base class and models
Comments suppressed due to low confidence (2)

test/test_ui.py:1062

  • [nitpick] The variable name plugs is ambiguous; consider renaming to found_plugins or loaded_plugins for clarity.
plugs = plugins.find_plugins()

beetsplug/chroma.py:29

  • TrackInfo is not exported by beets.metadata_plugins at runtime; import it from beets.autotag.hooks instead.
from beets.metadata_plugins import MetadataSourcePluginNext, TrackInfo

@snejus

This comment was marked as resolved.

@semohr semohr force-pushed the metadatasource-cleanup branch from c252adc to 2f0b610 Compare May 18, 2025 14:14
@semohr

This comment was marked as resolved.

fixed minor suggestions from copilot review
@semohr semohr requested review from snejus and wisp3rwind May 18, 2025 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants