Skip to content

For You: suggestions from what you play, worked out locally - #14

Merged
junaydirfan merged 2 commits into
masterfrom
discover
Nov 24, 2026
Merged

junaydirfan merged 2 commits into
masterfrom
discover

Conversation

@junaydirfan

@junaydirfan junaydirfan commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

A new sidebar entry, ✦ For You: 50 songs picked from what you actually play. The ranking happens on your machine, and every row says why it's there.

How it works

  1. What you play, logged locally. Each song played for 30 s is appended to ~/.local/share/trill/plays (unix time, uri, title, artist, about 100 bytes a song). It's only read when For You is worked out, so it costs no memory otherwise. While the log is short (under 15 songs), your 50 newest liked songs are seeds too, at half weight, fading over a month.
  2. Seeds. Each play counts half as much every 14 days. The top 4 songs are seed songs. The top 4 artists come from the first artist of your top 40 songs, adding up the songs' weights.
  3. Candidates, fetched in parallel (up to 8 requests at a time):
    • the radio of each seed song: the same apollo station request smart shuffle uses, first 25 songs;
    • each seed artist's page: the same GraphQL queryArtistOverview the artist page already sends for play counts. It lists related artists. The 12 strongest (earlier in a list counts more, and several seeds listing one artist add up) have their pages fetched for their top 4 songs;
    • titles and covers for all candidates in one batched metadata request.
  4. Ranking (local, discover::rank). Candidates for the same song add up, and the strongest reason is kept. Liked songs, saved albums and followed artists, "not interested" songs and the seeds themselves are left out. A song played n times in the last 30 days counts 1/(1+n). Then a greedy pick in which each further song by the same first artist counts half (at most 3 per artist), and each further song from the same source (one seed's radio, one artist's neighbours) counts 0.8, so the sources mix. Genres aren't in the metadata trill gets, so variety comes from artists and sources.
  5. Why: radio · <seed song> or like <your artist>, in the column blends use for "For".
  6. Cache. The result is saved like any list (~/.cache/trill/lists/trill_foryou). Opening For You shows it at once (5 ms in tmux) and only works it out again after 12 h, or on R (about 2 s).
  7. X = not interested, on a For You song or a ✦ smart-shuffle song. It's kept in ~/.local/share/trill/not_interested. The song leaves For You at once, a ✦ song leaves the queue (and is skipped if playing), and smart shuffle leaves it out from then on.

What goes to Spotify

Through the same session and the same endpoints trill already uses for browsing, artist pages and smart shuffle: up to 4 seed song ids (radio), up to 40 of your top song ids (to look up their artists), up to 16 artist ids (artist pages), and the ids of the songs suggested (titles and covers). That's about 20 requests per refresh, at most once every 12 h unless you press R. The play log and the not-interested list never leave the machine.

Also fixed

  • Opening a list (or the queue, or search) while another list was still loading let the slow one replace it when it arrived. Showing a different list now cancels the pending one, in show(), so every caller is covered.
  • The startup frame listed 3 sidebar entries while the real sidebar has 6, so the list jumped on the first real frame.

Tested

  • cargo test: new tests for the decay weights, the liked-song fallback, the 30-day counts, ranking (merging, exclusion, push-down, artist damping and cap, reasons) and the artist-overview parser. cargo clippy with 0 warnings. The help-layout test still fits (lyrics, art and theme now share a line, to make room for X).
  • In tmux on a scratch copy of my state: For You from scratch (50 songs, 1.8 s), reopen from disk (5 ms), R (2.2 s, the X'd song stays out), X in For You (the row goes, the file gets one line), X on a ✦ song in the queue (it leaves), and the play log after 30 s of a song.
  • PSS with For You open after a refresh: 19.6 MB, against 19.2 MB with Liked Songs playing. Idle wakeups unchanged: no new timers; the play log is written from the 1 Hz tick that already runs while playing.
  • Not tested: how good the picks feel over weeks of real use (the log starts empty), and macOS/Windows (CI compile only).

- Every song played for 30 s goes in a local log (~/.local/share/trill/plays). Seeds are
  the songs you play, each play counting half as much every 14 days; your newest liked
  songs fill in while the log is short.
- Candidates: the radio of the top 4 seed songs, and the top songs of artists Spotify lists
  as related to your top 4 artists (the artist-page query trill already sends for play
  counts). Fetched in parallel, about 2 s.
- Ranked locally: liked songs and "not interested" are left out, songs played a lot in
  the last 30 days are pushed down, and each further song by an artist counts half (3 at
  most). The Why column says where each one came from.
- Opening it shows the last list from disk at once; it's worked out again after 12 h, or on R.
- X on a For You song, or a ✦ smart-shuffle song, marks it not interested (kept in
  ~/.local/share/trill/not_interested); a playing ✦ song is skipped. Smart shuffle leaves
  them out too.
- Fix: opening a list while another was still loading let the slow one replace it when it
  arrived.
- The startup frame lists the same sidebar entries as the real one, so nothing jumps.
@junaydirfan
junaydirfan merged commit efecfbe into master Nov 24, 2026
3 checks passed
@junaydirfan
junaydirfan deleted the discover branch November 24, 2026 08:11
@junaydirfan junaydirfan mentioned this pull request Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant