-
Notifications
You must be signed in to change notification settings - Fork 1.9k
feat(api-server): add endpoint to play playlists #4505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ on: | |
| push: | ||
| branches: [ master ] | ||
|
|
||
|
|
||
| permissions: {} | ||
|
|
||
| env: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -146,5 +146,16 @@ export const getSongControls = (win: BrowserWindow) => { | |
| }); | ||
| win.webContents.send('peard:search', query, params, continuation); | ||
| }), | ||
| playPlaylist: (playlistId: ArgsType<string>, videoId?: ArgsType<string>) => { | ||
| const pid = parseStringFromArgsType(playlistId); | ||
| const vid = videoId ? parseStringFromArgsType(videoId) : null; | ||
| if (pid) { | ||
| let url = `https://music.youtube.com/playlist?list=${pid}`; | ||
| if (vid) { | ||
| url += `&v=${vid}`; | ||
| } | ||
| win.webContents.loadURL(url); | ||
|
Comment on lines
+149
to
+157
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major Handle
Update Suggested change- playPlaylist: (playlistId: ArgsType<string>, videoId?: ArgsType<string>) => {
+ playPlaylist: async (playlistId: ArgsType<string>, videoId?: ArgsType<string>) => {
const pid = parseStringFromArgsType(playlistId);
const vid = videoId ? parseStringFromArgsType(videoId) : null;
if (pid) {
let url = `https://music.youtube.com/playlist?list=${pid}`;
if (vid) {
url += `&v=${vid}`;
}
- win.webContents.loadURL(url);
+ return win.webContents.loadURL(url);
}
},- app.openapi(routes.playPlaylist, (ctx) => {
+ app.openapi(routes.playPlaylist, async (ctx) => {
const { playlistId, videoId } = ctx.req.valid('json');
- controller.playPlaylist(playlistId, videoId);
+ await controller.playPlaylist(playlistId, videoId);
ctx.status(204);
return ctx.body(null);
});🤖 Prompt for AI Agents |
||
| } | ||
| }, | ||
| }; | ||
| }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor
🧩 Analysis chain
🏁 Script executed:
Repository: pear-devs/pear-desktop
Length of output: 1236
🏁 Script executed:
Repository: pear-devs/pear-desktop
Length of output: 1354
Reject blank IDs in the request schema.
z.string()accepts empty strings''and whitespace-only values. The controller logic silently skips execution if a blankplaylistIdis provided (due to falsy check) while the endpoint still returns204 Success. This masks client errors.Update the schema to enforce non-empty, trimmed strings:
Suggested change
request: { body: { content: { 'application/json': { schema: z.object({ - playlistId: z.string().describe('Playlist ID'), - videoId: z.string().optional().describe('Video ID (optional)'), + playlistId: z.string().trim().min(1).describe('Playlist ID'), + videoId: z.string().trim().min(1).optional().describe('Video ID (optional)'), }), }, }, }, },📝 Committable suggestion
🤖 Prompt for AI Agents