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>
51 lines
1.5 KiB
Python
51 lines
1.5 KiB
Python
"""album art cache
|
|
|
|
Revision ID: 3ba21eb1ea0c
|
|
Revises: e7fb730bac15
|
|
Create Date: 2026-10-06 16:58:58.755196
|
|
|
|
"""
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = "3ba21eb1ea0c"
|
|
down_revision = "e7fb730bac15"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table(
|
|
"album_art",
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("artist", sa.Text(), nullable=False),
|
|
sa.Column("album", sa.Text(), nullable=False),
|
|
sa.Column("status", sa.String(length=16), nullable=False),
|
|
sa.Column("image_url", sa.Text(), nullable=True),
|
|
sa.Column("release_group_mbid", sa.String(length=36), nullable=True),
|
|
sa.Column("error_code", sa.String(length=64), nullable=True),
|
|
sa.Column("checked_at", sa.DateTime(timezone=True), nullable=False),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
with op.batch_alter_table("album_art", schema=None) as batch_op:
|
|
batch_op.create_index(
|
|
"uq_album_art_artist_album_lower",
|
|
[sa.literal_column("lower(artist)"), sa.literal_column("lower(album)")],
|
|
unique=True,
|
|
)
|
|
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
with op.batch_alter_table("album_art", schema=None) as batch_op:
|
|
batch_op.drop_index("uq_album_art_artist_album_lower")
|
|
|
|
op.drop_table("album_art")
|
|
# ### end Alembic commands ###
|