Skip to content

feat(api-server): add endpoint to add songs to playlists - #4602

Open
Juafeis wants to merge 1 commit into
pear-devs:masterfrom
Juafeis:codex/api-add-songs-to-playlist
Open

feat(api-server): add endpoint to add songs to playlists#4602
Juafeis wants to merge 1 commit into
pear-devs:masterfrom
Juafeis:codex/api-add-songs-to-playlist

Conversation

@Juafeis

@Juafeis Juafeis commented Jul 18, 2026

Copy link
Copy Markdown

Description

Adds POST /api/v1/playlists/{playlistId}/songs to the API Server. The endpoint accepts one or more YouTube Music videoIds and adds them to the requested playlist.

The implementation uses the authenticated ytmusic-app.networkManager already used by the renderer, so API clients do not need to handle YouTube cookies or credentials themselves.

Motivation

External controllers can manage playback and the queue, but cannot save a song to a user playlist. This also provides the API building block needed for shortcuts such as #2725.

Changes

  • Add OpenAPI schemas for playlist IDs and video IDs
  • Bridge the API request to the renderer through the existing song controls provider
  • Wait for the YouTube Music mutation before returning 204
  • Return an error instead of reporting success when the player is unavailable or the mutation fails

Validation

  • pnpm lint
  • oxfmt --check on the changed files
  • pnpm typecheck
  • pnpm build

Summary by CodeRabbit

  • New Features
    • Added an API endpoint for adding multiple songs to a playlist in one request.
    • Added playlist and song input validation.
    • Added support for adding songs to playlists through the application interface.
    • Added clear success, error, and timeout handling for playlist updates.

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 56c7686c-a216-4fcd-8d41-b478de390f09

📥 Commits

Reviewing files that changed from the base of the PR and between ec4cb23 and fa6ba98.

📒 Files selected for processing (5)
  • src/plugins/api-server/backend/routes/control.ts
  • src/plugins/api-server/backend/scheme/index.ts
  • src/plugins/api-server/backend/scheme/playlist.ts
  • src/providers/song-controls.ts
  • src/renderer.ts

📝 Walkthrough

Walkthrough

Adds a bulk playlist song-addition API with Zod validation, IPC request/response handling, timeout errors, and renderer-side /browse/edit_playlist calls.

Changes

Playlist song addition

Layer / File(s) Summary
Playlist API contract and route
src/plugins/api-server/backend/scheme/playlist.ts, src/plugins/api-server/backend/scheme/index.ts, src/plugins/api-server/backend/routes/control.ts
Defines playlist and video ID schemas, exports them, documents the new POST route, and returns 204 or structured 500 errors.
IPC playlist control
src/providers/song-controls.ts
Adds a Promise-based control using unique response channels, 10-second timeouts, and IPC error handling.
Renderer playlist mutation
src/renderer.ts
Handles the IPC request, checks app readiness, submits playlist add actions, and reports success or failure.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: jellybrick

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: a new API endpoint for adding songs to playlists.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Juafeis
Juafeis marked this pull request as ready for review July 18, 2026 23:59
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