Create and delete genre mixes from the web UI

- Add a form to create a cluster mix rule: shown on first visit when there
  are no rules, and from a + in the sidebar for another Listenbrainz user.
  Backed by POST /api/discover/rules, which validates each setting and
  allows one rule per Listenbrainz user.
- Add deleting a user's mixes from a bin in the sidebar, optionally also
  deleting the mixes' playlists from Subsonic. Backed by
  DELETE /api/discover/rules/<id>?delete_playlists=true.
- Stop showing the previous user's mix while a new user's mixes build.
- Remove the per-account Listenbrainz token: LB Radio now always uses
  listenbrainz.token from the config. A migration drops the token columns
  from app_user, and PUT /api/auth/account/listenbrainz is gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
judeandClaude Opus 5.5 committed 2026-11-22 09:45:52 +00:00
1 parent f5cb5076ca
commit 93e12cfc72
23 files changed
+701 -344

No files matched your search

+20 -11
View File
@@ -92,8 +92,9 @@ from it is logged too.
Each of these will work best when your music library is well organised with Musicbrainz metadata.
Tracked playlists, recurring playlists and genre mixes can all be managed from the web UI (see
[Discover UI](#discover-ui)), under "Tracked playlists". The SQL below does the same by hand.
Tracked playlists and recurring playlists can be managed from the web UI (see
[Discover UI](#discover-ui)), under "Tracked playlists", and genre mixes are created there too. The
SQL below does the same by hand.
### Tracked playlist
@@ -138,10 +139,19 @@ Mixes are rebuilt every `refresh_hours`. On a rebuild, existing mix playlists ar
new cluster with the most similar genres (and renamed), new playlists are created for new
clusters, and playlists for clusters that no longer appear are deleted.
Create a rule through the API (after logging in, see [Logging in](#logging-in)):
Create a rule from the web UI: the first time you open it, it asks for your Listenbrainz user and
how to build the mixes. To add mixes for another Listenbrainz user, use the + next to the current
one in the sidebar. Each Listenbrainz user can have one rule.
To stop making a user's mixes, use the bin next to their name in the sidebar. This deletes the rule
with its mixes and suggestions (liked ones too), and, unless you untick it, the mixes' playlists in
Subsonic. (Mixes are regrouped on every rebuild, so there's no deleting a single mix: it would just
come back.)
Or through the API (after logging in, see [Logging in](#logging-in)):
```sh
curl -b cookies -X POST localhost:8000/api/playlist/mix -H 'Content-Type: application/json' \
curl -b cookies -X POST localhost:8000/api/discover/rules -H 'Content-Type: application/json' \
-d '{"tracking_user": "jellywx", "months": 3, "playlist_size": 50}'
```
@@ -172,8 +182,10 @@ your library yet.
Each time the mixes are rebuilt, playlistd also looks for new songs for each mix:
* your Listenbrainz recommendations, keeping only recordings you've never listened to, and
* if a Listenbrainz token is saved to your account (or `listenbrainz.token` is set), an LB Radio
playlist for each mix's top genres.
* if `listenbrainz.token` (or `LISTENBRAINZ_TOKEN`) is set to a Listenbrainz user token, an LB
Radio playlist for each mix's top genres. Find your token at
[listenbrainz.org/settings](https://listenbrainz.org/settings/). It's used for every mix, whichever
Listenbrainz user it's for.
Every candidate's MusicBrainz genres are compared with each mix's, and it's suggested in the mix
it fits best (if it fits well enough), skipping songs already in your library.
@@ -214,10 +226,6 @@ will set it up again:
DELETE FROM app_user;
```
Under the account page in the UI (your username, in the sidebar), you can save your Listenbrainz
user token to your account. It's checked with Listenbrainz first, and is then used instead of
`listenbrainz.token` from the config.
To use the API from a script, log in with a cookie jar and pass it with each request:
```sh
@@ -236,7 +244,6 @@ under `/api/auth`:
| `POST /login` | Log in (`username`, `password`) |
| `POST /logout` | Log out |
| `GET /account` | The logged in account |
| `PUT /account/listenbrainz` | Save a Listenbrainz `token` to the account (empty removes it) |
### Endpoints
@@ -245,6 +252,8 @@ The UI uses these endpoints under `/api/discover`:
| Endpoint | Purpose |
|--------------------------------|------------------------------------------------------|
| `GET /rules` | Cluster mix rules |
| `POST /rules` | Create a cluster mix rule (`tracking_user`, plus any of the columns above) |
| `DELETE /rules/<id>?delete_playlists=true` | Delete a rule, its mixes and suggestions, optionally deleting the playlists from Subsonic |
| `GET /rules/<id>/mixes` | A rule's mixes |
| `GET /mixes/<id>` | A mix's library songs and new song suggestions |
| `GET /rules/<id>/liked` | Liked suggestions |