Module coverart

Source
Expand description

The Cover Art Archive: the front image of a record, when it has one.

Deliberately no network, like crate::musicbrainz: this module turns an index somebody else fetched into an address to download, and decides which image is the front one. Reaching the address is the client’s job.

§The index says what exists, so nothing here guesses

Asking coverartarchive.org about a release answers with a small JSON document — not the image — listing every image it holds:

{ "images": [ { "front": true, "types": ["Front"], "approved": true,
                "image": "…/12345.jpg",
                "thumbnails": { "250": "…", "500": "…", "1200": "…" } } ],
  "release": "https://musicbrainz.org/release/…" }

The sizes are named in the answer, so a caller asking for 1200 px is told whether one exists rather than being sent to an address that might 404. That is why the index is fetched first: one small request decides everything, including whether there is anything to download at all.

Structs§

Front
The front image of a record, at the size asked for.
RenderedImage
A validated original or a derived PNG thumbnail kept only in memory.

Enums§

Kind
What a picture is of, for the few kinds worth telling apart.
Size
Which image to take, of the ones the archive offers.
Written
What became of one image.

Constants§

EXTRAS
The subfolder everything that is not the cover is written into.
SOURCE
The name records from this service carry in sources.json.
WEB_SERVICE
Base address of the service.

Functions§

artist_destination
Existing artist artwork location; watched roots are never artist folders. An unavailable or path-shaped fallback identifier has no cache destination.
asset_destination
Confined cache directory for an artist or label’s opaque identifier.
exists_beside
Whether an image of this kind is already sitting beside the music, under either extension write_image can produce.
exists_image
Whether this image already exists at the name write_image would use.
extras_in
Where the images that are not the cover belong, for one album folder.
file_name
What to call the file written beside the music.
front
Picks the front image out of an index, at the size asked for.
image_kind
Which supported format signature these bytes carry.
image_name
What to call one image of a given kind, when several may share it.
images
Every image an index holds, with what each one is of.
index_url
Where to ask what images a record has.
positions
Where each image sits among the others of its own kind.
release_index_url
Where to ask about one precise edition, when the tags name one.
render_image
Validate an image and optionally produce a thumbnail for a client response.
shared_artist_folder
Parent shared by every local edition, absent when editions span folders.
validate_index
Refuses a malformed index before a caller records it as having no artwork.
write_beside
Writes an image beside music, or says why it did not.
write_image
Writes one image of a known kind, under the name that says what it is.