From f3e982c946aabbe9d1bcbf072d98e0280094aa49 Mon Sep 17 00:00:00 2001 From: Sayem Chowdhury Date: Wed, 7 Apr 2021 19:34:50 +0600 Subject: [PATCH] get channel list --- __tests__/api.ts | 8 ++++++++ src/api/api.ts | 6 ++++++ src/types/index.ts | 1 + 3 files changed, 15 insertions(+) diff --git a/__tests__/api.ts b/__tests__/api.ts index d64f8b3..38f2da3 100644 --- a/__tests__/api.ts +++ b/__tests__/api.ts @@ -221,7 +221,15 @@ if (process.env.CI) { }); } +test('GET CHANNEL LIST', async (t) => { + const channel = await api.getChannelList(); + t.is(channel.count, channel.data.length); + t.true(Array.isArray(channel.data)); +}); + test('GET PLAYLIST CHANNEL', async (t) => { const channel = await api.getPlaylistChannel('dance'); t.deepEqual(Object.keys(channel), ['version', 'page_id', 'ga', 'title', 'persistent', 'sections', 'expire']); + t.truthy(channel.title); + t.true(Array.isArray(channel.sections)); }); diff --git a/src/api/api.ts b/src/api/api.ts index 843f3f5..ca7e5d8 100644 --- a/src/api/api.ts +++ b/src/api/api.ts @@ -8,6 +8,7 @@ import type { playlistInfo, playlistTracksType, playlistChannelType, + channelSearchType, artistInfoType, discographyType, profileType, @@ -130,6 +131,11 @@ export const getUser = async (): Promise => { throw new Error(errorMessage); }; +/** + * Get list of channles + */ +export const getChannelList = async (): Promise => request({}, 'search_getChannels'); + /** * Get details about a playlist channel */ diff --git a/src/types/index.ts b/src/types/index.ts index 46991ed..c8fcfb9 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -2,6 +2,7 @@ export * from './album'; export * from './artist'; export * from './playlist'; export * from './playlist-channel'; +export * from './channel'; export * from './profile'; export * from './search'; export * from './tracks';