Add album art backend: MusicBrainz + Cover Art Archive, proxied and cached

New GET /api/v1/art/album?artist=&album= resolves and streams an
album's cover art. Lookups go through MusicBrainz release-group
search then Cover Art Archive's release-group front-image endpoint,
both free and keyless - no setup required by self-hosters. Results
(hits, misses and errors) are cached in a new album_art table keyed
case-insensitively on (artist, album), since Scrobble.mbid can't be
trusted as a release identifier.

The service layer separates resolving where the art is (lookup())
from fetching the bytes (fetch_image()) so a future move to storing
the bytes ourselves only touches the latter.

Also widens the UI's CSP (img-src) to allow blob: URLs, since the
frontend will fetch art with the existing bearer-auth header and
hand the browser a blob: object URL rather than hotlinking.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
mattandClaude Sonnet 5 committed 2026-10-06 17:05:57 +01:00
1 parent 7b169ea807
commit 5bdeeddb0b
13 files changed
+627 -2

No files matched your search

+81
View File
@@ -1503,6 +1503,83 @@
}
]
},
"/api/v1/art/album": {
"get": {
"parameters": [
{
"in": "query",
"name": "artist",
"schema": {
"type": "string",
"minLength": 1,
"maxLength": 500
},
"required": true
},
{
"in": "query",
"name": "album",
"schema": {
"type": "string",
"minLength": 1,
"maxLength": 500
},
"required": true
}
],
"responses": {
"422": {
"$ref": "#/components/responses/UNPROCESSABLE_CONTENT"
},
"502": {
"description": "MusicBrainz or Cover Art Archive is unreachable",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"404": {
"description": "No cover art found for this album",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"200": {
"description": "The album's cover art"
},
"401": {
"description": "Not authenticated",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"default": {
"$ref": "#/components/responses/DEFAULT_ERROR"
}
},
"summary": "An album's cover art",
"description": "Resolved via MusicBrainz + Cover Art Archive and cached; bytes are proxied on every\ncall, so cache this response client-side.",
"tags": [
"Art"
],
"security": [
{
"bearerAuth": []
}
]
}
},
"/healthz": {
"get": {
"responses": {
@@ -3374,6 +3451,10 @@
"name": "Imports",
"description": "Import listening history from a Last.fm export file, or straight from Last.fm. Imports run in the background; poll a job to follow its progress."
},
{
"name": "Art",
"description": "Album art, proxied from MusicBrainz / Cover Art Archive"
},
{
"name": "Health",
"description": "Liveness for load balancers and containers"