From 8623b860664d82813cbb6d8c06ef9d8ce97510ad Mon Sep 17 00:00:00 2001 From: adasq Date: Wed, 4 Jan 2023 15:37:02 +0100 Subject: [PATCH] getVideos API fix --- package-lock.json | 2 +- package.json | 2 +- src/youtube-studio-api.js | 1 + src/youtube-studio-api.spec.js | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 577b300..54b27bb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "youtube-studio", - "version": "0.0.23", + "version": "0.0.24", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 585af47..9562545 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "youtube-studio", - "version": "0.0.23", + "version": "0.0.24", "description": "Unofficial YouTube Studio API", "main": "index.js", "scripts": { diff --git a/src/youtube-studio-api.js b/src/youtube-studio-api.js index 073fd53..1c936a4 100644 --- a/src/youtube-studio-api.js +++ b/src/youtube-studio-api.js @@ -241,6 +241,7 @@ async function getVideos(pageSize = 30) { _.set(template, 'pageSize', pageSize); _.set(template, 'context.user.delegationContext.externalChannelId', config.CHANNEL_ID); _.set(template, 'filter.and.operands[0].channelIdIs.value', config.CHANNEL_ID); + _.set(template, 'context.user.onBehalfOfUser', config.DELEGATED_SESSION_ID); return fetch(`${YT_STUDIO_URL}/youtubei/v1/creator/list_creator_videos?alt=json&key=${config.INNERTUBE_API_KEY}`, { method: 'POST', diff --git a/src/youtube-studio-api.spec.js b/src/youtube-studio-api.spec.js index 9a91903..851ce57 100644 --- a/src/youtube-studio-api.spec.js +++ b/src/youtube-studio-api.spec.js @@ -107,6 +107,7 @@ describe('for authenticated user', () => { it('should list videos', async () => { const result = await getVideos(60) + console.log(result.videos.length) expect(result.videos.length).toBeGreaterThan(0) })