From cfb48fab89792d87a7377eaf15a56d289d26769b Mon Sep 17 00:00:00 2001 From: YBD Project Date: Tue, 19 Nov 2024 16:56:57 +0900 Subject: [PATCH] feat: Add `getCourses` (#798) * feat: add getCourses function to retrieve courses * chore: Change getCourses function to return Feed instead of TabbedFeed --- src/Innertube.ts | 7 +++++++ test/main.test.ts | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/src/Innertube.ts b/src/Innertube.ts index 351e358a6..83502eb3d 100644 --- a/src/Innertube.ts +++ b/src/Innertube.ts @@ -320,6 +320,13 @@ export default class Innertube { return new TabbedFeed(this.actions, response); } + async getCourses(): Promise> { + const response = await this.actions.execute( + BrowseEndpoint.PATH, { ...BrowseEndpoint.build({ browse_id: 'FEcourses_destination' }), parse: true } + ); + return new Feed(this.actions, response); + } + async getSubscriptionsFeed(): Promise> { const response = await this.actions.execute( BrowseEndpoint.PATH, { ...BrowseEndpoint.build({ browse_id: 'FEsubscriptions' }), parse: true } diff --git a/test/main.test.ts b/test/main.test.ts index 4c98de997..927cbf60d 100644 --- a/test/main.test.ts +++ b/test/main.test.ts @@ -165,6 +165,14 @@ describe('YouTube.js Tests', () => { expect(trending.videos.length).toBeGreaterThan(0); }); + test('Innertube#getCourses', async () => { + const courses = await innertube.getCourses(); + expect(courses).toBeDefined(); + expect(courses.page.contents).toBeDefined(); + expect(courses.page.contents_memo).toBeDefined(); + expect(courses.shelves.length).toBeGreaterThan(0); + }); + describe('Innertube#getChannel', () => { let channel: YT.Channel;