Let a tag play several albums in order

An assignment is now an ordered list of albums (e.g. one vinyl compiling two EPs that are separate releases in the library). Albums move to their own table, with a migration for existing databases. The scan and lookup responses return an albums list instead of the single artist/album/uri fields. The tag page lists its albums with up, down and remove, and search results get an Add button.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-26 11:44:44 +00:00
co-authored by Claude Opus 5.5
parent a2f421c272
commit 5878adb756
11 changed files with 536 additions and 259 deletions
+4 -2
View File
@@ -21,11 +21,13 @@ Both endpoints need `Authorization: Bearer <API_TOKEN>`.
| Endpoint | Purpose |
|---|---|
| `POST /api/scans` `{"tag_id": "53-13-0B-2A"}` | Record a Scan; creates the Tag on first sight. Returns `{"tag_id", "assigned": true, "artist", "album", "uri"}` or `{"tag_id", "assigned": false}`. `uri` is the album's Music Assistant URI (e.g. `library://album/2846`), checked against the library on every scan; `null` means play by name. |
| `GET /api/tags/{tag_id}` | Read-only lookup, same response, with the stored `uri` unchecked. `404` if the tag has never been seen. |
| `POST /api/scans` `{"tag_id": "53-13-0B-2A"}` | Record a Scan; creates the Tag on first sight. Returns `{"tag_id", "assigned", "albums": [{"artist", "album", "uri"}, …]}`, the albums in play order (empty when unassigned). Each `uri` is the album's Music Assistant URI (e.g. `library://album/2846`), checked against the library on every scan; `null` means play by name. |
| `GET /api/tags/{tag_id}` | Read-only lookup, same response, with the stored URIs unchecked. `404` if the tag has never been seen. |
Tag IDs are normalised to upper case.
A tag usually plays one album, but can play several in order, e.g. a vinyl that compiles two EPs the library has as separate releases. HA plays the first album (replacing the queue) and queues the others after it. On the web page, **Add** appends an album to a tag and **Assign** replaces all of them; the tag's page reorders and removes them.
HA plays by `uri` when there is one, because a library can hold near-duplicate albums whose names differ only in capitals, and only one of them may be playable. On each scan the service checks the stored URI is still in the library. If it's gone (e.g. after a library rebuild), it finds the album by name again, preferring the exact spelling, and stores the new URI.
The web page (`/`) has no login: keep the service on the LAN.