diff --git a/src/parser/youtube/Channel.ts b/src/parser/youtube/Channel.ts index 9057b0bdb0..2a0ad00266 100644 --- a/src/parser/youtube/Channel.ts +++ b/src/parser/youtube/Channel.ts @@ -196,6 +196,10 @@ export default class Channel extends TabbedFeed { return new Channel(this.actions, page, true); } + get has_home(): boolean { + return this.hasTabWithURL('featured'); + } + get has_videos(): boolean { return this.hasTabWithURL('videos'); } @@ -216,6 +220,18 @@ export default class Channel extends TabbedFeed { return this.hasTabWithURL('community'); } + get has_channels(): boolean { + return this.hasTabWithURL('channels'); + } + + get has_about(): boolean { + return this.hasTabWithURL('about'); + } + + get has_search(): boolean { + return this.memo.getType(ExpandableTab)?.length > 0; + } + /** * Retrives list continuation. */ diff --git a/test/constants.ts b/test/constants.ts index c7706265a2..6e44f53539 100644 --- a/test/constants.ts +++ b/test/constants.ts @@ -41,5 +41,9 @@ export const CHANNELS = [ { ID: 'UCt-oJR5teQIjOAxCmIQvcgA', NAME: "They're Just Movies" + }, + { + ID: 'UCOpNcN46UbXVtpKMrmU4Abg', + NAME: "Gaming" } ]; \ No newline at end of file diff --git a/test/main.test.ts b/test/main.test.ts index b25e8edf34..cef22e1e5f 100644 --- a/test/main.test.ts +++ b/test/main.test.ts @@ -165,11 +165,28 @@ describe('YouTube.js Tests', () => { it('should detect missing channel tabs', async () => { const channel = await yt.getChannel(CHANNELS[2].ID); + expect(channel.has_home).toBe(true); expect(channel.has_videos).toBe(true); expect(channel.has_shorts).toBe(false); expect(channel.has_live_streams).toBe(false); expect(channel.has_playlists).toBe(true); expect(channel.has_community).toBe(true); + expect(channel.has_channels).toBe(true); + expect(channel.has_about).toBe(true); + expect(channel.has_search).toBe(true); + }) + + it('should have no channel tabs', async () => { + const channel = await yt.getChannel(CHANNELS[3].ID); + expect(channel.has_home).toBe(false); + expect(channel.has_videos).toBe(false); + expect(channel.has_shorts).toBe(false); + expect(channel.has_live_streams).toBe(false); + expect(channel.has_playlists).toBe(false); + expect(channel.has_community).toBe(false); + expect(channel.has_channels).toBe(false); + expect(channel.has_about).toBe(false); + expect(channel.has_search).toBe(false); }) it('should retrieve home feed', async () => {