Skip to content

Add Wikipedia provider and associated plumbing#3972

Merged
MarvinSchenkel merged 5 commits into
devfrom
add-wikipedia-metadata-provider
May 28, 2026
Merged

Add Wikipedia provider and associated plumbing#3972
MarvinSchenkel merged 5 commits into
devfrom
add-wikipedia-metadata-provider

Conversation

@OzGav
Copy link
Copy Markdown
Contributor

@OzGav OzGav commented May 25, 2026

What does this implement/fix?

A new Wikipedia metadata provider that fetches artist biographies in the user's preferred language, falling back to English. It finds the right Wikipedia article via the artist's MusicBrainz links (and Wikidata where MusicBrainz doesn't list one), then pulls the article's intro text.

As there are now two biography-supplying metadata providers it is necessary to populate the database with the best one and in the right language. So this also:

  • Updates TheAudioDB to report which language its bio is in. Previously it returned text with no language label; now it tags it (e.g. en, nl) so the system can compare it against the user's preference.
  • Updates Qobuz the same way. Its API returns a language code with the bio, so we now tag it rather than guess.
  • Adds bio-selection logic to the metadata controller. When several providers can supply a bio, it now picks the best one by a clear rule:
    • prefer the first bio in the user's language, in provider priority order (music, then TheAudioDB, then Wikipedia);
    • fall back to English only if no provider has the user's language and we don't already have a bio in that language stored;
    • a music provider's bio counts as the user's language or English only when the provider reports the language with certainty; if it leaves the language unknown, the bio is used only as a last resort;
    • a bio already stored in the user's language is never replaced by one not in the users preferred language;
    • the bio refreshes on each metadata update, so edits to the source article are picked up over time.
  • Adds unit tests covering each of those selection outcomes, so the behaviour can't silently break.

Related issue (if applicable):

  • related issue

Types of changes

  • Bugfix (non-breaking change which fixes an issue) — bugfix
  • New feature (non-breaking change which adds functionality) — new-feature
  • Enhancement to an existing feature — enhancement
  • New music/player/metadata/plugin provider — new-provider
  • Breaking change (fix or feature that would cause existing functionality to not work as expected) — breaking-change
  • Refactor (no behaviour change) — refactor
  • Documentation only — documentation
  • Maintenance / chore — maintenance
  • CI / workflow change — ci
  • Dependencies bump — dependencies

Checklist

  • The code change is tested and works locally.
  • pre-commit run --all-files passes.
  • pytest passes, and tests have been added/updated under tests/ where applicable.
  • For changes to shared models, the companion PR in music-assistant/models is linked.
  • For changes affecting the UI, the companion PR in music-assistant/frontend is linked.
  • I have read and complied with the project's AI Policy for any AI-assisted contributions.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 25, 2026

🔒 Dependency Security Report

✅ No dependency changes detected in this PR.

@OzGav OzGav marked this pull request as draft May 25, 2026 04:53
@OzGav OzGav marked this pull request as ready for review May 25, 2026 05:15
@marcelveldt
Copy link
Copy Markdown
Member

Also don't forget about a Music provider itself providing a bio/description. For example Qobuz provides (localized) artist bio's

@MarvinSchenkel MarvinSchenkel requested a review from Copilot May 26, 2026 11:37
Comment thread music_assistant/providers/theaudiodb/__init__.py
Copy link
Copy Markdown
Contributor

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@OzGav
Copy link
Copy Markdown
Contributor Author

OzGav commented May 26, 2026

I wrestled with this. I wasn't sure if a music provider returns a language code with the bio text so we know for certain what language it's in. I just checked Qobuz and it does, so I've changed Qobuz to populate the language field and adjusted the selection to favour music provider bios.

The order is now: first bio in the user's preferred language wins (music, then TADB, then Wikipedia), otherwise keep an existing preferred language bio, otherwise fall back to English in that same order, and only use an unknown language bio as a last resort.

I'll ask the other devs who populate artist.description to populate the language field too, but only when they know it for certain. If they leave it as None, that bio won't count as preferred language or English, so anything with a confident match will be used ahead of it.

@OzGav OzGav mentioned this pull request May 26, 2026
@OzGav OzGav added this to the 2.10.0 milestone May 28, 2026
Copy link
Copy Markdown
Contributor

@MarvinSchenkel MarvinSchenkel left a comment

Choose a reason for hiding this comment

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

Thanks @OzGav !

@MarvinSchenkel MarvinSchenkel merged commit ef2f2de into dev May 28, 2026
11 checks passed
@MarvinSchenkel MarvinSchenkel deleted the add-wikipedia-metadata-provider branch May 28, 2026 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants