Skip to content

feat: create playlists and remove them from the library - #450

Open
isnogudus wants to merge 2 commits into
devgianlu:masterfrom
isnogudus:feature/playlist-create-remove
Open

isnogudus wants to merge 2 commits into
devgianlu:masterfrom
isnogudus:feature/playlist-create-remove

Conversation

@isnogudus

Copy link
Copy Markdown
Contributor

Adds the two endpoints a client needs to manage the playlists themselves, after #403 and #411 made it possible to edit their contents.

POST /library/playlists/create {"name"} creates an empty playlist owned by the user and answers {"uri"}.

  • The playlist is created with POST /playlist/v2/playlist, whose body is an OpList whose UPDATE_LIST_ATTRIBUTES op sets the name, as Spotify's web player sends it. I first sent a ListUpdateRequest with the name in its attributes: Spotify created the playlist but ignored the name.
  • Creating is sent once (RequestOnce): if a resent request reached the server after the first one already had, it would create a second playlist.
  • A created playlist is not in the library yet, so the daemon then adds it to the top of the user's rootlist (an ADD at index 0), where Spotify shows a new playlist. This change is based on the rootlist's current revision and is retried once if the rootlist changed in between. If adding fails, the error names the playlist that was created.
  • An empty or blank name answers 400.

POST /library/playlists/remove {"playlist_uri"} takes a playlist out of the user's library by removing its entry from the rootlist. That is how Spotify deletes a playlist the user owns and unfollows one of someone else's. Like for a deleted playlist in Spotify, its followers keep it and it can be restored.

  • As in remove_track, the entry is removed by index range in a change based on the rootlist's revision. The rootlist is read again and the removal retried once if it changed meanwhile.
  • A playlist that is not in the library answers 404.
  • The rootlist is read and changed with the same code as a playlist: listContents and listChange now take the list's path.

Testing

  • Unit tests:
    • the OpList the create request sends and the uri read from its reply
    • adding to the top of the rootlist
    • the rootlist removal by index range
    • the retry on a conflict and the error when only adding to the library fails, against a fake playlist service
    • the API validation
  • Ran against a real account with respot:
    • A playlist created with this endpoint appears named at the top of the library in Spotify's clients.
    • Removing it deletes it there.
  • go mod tidy, go generate ./..., gofmt, build and go test -race -tags "test_unit test_integration" ./... are clean.

🤖 Generated with Claude Code

isnogudus and others added 2 commits November 19, 2026 09:41
Take a playlist out of the user's library by removing its entry from the
rootlist, which is how Spotify deletes a playlist the user owns and
unfollows one of someone else's. Like removing a track, the entry is
removed by index range in a change based on the rootlist's revision, and
read again and retried once if the rootlist moved on in between. A
playlist that is not in the library answers 404.

The rootlist is read and changed through the same code as a playlist:
listContents and listChange now take the list's path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Create an empty playlist owned by the user and add it to the top of the
user's library, where Spotify shows a new playlist. Creating is sent once,
as a resent request could create a second playlist; adding to the rootlist
is based on its current revision and retried once if it moved on in
between. The response carries the new playlist's uri.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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