0.6.2: Bypass sldl's Spotify client -- fetch the playlist ourselves, feed sldl a CSV
sldl's vendored Spotify client still calls GET /playlists/{id}/tracks, which
Spotify removed in its February 2026 API changes. Grandfathered apps still get
a pass; apps created after the change get a hard 403 there no matter how they
authenticate (client-credentials or a correctly-scoped OAuth user token), so
sldl can never load a playlist for a new app regardless of what we hand it.
Instead of depending on sldl's Spotify client at all, run-playlist.sh now reads
the playlist itself via the still-working /items endpoint (new
spotify-playlist-csv.py, creds sourced from _spotify.env) and invokes sldl with
the CSV + --input-type csv, which override the conf's input lines while -c still
supplies Soulseek login, paths, and quality settings (verified live). The same
CSV format upgrade-mp3-to-flac.sh already feeds sldl. All artists are
comma-joined in the CSV so multi-artist tracks search no worse than before, and
a 403/404 on the fetch prints the account-visibility hint instead of a bare
traceback.
Since sldl no longer talks to Spotify, playlist .confs no longer carry
spotify-id/spotify-secret/spotify-refresh: _template.conf drops them,
render_playlist_confs stops injecting them, and a Spotify credential save no
longer re-renders confs (only _spotify.env). The retag step in run-playlist.sh
reuses the sourced _spotify.env creds instead of scraping the conf lines that
no longer exist. Confs are also re-rendered once at app startup so
already-deployed confs converge on upgrade (and shed the stale secret lines)
without waiting for a playlist or credential change. Playlist delete now also
removes the generated .csv.
Tests updated: conf rendering must NOT contain Spotify creds but must keep the
input URL line; new coverage for _spotify.env rendering (quoting, refresh-token
presence/blank, 0600).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -43,22 +43,41 @@ def test_render_playlist_confs_injects_creds_safely(db, config_dir):
|
||||
text = conf.read_text()
|
||||
assert "user = seek" in text
|
||||
assert "pass = p'a$(id)ss" in text
|
||||
assert "spotify-id = CID" in text
|
||||
assert "spotify-secret = CSECRET" in text
|
||||
# no account connected yet -- rendered blank, not left as the placeholder
|
||||
assert "spotify-refresh = \n" in text
|
||||
# run-playlist.sh scrapes the playlist URL from this line to build the CSV
|
||||
assert "input = https://open.spotify.com/playlist/Z" in text
|
||||
# Spotify creds must NOT be rendered into confs: sldl never talks to
|
||||
# Spotify (run-playlist.sh feeds it a CSV); the creds live in _spotify.env
|
||||
assert "spotify-id" not in text
|
||||
assert "spotify-secret" not in text
|
||||
assert "spotify-refresh" not in text
|
||||
assert "CID" not in text
|
||||
assert "CSECRET" not in text
|
||||
# rendered config must be owner-only (holds the Soulseek password)
|
||||
assert stat.S_IMODE(os.stat(conf).st_mode) == 0o600
|
||||
|
||||
|
||||
def test_render_playlist_confs_includes_spotify_refresh_when_connected(db, config_dir):
|
||||
cs.set_credentials(db, "spotify", {"client_id": "CID", "client_secret": "CSECRET", "refresh_token": "RTOK"})
|
||||
cs.set_credentials(db, "soulseek", {"username": "seek", "password": "pw"})
|
||||
pl.create(db, name="rtest2", spotify_url="https://open.spotify.com/playlist/Z")
|
||||
def test_spotify_env_renders_creds_and_refresh_token(db, config_dir):
|
||||
# _spotify.env is the ONLY rendered home of Spotify creds; run-playlist.sh
|
||||
# sources it to fetch the playlist CSV, so values must be shell-quoted
|
||||
cs.set_credentials(
|
||||
db, "spotify", {"client_id": "CID", "client_secret": "CS'EC$(id)RET", "refresh_token": "RTOK"}
|
||||
)
|
||||
|
||||
conf = config_dir / "pipeline" / "rtest2.conf"
|
||||
text = conf.read_text()
|
||||
assert "spotify-refresh = RTOK" in text
|
||||
env = config_dir / "pipeline" / "_spotify.env"
|
||||
text = env.read_text()
|
||||
assert "SPOTIFY_CLIENT_ID=CID" in text
|
||||
# shlex.quote keeps a metacharacter-laden secret a single literal value
|
||||
assert "SPOTIFY_CLIENT_SECRET='CS'\"'\"'EC$(id)RET'" in text
|
||||
assert "SPOTIFY_REFRESH_TOKEN=RTOK" in text
|
||||
assert stat.S_IMODE(os.stat(env).st_mode) == 0o600
|
||||
|
||||
|
||||
def test_spotify_env_refresh_token_blank_until_connected(db, config_dir):
|
||||
cs.set_credentials(db, "spotify", {"client_id": "CID", "client_secret": "CSECRET"})
|
||||
|
||||
text = (config_dir / "pipeline" / "_spotify.env").read_text()
|
||||
# rendered blank (''), which sources cleanly and stays falsy in bash
|
||||
assert "SPOTIFY_REFRESH_TOKEN=''" in text
|
||||
|
||||
|
||||
def test_azuracast_renders_and_clears_base_url(db, config_dir):
|
||||
|
||||
Reference in New Issue
Block a user