From 2d4d17ef9f1804374c2a9ec59a8054d7497fa73b Mon Sep 17 00:00:00 2001 From: Sayem Chowdhury Date: Tue, 6 Apr 2021 14:09:18 +0600 Subject: [PATCH] playlist channel --- src/api.ts | 110 ++++++++++++++++++++++++++++++++++ src/types/index.ts | 1 + src/types/playlist-channel.ts | 65 ++++++++++++++++++++ 3 files changed, 176 insertions(+) create mode 100644 src/types/playlist-channel.ts diff --git a/src/api.ts b/src/api.ts index bc017c4..1fd0a94 100644 --- a/src/api.ts +++ b/src/api.ts @@ -7,6 +7,7 @@ import type { albumTracksType, playlistInfo, playlistTracksType, + playlistChannelType, artistInfoType, discographyType, profileType, @@ -181,3 +182,112 @@ export const getUser = async (): Promise => { const errorMessage = Object.entries(error).join(', '); throw new Error(errorMessage); }; + +/** + * Get details about a playlist channel + */ +export const getPlaylistChannel = async (name: string): Promise => { + const gateway_input = { + page: 'channels/' + name, + version: '2.3', + support: { + 'long-card-horizontal-grid': ['album', 'playlist', 'radio', 'show', 'livestream'], + ads: ['native'], + message: ['conversion', 'informative', 'call_onboarding'], + highlight: ['generic', 'album', 'artist', 'playlist', 'radio', 'livestream', 'app'], + 'deeplink-list': ['generic', 'deeplink'], + grid: [ + 'generic', + 'album', + 'artist', + 'playlist', + 'radio', + 'channel', + 'show', + 'livestream', + 'page', + 'smarttracklist', + 'flow', + 'video-link', + ], + slideshow: [ + 'album', + 'artist', + 'playlist', + 'radio', + 'show', + 'livestream', + 'channel', + 'video-link', + 'external-link', + ], + 'large-card': [ + 'generic', + 'album', + 'artist', + 'playlist', + 'radio', + 'show', + 'livestream', + 'external-link', + 'video-link', + ], + 'item-highlight': ['radio', 'app'], + 'small-horizontal-grid': ['album', 'artist', 'playlist', 'radio', 'channel', 'show', 'livestream'], + 'grid-preview-two': [ + 'generic', + 'album', + 'artist', + 'playlist', + 'radio', + 'channel', + 'show', + 'livestream', + 'page', + 'smarttracklist', + 'flow', + 'video-link', + ], + list: ['generic', 'album', 'artist', 'playlist', 'radio', 'show', 'video-link', 'channel', 'episode'], + 'grid-preview-one': [ + 'generic', + 'album', + 'artist', + 'playlist', + 'radio', + 'channel', + 'show', + 'livestream', + 'page', + 'smarttracklist', + 'flow', + 'video-link', + ], + 'horizontal-grid': [ + 'generic', + 'album', + 'artist', + 'playlist', + 'radio', + 'channel', + 'show', + 'livestream', + 'video-link', + 'smarttracklist', + 'flow', + ], + }, + lang: 'en', + timezone_offset: '6', + }; + const { + data: {error, results}, + } = await axios.get('/gateway.php', {params: {method: 'app_page_get', gateway_input}}); + + if (Object.keys(results).length > 0) { + return results; + } + + const errorMessage = Object.entries(error).join(', '); + throw new Error(errorMessage); +}; diff --git a/src/types/index.ts b/src/types/index.ts index 57c55bd..46991ed 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -1,6 +1,7 @@ export * from './album'; export * from './artist'; export * from './playlist'; +export * from './playlist-channel'; export * from './profile'; export * from './search'; export * from './tracks'; diff --git a/src/types/playlist-channel.ts b/src/types/playlist-channel.ts new file mode 100644 index 0000000..e5c3da3 --- /dev/null +++ b/src/types/playlist-channel.ts @@ -0,0 +1,65 @@ +interface itemsType { + item_id: string; // 'page_id=channels/dance,render_id=608a93738223d615200e6390ea48f8f3,version=channel-cms.1.0,section_id=long-card-horizontal-grid,section_position=0,module_id=be55d60e-e3c3-421a-9ea9-aef6f0c63c6c,module_type=playlists,layout=playlists_layout_long-card-horizontal-grid,content_source=playlists_content-source_custom,content_source_count=0,content_programming_count=8,section_content=playlist%3A1291471565%3Bplaylist%3A2249258602%3Bplaylist%3A2113355604%3Bplaylist%3A1950512362%3Bplaylist%3A1495242491%3Bplaylist%3A6090195324%3Bplaylist%3A706093725%3Bplaylist%3A7837492422,item_type=playlist,item_id=1291471565,item_position=0' + id: string; // '1291471565' + type: 'playlist'; + data: { + NB_FAN: number; // 231133 + NB_SONG: number; // 50 + PARENT_USER_ID: string; // '2834392844' + PICTURE_TYPE: 'playlist'; + PLAYLIST_ID: string; // '1291471565' + PLAYLIST_PICTURE: string; // 'c5eb1bf10a83734c032e983ef190105e' + STATUS: number; // 0 + TITLE: string; // 'Dance Party' + TYPE: string; // '0' + DATE_MOD: string; // '2021-04-02 19:57:27' + DATE_ADD: string; // '2020-12-15 19:31:07' + DESCRIPTION: string; // 'The biggest dance hits to keep the party going!' + __TYPE__: 'playlist'; + }; + target: string; // '/playlist/1291471565' + title: string; // 'Dance Party' + subtitle: string; // '50 tracks' + description: string; // 'The biggest dance hits to keep the party going!' + pictures: [ + { + md5: string; // 'c5eb1bf10a83734c032e983ef190105e' + type: 'playlist'; + }, + ]; + weight: number; // 1 + layout_parameters: { + cta: { + type: 'browse'; + label: 'BROWSE'; + }; + }; +} + +interface sectionsType { + layout: string; // 'long-card-horizontal-grid' + section_id: string; // 'page_id=channels/dance,render_id=608a93738223d615200e6390ea48f8f3,version=channel-cms.1.0,section_id=long-card-horizontal-grid,section_position=0,module_id=be55d60e-e3c3-421a-9ea9-aef6f0c63c6c,module_type=playlists,layout=playlists_layout_long-card-horizontal-grid,content_source=playlists_content-source_custom,content_source_count=0,content_programming_count=8,section_content=playlist%3A1291471565%3Bplaylist%3A2249258602%3Bplaylist%3A2113355604%3Bplaylist%3A1950512362%3Bplaylist%3A1495242491%3Bplaylist%3A6090195324%3Bplaylist%3A706093725%3Bplaylist%3A7837492422' + items: itemsType[]; + title: string; // 'Top Dance & EDM playlists' + target: string; // '/channels/module/be55d60e-e3c3-421a-9ea9-aef6f0c63c6c' + related: { + target: string; // '/channels/module/be55d60e-e3c3-421a-9ea9-aef6f0c63c6c' + label: string; // 'View all' + mandatory: boolean; + }; + alignment: string; // 'left' + group_id: string; // '606c10eda2d91' + hasMoreItems: boolean; +} + +export interface playlistChannelType { + version: string; // '2.3' + page_id: string; // 'page_id=channels/dance,render_id=608a93738223d615200e6390ea48f8f3,version=channel-cms.1.0' + ga: { + screen_name: string; // 'page-dance' + }; + title: string; // 'Dance & EDM' + persistent: boolean; + sections: sectionsType[]; + expire: number; // 1617707131 +}