Add discover UI with new song suggestions

Each mix rebuild now also finds songs that aren't in the library: the
user's Listenbrainz recommendations they've never played, plus an LB
Radio prompt per mix when a Listenbrainz token is configured. Each
candidate goes to the mix whose genre profile it fits best and is
skipped if it's already in the library or was played recently.

discover/ is a new React app to listen to the mixes: library songs
stream from Subsonic and suggested songs are found on YouTube with
yt-dlp, both proxied through playlistd with Range support for seeking.
Suggestions can be liked (kept in a "Liked new songs" list) or hidden.

- discover: candidate gathering, genre fit scoring, library filtering
- web: /api/discover routes, Subsonic/YouTube streaming proxy
- youtube: yt-dlp search (skipping hour-long results) and audio URLs
- mix tags now hold library genre names, for display in the UI
- config: listenbrainz.token, discover.ui, discover.ytdlp, discover.format

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018opPJMJjLWr4RqdG6vuK6p
This commit is contained in:
Claude committed 2026-11-13 16:39:46 +00:00
1 parent 18b3f0974e
commit a8b1123777
32 files changed
+4628 -36

No files matched your search

+45
View File
@@ -109,5 +109,50 @@ VALUES (gen_random_uuid(), 'jellywx', 3, 50);
| `familiar_ratio` | 0.3 | Share of each mix taken from recently played tracks |
| `name_template` | `Mix: {label}` | Playlist name; `{label}` becomes the mix's top genres |
| `refresh_hours` | 24 | How often to rebuild the mixes |
| `discovery_count`| 15 | New songs (not in your library) to suggest per mix |
Set `last_run` to `NULL` to rebuild a rule's mixes on the next daemon tick.
### Discover UI
`discover/` is a React app for listening to the genre mixes, alongside new songs that aren't in
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 `listenbrainz.token` is set, an LB Radio playlist for each mix's top genres.
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.
In the UI, songs from your library stream from Subsonic. New songs are found on YouTube with
[yt-dlp](https://github.com/yt-dlp/yt-dlp) and streamed through playlistd, so yt-dlp needs to be
installed on the server (keep it up to date: YouTube changes often break older versions). You can
like a new song to keep it in "Liked new songs", or hide it so it isn't suggested again.
Build it with:
```sh
cd discover
npm install
npm run build
```
and set `discover.ui` (or `DISCOVER_UI`) to the `discover/dist` directory to serve it from
playlistd at `/`. For development, `npm run dev` serves the UI with hot reload and forwards API
requests to playlistd on `localhost:8000` (or `PLAYLISTD_URL`).
The UI uses these endpoints under `/api/discover`:
| Endpoint | Purpose |
|--------------------------------|------------------------------------------------------|
| `GET /rules` | Cluster mix rules |
| `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 |
| `PUT /suggestions/<id>` | Set a suggestion's status (`new`, `liked`, `dismissed`) |
| `POST /rules/<id>/rebuild` | Rebuild a rule's mixes on the next daemon tick |
| `GET /stream/<song id>` | Stream a library song from Subsonic |
| `GET /cover/<cover art id>` | Library cover art from Subsonic |
| `GET /youtube/<suggestion id>` | Stream a suggested song from YouTube |