diff --git a/lib/core/Actions.js b/lib/core/Actions.js index 286be258..a98b7948 100644 --- a/lib/core/Actions.js +++ b/lib/core/Actions.js @@ -99,7 +99,7 @@ class Actions { data.actions = [ target_action ]; break; default: - throw new Utils.InnertubeError('Invalid action', action); + throw new Utils.InnertubeError('Action not implemented', action); } const response = await this.#request.post(`/${action}`, data); @@ -111,8 +111,8 @@ class Actions { * * @param {string} action * @param {object} args - * @param {string} args.new_value - * @param {string} args.setting_item_id + * @param {string} [args.new_value] + * @param {string} [args.setting_item_id] * * @returns {Promise.<{ success: boolean; status_code: number; data: object }>} */ @@ -161,6 +161,7 @@ class Actions { (data.client = args.client); const response = await this.#request.post('/search', data); + return response; } @@ -183,6 +184,37 @@ class Actions { return response; } + /** + * Channel management endpoints. + * + * @param {string} action + * @param {object} args + * @param {string} [args.new_name] + * @param {string} [args.new_description] + * + * @returns {Promise.<{ success: boolean; status_code: number; data: object; }>} + */ + async channel(action, args = {}) { + const data = { client: args.client || 'ANDROID' }; + + switch (action) { + case 'channel/edit_name': + data.givenName = args.new_name; + break; + case 'channel/edit_description': + data.description = args.new_description; + break; + case 'channel/get_profile_editor': + break; + default: + throw new Utils.InnertubeError('Action not implemented', action); + } + + const response = await this.#request.post(action, data); + + return response; + } + /** * Covers endpoints used for playlist management. * @@ -223,10 +255,11 @@ class Actions { })[args.action]); break; default: - throw new Utils.InnertubeError('Invalid action', action); + throw new Utils.InnertubeError('Action not implemented', action); } const response = await this.#request.post(`/${action}`, data); + return response; } @@ -260,10 +293,11 @@ class Actions { // doesn't require any parameter break; default: - throw new Utils.InnertubeError('Invalid action', action); + throw new Utils.InnertubeError('Action not implemented', action); } const response = await this.#request.post(`/notification/${action}`, data); + return response; } @@ -305,10 +339,11 @@ class Actions { args.ctoken && (data.continuation = args.ctoken); break; default: - throw new Utils.InnertubeError('Invalid action', action); + throw new Utils.InnertubeError('Action not implemented', action); } const response = await this.#request.post(`/${action}`, data); + return response; } @@ -336,10 +371,11 @@ class Actions { data.params = args.params; break; default: - throw new Utils.InnertubeError('Invalid action', action); + throw new Utils.InnertubeError('Action not implemented', action); } const response = await this.#request.post(`/${action}`, data); + return response; } @@ -358,6 +394,7 @@ class Actions { }; const response = await this.#request.post(`/music/${action}`, data); + return response; } @@ -367,7 +404,7 @@ class Actions { * @param {object} args * @param {string} [args.video_id] * @param {string} [args.ctoken] - * @param {string} [client] + * @param {string} [args.client] * * @returns {Promise.<{ success: boolean; status_code: number; data: object; }>} */ @@ -384,6 +421,7 @@ class Actions { (data.client == args.client); const response = await this.#request.post('/next', data); + return response; } @@ -416,6 +454,7 @@ class Actions { cpn && (data.cpn = cpn); const response = await this.#request.post('/player', data); + return response.data; }