Repository navigation
Streaming integrations: Apple Music links, 30s previews, playlist export - #2
Merged
Merged
Conversation
The previous selector required a video track, so audio-only URLs (SoundCloud, Bandcamp, etc.) silently failed. Adds /ba/b fallbacks so yt-dlp picks the best audio when no video stream exists. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…gest Steps after ingest (peaks, bpm, key, fingerprint) had no data dependency on each other but ran serially. Fan them out across a ThreadPoolExecutor; the status.json read-modify-write is the only shared mutable state, so a single lock around update_step is sufficient. Real-world wins come from overlapping the network-bound fingerprint scan and subprocess-bound peaks step with the CPU-bound bpm/key passes. On the viewer side, the library form now navigates to /set.html as soon as the SSE stream emits a set_id (immediately after ingest), rather than blocking on the full pipeline. The set page already polled status.json and reloaded artifacts as they appeared; added a peaks case so wavesurfer rebuilds with real peaks once that step finishes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… export) Personal-but-deployable single-user OAuth design. Apple Music links and 30s previews need no auth. Spotify export uses PKCE with loopback redirect; Apple Music export is gated on operator providing a Developer .p8 key. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…t export
Three independent surfaces (any can be enabled separately):
* Apple Music links — render alongside Spotify/YouTube on candidate cards
and tracklist rows. The apple_id was already flowing through ACR; we just
weren't displaying it.
* 30s in-browser previews (no auth) — Apple via the iTunes Search lookup
endpoint (cached on disk for 24h), Spotify via the open.spotify.com/embed
iframe widget. Inline ▶ buttons on each candidate; main set audio pauses
when a preview plays, and a preview tears down when the user resumes.
* Playlist export — single-user OAuth model, tokens stored in ~/.setplot/
with 0600 perms.
- Spotify: Authorization Code with PKCE (no client secret), server-side
token exchange and refresh. Track resolution prefers ACR's spotify_id,
falls back to ISRC search, then to title+artist with artist-substring
sanity check. Adds tracks in batches of 100 (Spotify's hard limit).
- Apple Music: developer JWT (ES256) signed in-process with a .p8 key,
served at /api/apple/dev-token. The browser uses MusicKit JS for sign-in
and library writes; the backend's involvement ends at the JWT.
Both endpoints self-disable when their credentials aren't configured —
the viewer reads a `services` capability flag and hides the buttons.
New deps: cryptography (for ES256 signing).
Configuration is documented in README.md and lives entirely in env vars,
nothing on disk that gets committed.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three independent surfaces, each gated separately so partial setup is fine.
1. Apple Music links
apple_id. Pure UI — the data was already flowing through.2. 30-second in-browser previews (no auth, no signups)
GET /api/preview?service=apple&id=<song_id>→ iTunes Search lookup, returns{ preview_url, artwork_url, … }. Cached on disk per song-id for 24h.open.spotify.com/embed/track/<id>iframe widget — Spotify allows their embed to play 30s clips with no auth.3. Playlist export (single-user OAuth)
SPOTIFY_CLIENT_ID. Tokens persist in~/.setplot/spotify_token.json(0600). Track resolution: existingspotify_idfrom ACR → ISRC search → title+artist search with artist-substring sanity check. Adds tracks in batches of 100 (Spotify's hard limit)..p8key (APPLE_MUSIC_TEAM_ID/KEY_ID/KEY_PATH). Sign-in andPOST /v1/me/library/playlistshappen entirely in the browser via MusicKit JS — the backend's involvement ends at the JWT. Same resolution chain (catalog filter[isrc] → text search)./api/sets/{id}response gains aservices: { spotify, apple }capability flag. No env, no buttons.Architecture & decision log
Full design recorded in
docs/superpowers/specs/2026-05-04-streaming-integrations-design.md.Test plan
pytest— 99 passed (78 prior + 21 new).previewUrlreturned, no auth).SPOTIFY_CLIENT_IDunset.iss/iat/exp), and signature roundtrip with a freshly generated EC P-256 key.Out of scope (deferred)