diff --git a/docs/API/playlist.md b/docs/API/playlist.md
index 3f099df32..2f440a0b3 100644
--- a/docs/API/playlist.md
+++ b/docs/API/playlist.md
@@ -10,6 +10,8 @@ Playlist management class.
* [.addVideos(playlist_id, video_ids)](#addvideos)
* [.removeVideos(playlist_id, video_ids)](#removevideos)
* [.moveVideo(playlist_id, moved_video_id, predecessor_video_id)](#movevideo)
+ * [.setName(playlist_id, name)](#setname)
+ * [.setDescription(playlist_id, description)](#setdescription)
### create(title, video_ids)
@@ -69,4 +71,29 @@ Moves a video to a new position within a given playlist.
| --- | --- | --- |
| playlist_id | `string` | Playlist id |
| moved_video_id | `string` | the video to be moved |
-| predecessor_video_id | `string` | the video present in the target position |
\ No newline at end of file
+| predecessor_video_id | `string` | the video present in the target position |
+
+
+### setName(playlist_id, name)
+
+Sets the name / title for the given playlist.
+
+**Returns:** `Promise.`
+
+| Param | Type | Description |
+| --- | --- | --- |
+| playlist_id | `string` | Playlist id |
+| name | `string` | Name / title |
+
+
+
+### setDescription(playlist_id, description)
+
+Sets the description for the given playlist.
+
+**Returns:** `Promise.`
+
+| Param | Type | Description |
+| --- | --- | --- |
+| playlist_id | `string` | Playlist id |
+| description | `string` | Description |
diff --git a/src/core/endpoints/browse/EditPlaylistEndpoint.ts b/src/core/endpoints/browse/EditPlaylistEndpoint.ts
index 83654c5bf..f03c3bebf 100644
--- a/src/core/endpoints/browse/EditPlaylistEndpoint.ts
+++ b/src/core/endpoints/browse/EditPlaylistEndpoint.ts
@@ -15,7 +15,9 @@ export function build(opts: EditPlaylistEndpointOptions): IEditPlaylistRequest {
...{
addedVideoId: action.added_video_id,
setVideoId: action.set_video_id,
- movedSetVideoIdPredecessor: action.moved_set_video_id_predecessor
+ movedSetVideoIdPredecessor: action.moved_set_video_id_predecessor,
+ playlistDescription: action.playlist_description,
+ playlistName: action.playlist_name
}
}))
};
diff --git a/src/core/managers/PlaylistManager.ts b/src/core/managers/PlaylistManager.ts
index 59727357a..e9d5ff6d7 100644
--- a/src/core/managers/PlaylistManager.ts
+++ b/src/core/managers/PlaylistManager.ts
@@ -200,4 +200,60 @@ export default class PlaylistManager {
action_result: response.data.actions // TODO: implement actions in the parser
};
}
-}
\ No newline at end of file
+
+ /**
+ * Sets the name (title) for the given playlist.
+ * @param playlist_id - The playlist ID.
+ * @param name - The name / title to use for the playlist.
+ */
+ async setName(playlist_id: string, name: string): Promise<{ playlist_id: string; action_result: any; }> {
+ throwIfMissing({ playlist_id, name });
+
+ if (!this.#actions.session.logged_in)
+ throw new InnertubeError('You must be signed in to perform this operation.');
+
+ const payload: EditPlaylistEndpointOptions = { playlist_id, actions: [] };
+
+ payload.actions.push({
+ action: 'ACTION_SET_PLAYLIST_NAME',
+ playlist_name: name
+ });
+
+ const response = await this.#actions.execute(
+ EditPlaylistEndpoint.PATH, EditPlaylistEndpoint.build(payload)
+ );
+
+ return {
+ playlist_id,
+ action_result: response.data.actions
+ };
+ }
+
+ /**
+ * Sets the description for the given playlist.
+ * @param playlist_id - The playlist ID.
+ * @param description - The description to use for the playlist.
+ */
+ async setDescription(playlist_id: string, description: string): Promise<{ playlist_id: string; action_result: any; }> {
+ throwIfMissing({ playlist_id, description });
+
+ if (!this.#actions.session.logged_in)
+ throw new InnertubeError('You must be signed in to perform this operation.');
+
+ const payload: EditPlaylistEndpointOptions = { playlist_id, actions: [] };
+
+ payload.actions.push({
+ action: 'ACTION_SET_PLAYLIST_DESCRIPTION',
+ playlist_description: description
+ });
+
+ const response = await this.#actions.execute(
+ EditPlaylistEndpoint.PATH, EditPlaylistEndpoint.build(payload)
+ );
+
+ return {
+ playlist_id,
+ action_result: response.data.actions
+ };
+ }
+}
diff --git a/src/types/Endpoints.ts b/src/types/Endpoints.ts
index 3cdd963db..1de4de848 100644
--- a/src/types/Endpoints.ts
+++ b/src/types/Endpoints.ts
@@ -334,18 +334,22 @@ export type EditPlaylistEndpointOptions = {
* The changes to make to the playlist.
*/
actions: {
- action: 'ACTION_ADD_VIDEO' | 'ACTION_REMOVE_VIDEO' | 'ACTION_MOVE_VIDEO_AFTER';
+ action: 'ACTION_ADD_VIDEO' | 'ACTION_REMOVE_VIDEO' | 'ACTION_MOVE_VIDEO_AFTER' | 'ACTION_SET_PLAYLIST_DESCRIPTION' | 'ACTION_SET_PLAYLIST_NAME';
added_video_id?: string;
set_video_id?: string;
moved_set_video_id_predecessor?: string;
+ playlist_description?: string;
+ playlist_name?: string;
}[];
}
export interface IEditPlaylistRequest extends ObjectSnakeToCamel {
actions: {
- action: 'ACTION_ADD_VIDEO' | 'ACTION_REMOVE_VIDEO' | 'ACTION_MOVE_VIDEO_AFTER';
+ action: 'ACTION_ADD_VIDEO' | 'ACTION_REMOVE_VIDEO' | 'ACTION_MOVE_VIDEO_AFTER' | 'ACTION_SET_PLAYLIST_DESCRIPTION' | 'ACTION_SET_PLAYLIST_NAME';
addedVideoId?: string;
setVideoId?: string;
movedSetVideoIdPredecessor?: string;
+ playlistDescription?: string;
+ playlistName?: string;
}[];
}
\ No newline at end of file