Expand description
Wikipedia, reached through Wikidata: the prose MusicBrainz does not hold.
MusicBrainz answers with identifiers, dates and relationships. It never
answers with a sentence about the artist, because that is not what it is
for. The sentence exists on Wikipedia — and the way from one to the other
is the wikidata relationship MusicBrainz already returns.
Two requests, not one. A Wikidata entity is the hub: it holds a sitelink per language, and a sitelink is a page title rather than a summary. So reaching a paragraph is
MusicBrainz artist → wikidata: .../wiki/Q11649
Special:EntityData/Q11649.json → sitelinks.enwiki.title
en.wikipedia.org/…/summary/<title> → extractThat is why this is opt-in rather than part of every fetch: it doubles a run that already takes ten minutes over a large library, and the summary is the one fact here nobody needs in order to file their music.
Everything in this module is a decision, and none of it is a request.
The two URL builders and the two extractors below are pure functions over
text and JSON, so what the program concludes from an answer is proven by
the tests beside them, and only the handing of a URL to a client library is
left unproven — the same split crate::musicbrainz follows.
§The licence is not optional
Wikipedia text is CC BY-SA. Reusing it obliges attribution, so the extract
is only ever produced as a Prose, which cannot hold the words without
the page they came from and the terms they came under. There is deliberately
no function here that returns a bare String of article text.
Structs§
- Article
- An article on one language’s Wikipedia.
Constants§
- FALLBACK_
LANGS - Languages to look for an article in, best first.
- LICENCE
- The licence Wikipedia article text is under.
- PORTRAIT_
SOURCE - The name a portrait reached through Wikidata is stored under.
- REQUEST_
INTERVAL - How long to leave between requests.
- SOURCE
- The name this source is stored under in
sources.json.
Functions§
- article
- The article to read, from a
Special:EntityDatadocument. - commons_
file_ url - Where to download a Commons file, at a given width.
- entity_
data_ url - Where to ask Wikidata about an entity.
- entity_
id - The Wikidata entity id inside a URL MusicBrainz returned.
- portrait_
file - The Commons filename in a Wikidata entity’s
imageclaim (P18), if it states one. - prose
- The paragraph, credited, from a REST summary document.
- summary_
url - Where to ask for an article’s opening paragraph.
- validate_
entity - Checks the entity response before a fetch records a completed absence.
- validate_
portrait - Checks portrait tables before a fetch records a completed absence.
- validate_
summary - Distinguishes a readable summary or genuine absence from an invalid body.