8 Commits
Author SHA1 Message Date
Claude 0767c21a6f Add Docker Compose deployment
compose.yaml runs playlistd with a Postgres database. Settings come from
.env (see .env.example), and Postgres must be healthy before playlistd
starts.

The Dockerfile builds the web UI with Node and the server with Rust, then
copies both into a Debian slim image that runs as an unprivileged user. It
also installs the latest yt-dlp (with its YouTube scripts) and Deno, the
JavaScript runtime yt-dlp needs for YouTube. playlistd's port is only
published on 127.0.0.1 by default, since it has no login.

The image can't reach a database during the build, so the SQL query data
from `cargo sqlx prepare` is now committed in .sqlx/. Builds with
DATABASE_URL set still check queries against that database.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018opPJMJjLWr4RqdG6vuK6p
2026-11-14 10:22:23 +00:00
Claude 77f9f29cc6 Build the web UI into the .deb
- Package discover/dist to /usr/share/playlistd/discover, and serve it
  from there in the default config. cargo deb refuses to package if the
  UI hasn't been built, rather than shipping without it.
- Install a pinned Node.js (22.23.4, checksum-verified) in the
  Containerfile; Ubuntu 22.04's is too old for Vite. The README's build
  command now builds the UI first.
- Recommend yt-dlp, for playing suggested songs from YouTube.
- If discover.ui points to a missing directory, warn instead of letting
  Rocket panic at startup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018opPJMJjLWr4RqdG6vuK6p
2026-11-14 10:02:25 +00:00
Claude 4031ec7c08 Squash the branch's migrations into one
The three migrations added on this branch (cluster mixes, mix suggestions,
known songs) haven't been released, so they're combined into
20261113150000_cluster_mixes.sql. The resulting schema is identical.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018opPJMJjLWr4RqdG6vuK6p
2026-11-14 09:47:58 +00:00
Claude a594c56abc Set up logging properly
Rocket's logger was the only one, so messages from the daemons depended on
it having launched, and most messages bypassed logging with println!.

- Install env_logger at startup: level from log.level (LOG_LEVEL), with
  RUST_LOG overriding it. Rocket's per-request logs and sqlx's Postgres
  notices are kept to warnings.
- Under systemd, prefix lines with their syslog priority so journald
  records levels (journalctl -p warning works).
- Replace every println! with a log macro at a fitting level.
- Recurring failures are a warning when they start or change, debug while
  they repeat, and an info message when they recover.
- Listenbrainz errors are readable: an unknown user is "Listenbrainz user
  "x" doesn't exist" rather than a JSON decode error, and a period without
  stats yet (204) leaves the playlist alone instead of failing to decode.
  The UI's Refresh shows the same messages.
- Warnings name the playlist or rule they're about.
- Songs missing from the library are debug output, not errors every tick.
- Daemons no longer run twice at startup (interval's first tick is
  immediate), and a failing playlist rule or daemon is logged instead of
  panicking the task.
- Subsonic errors display as messages rather than Debug output.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018opPJMJjLWr4RqdG6vuK6p
2026-11-13 21:48:54 +00:00
Claude e176ddac6c Add UI for managing tracked playlists
A "Tracked playlists" page in the web UI lists, creates, edits, refreshes
and removes tracked playlists, and manages the rules that create a new
tracked playlist each period.

- New /api/tracked routes. Input is validated with readable errors,
  including name templates, which made the create daemon panic when they
  had an invalid % code.
- New playlists can be created in Subsonic or picked from existing ones.
  Genre mix playlists can't be tracked, since two daemons would fight
  over their songs.
- "Refresh" updates a playlist straight away, and the page shows when
  some of the top songs couldn't be found in the library.
- Removing a playlist can also delete it from Subsonic.
- Rule names preview live as you type.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018opPJMJjLWr4RqdG6vuK6p
2026-11-13 19:59:09 +00:00
Claude 2dd8621568 Mix known songs into discover mixes at a fixed ratio
"Play mix" in the discover UI used to spread new songs through the whole
library playlist, so the share of new songs depended on how many there
were. It now plays the new songs with songs the user has played mixed in
evenly at the rule's familiar_ratio (30% by default), the same ratio that
sets how much of the Subsonic playlist is familiar.

Which songs in each mix playlist were played recently is now recorded
when the mix is built (cluster_mix_playlist.known_song_ids) and returned
with the mix; the UI marks them as "Played". Mixes built before this fall
back to using the library songs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018opPJMJjLWr4RqdG6vuK6p
2026-11-13 17:00:14 +00:00
Claude a8b1123777 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
2026-11-13 16:39:46 +00:00
Claude 18b3f0974e Add genre mixes from clustering recent listens
A new cluster_mix_rule clusters a Listenbrainz user's listens from the
last few months by MusicBrainz genre (with tracks played in the same
session pulled together) and maintains one Subsonic playlist per cluster,
filled with the cluster's most played tracks plus unheard library songs
from the best matching library genres.

- listenbrainz: fetch raw listens since a timestamp and bulk recording
  genres, handling rate limits
- cluster: tag TF-IDF + co-listen smoothing, spherical k-means with k
  chosen by silhouette score
- mix: match cluster profiles to library genres and pick songs, with a
  per-artist cap; reuse playlists across rebuilds by genre overlap
- subsonic: getGenres, getSongsByGenre, rename/delete playlist, genre and
  MBID fields on tracks, API error detection
- daemon, migration, POST/GET /api/playlist/mix and README docs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018opPJMJjLWr4RqdG6vuK6p
2026-11-13 14:53:29 +00:00