update playlist channel

This commit is contained in:
Sayem Chowdhury 2021-04-13 18:40:14 +06:00
parent 5fc58df2a7
commit 360d1734a5
5 changed files with 2380 additions and 10 deletions

View File

@ -228,7 +228,7 @@ test('GET CHANNEL LIST', async (t) => {
});
test('GET PLAYLIST CHANNEL', async (t) => {
const channel = await api.getPlaylistChannel('dance');
const channel = await api.getPlaylistChannel('channels/dance');
t.deepEqual(Object.keys(channel), ['version', 'page_id', 'ga', 'title', 'persistent', 'sections', 'expire']);
t.truthy(channel.title);
t.true(Array.isArray(channel.sections));

2372
c.json Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,3 @@
import axios from '../lib/request';
import {request, requestGet, requestPublicApi} from './request';
import type {
albumType,
@ -127,11 +126,10 @@ export const getChannelList = async (): Promise<channelSearchType> => request({}
/**
* Get details about a playlist channel
* Return homepage if name is undefined
*/
export const getPlaylistChannel = async (name?: string): Promise<playlistChannelType> => {
export const getPlaylistChannel = async (page: string): Promise<playlistChannelType> => {
const gateway_input = {
page: name ? 'channels/' + name : 'home',
page,
version: '2.3',
support: {
'long-card-horizontal-grid': ['album', 'playlist', 'radio', 'show', 'livestream'],
@ -224,5 +222,5 @@ export const getPlaylistChannel = async (name?: string): Promise<playlistChannel
timezone_offset: '6',
};
return await requestGet('app_page_get', {gateway_input});
return await requestGet('app_page_get', {gateway_input}, page);
};

View File

@ -31,8 +31,8 @@ export const request = async (body: object, method: string) => {
* @param {String} method request method
* @param {Object} params request parameters
*/
export const requestGet = async (method: string, params?: object) => {
const cacheKey = `${method}:${params ? Object.entries(params).join(':') : 'get_request'}`;
export const requestGet = async (method: string, params: object = {}, key: string = 'get_request') => {
const cacheKey = method + key;
const cache = lru.get(cacheKey);
if (cache) {
return cache;

View File

@ -32,7 +32,7 @@ export interface playlistChannelItemsType {
DATE_ADD: string; // '2020-12-15 19:31:07'
DESCRIPTION: string; // 'The biggest dance hits to keep the party going!'
__TYPE__: 'playlist';
};
} | null;
target: string; // '/playlist/1291471565'
title: string; // 'Dance Party'
subtitle: string; // '50 tracks'
@ -40,7 +40,7 @@ export interface playlistChannelItemsType {
pictures: [
{
md5: string; // 'c5eb1bf10a83734c032e983ef190105e'
type: 'playlist';
type: string; // 'playlist';
},
];
weight: number; // 1