Skip to content

Add Smart Shuffle for playlists - #45

Open
VitzS7 wants to merge 2 commits into
fatyzzz:mainfrom
VitzS7:smart-shuffle
Open

VitzS7 wants to merge 2 commits into
fatyzzz:mainfrom
VitzS7:smart-shuffle

Conversation

@VitzS7

@VitzS7 VitzS7 commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Adds Spotify's Smart Shuffle for playlists played on this computer.

Smart Shuffle is the playlist loaded through context-resolve with ?spotify-apply-lenses=enhance. Spotify then returns the playlist plus its recommendations, marks the context with enhanced_context=true and each added track with provider=enhanced_recommendation. librespot loads that URI as is, so nothing changes on the librespot side. The lens only works as a query parameter, sending it as a header to context-resolve does nothing.

  • The shuffle button cycles off, shuffle, Smart Shuffle (skipped where it is not available), with a sparkle on the icon in Smart Shuffle, like the official client. The mini player and island menus get a Smart Shuffle item.
  • Recommended tracks get a sparkle in the queue.
  • Switching it on or off reloads the playing playlist from the playing row and position. The row is found by uid, because the two forms of the context can give a relinked track different ids, and loading by uri jumped to another track.
  • The icon font gains auto_awesome only. Regenerating the whole subset also changed a few unrelated glyphs, so I left those out.

Limits:

  • Playlists only. Liked Songs with the lens returns 404.
  • Local playback only. I found no way to pass the lens to a remote Connect device, so remote control keeps plain shuffle, and Smart Shuffle started on another device shows as normal shuffle.
  • librespot shuffles the recommendations at random, it does not use Spotify's order (shuffle.distribution in the track metadata).
  • Switching the mode reloads the track, so there is a short blip, and it starts playback if it was paused.
  • The mode is not remembered between sessions.

Tested on Linux with a Premium account: two playlists (220 to 286 and 30 to 45 tracks), switching on and off mid track, the queue marks. cargo test --locked -p sf-player -p md3-model -p mf-i18n and qmllint pass.

Smart Shuffle loads the playlist through context-resolve with
?spotify-apply-lenses=enhance, which adds Spotify's recommendations to it.
Switching it on or off reloads the playing playlist from the playing row
(found by uid, since the two forms of the context can give a relinked
track different ids). The queue marks recommended tracks. Remote devices
keep plain shuffle: the lens can't be passed to them.
…yer menus

The shuffle button cycles off, shuffle and Smart Shuffle (skipped where it
isn't available) and shows a sparkle in Smart Shuffle. Recommended tracks
get a sparkle in the queue. The icon font gains auto_awesome.
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