feat: a release catalogue from MusicBrainz; request search asks it directly (M502 #5519)
release / govulncheck (push) Successful in 22s
release / web (push) Failing after 24s
release / go (push) Successful in 1m57s
release / integration (push) Successful in 4m1s
release / Attach APK to the Release (tag releases only) (push) Canceled after 0s
release / Build + push container image (push) Canceled after 0s
release / Verify release artifacts (tag releases only) (push) Canceled after 0s
release / android (push) Canceled after 4m38s
release / Build signed APK (releases and dev) (push) Canceled after 4m37s

Minstrel keeps its own record of what artists have released, read from
MusicBrainz, so the wanted list, search and import no longer need Lidarr.

- internal/musicbrainz: searches (artists, release groups, recordings) and
  browses (an artist's release groups; a group's releases with track lists).
  One process-wide pacer at 1.1s, shared with tag enrichment, because
  MusicBrainz's limit is per address. A 503 throttle is retried.
- Migration 0080: mb_artists, mb_release_groups, mb_artist_release_groups
  (a collaboration belongs to each credited artist), mb_releases,
  mb_release_tracks.
- internal/catalogue: Discography and Releases serve the held copy and
  re-read it when older than 7 or 30 days. An unreachable MusicBrainz
  serves the stale copy, marked. An hourly pass re-reads due artists.
- Art for what isn't held comes through /api/catalogue/art from the
  enabled cover-art sources (Cover Art Archive by release group, then the
  name-based sources) and is kept on disk, so the browser never fetches a
  third-party host. A miss is a 404 and the card shows its icon.
- Request search moves from /api/lidarr/search to /api/catalogue/search,
  with the same response shape. Albums are release groups, and "in
  library" matches albums.release_group_mbid. A 10-minute cache absorbs
  search-as-you-type. Discover suggestions point at the art endpoint
  instead of looking up Lidarr.
- Android calls the new path and loads Discover art through ServerImage.
  Installed builds older than this one lose Discover search until they
  update (no compatibility path, rule 22).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-09 21:08:22 -04:00
co-authored by Claude Opus 5.5
parent a2e1890d4c
commit 77389f88bc
40 changed files with 3223 additions and 577 deletions
@@ -0,0 +1,5 @@
DROP TABLE IF EXISTS mb_release_tracks;
DROP TABLE IF EXISTS mb_releases;
DROP TABLE IF EXISTS mb_artist_release_groups;
DROP TABLE IF EXISTS mb_release_groups;
DROP TABLE IF EXISTS mb_artists;
@@ -0,0 +1,86 @@
-- 0080_release_catalogue.up.sql — Minstrel's own copy of what artists have
-- released, read from MusicBrainz (Scribe milestone #502, #5519).
--
-- With Lidarr gone, the wanted list, search and import need to know an
-- artist's discography and each release's track list. MusicBrainz allows one
-- request a second, so what has been read is kept here and refreshed on a
-- schedule rather than asked again for every page.
--
-- mb_artists artists the catalogue has been asked about.
-- mb_release_groups what a person calls an album (Lidarr's albums
-- were release groups too), with MusicBrainz's
-- primary and secondary types.
-- mb_artist_release_groups who is credited on each group: a collaboration
-- belongs to every credited artist's discography.
-- mb_releases the editions of a group, read when something
-- needs a track list.
-- mb_release_tracks each release's track list.
--
-- Dates stay as MusicBrainz's partial-date text ("1997", "1997-05",
-- "1997-05-21"): most early releases have only a year.
CREATE TABLE mb_artists (
mbid text PRIMARY KEY,
name text NOT NULL,
sort_name text NOT NULL DEFAULT '',
disambiguation text NOT NULL DEFAULT '',
artist_type text NOT NULL DEFAULT '',
country text NOT NULL DEFAULT '',
-- When the discography was last read in full; NULL means never.
discography_refreshed_at timestamptz,
created_at timestamptz NOT NULL DEFAULT now(),
updated_at timestamptz NOT NULL DEFAULT now()
);
CREATE INDEX mb_artists_refresh_idx ON mb_artists (discography_refreshed_at NULLS FIRST);
CREATE TABLE mb_release_groups (
mbid text PRIMARY KEY,
title text NOT NULL,
primary_type text NOT NULL DEFAULT '',
secondary_types text[] NOT NULL DEFAULT '{}',
first_release_date text NOT NULL DEFAULT '',
artist_credit text NOT NULL DEFAULT '',
-- When the releases and their track lists were last read; NULL means never.
releases_refreshed_at timestamptz,
created_at timestamptz NOT NULL DEFAULT now(),
updated_at timestamptz NOT NULL DEFAULT now()
);
CREATE TABLE mb_artist_release_groups (
artist_mbid text NOT NULL REFERENCES mb_artists (mbid) ON DELETE CASCADE,
release_group_mbid text NOT NULL REFERENCES mb_release_groups (mbid) ON DELETE CASCADE,
PRIMARY KEY (artist_mbid, release_group_mbid)
);
CREATE INDEX mb_artist_release_groups_group_idx ON mb_artist_release_groups (release_group_mbid);
CREATE TABLE mb_releases (
mbid text PRIMARY KEY,
release_group_mbid text NOT NULL REFERENCES mb_release_groups (mbid) ON DELETE CASCADE,
title text NOT NULL,
status text NOT NULL DEFAULT '',
release_date text NOT NULL DEFAULT '',
country text NOT NULL DEFAULT '',
disambiguation text NOT NULL DEFAULT '',
formats text NOT NULL DEFAULT '',
track_count integer NOT NULL DEFAULT 0,
created_at timestamptz NOT NULL DEFAULT now()
);
CREATE INDEX mb_releases_group_idx ON mb_releases (release_group_mbid);
CREATE TABLE mb_release_tracks (
release_mbid text NOT NULL REFERENCES mb_releases (mbid) ON DELETE CASCADE,
medium_position integer NOT NULL,
position integer NOT NULL,
medium_format text NOT NULL DEFAULT '',
number text NOT NULL DEFAULT '',
title text NOT NULL,
length_ms integer NOT NULL DEFAULT 0,
recording_mbid text NOT NULL DEFAULT '',
PRIMARY KEY (release_mbid, medium_position, position)
);
CREATE INDEX mb_release_tracks_recording_idx ON mb_release_tracks (recording_mbid)
WHERE recording_mbid <> '';