feat(parser): add GridMix (#356)

This commit is contained in:
Patrick Kan
2023-03-14 17:19:22 +08:00
committed by GitHub
parent ad1d3dbf91
commit a8e7e644ec
2 changed files with 41 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
import Text from './misc/Text.js';
import Parser from '../index.js';
import Thumbnail from './misc/Thumbnail.js';
import NavigationEndpoint from './NavigationEndpoint.js';
import { YTNode } from '../helpers.js';
class GridMix extends YTNode {
static type = 'GridMix';
id: string;
title: Text;
author: Text | null;
thumbnails: Thumbnail[];
video_count: Text;
video_count_short: Text;
endpoint: NavigationEndpoint;
secondary_endpoint: NavigationEndpoint;
thumbnail_overlays;
constructor(data: any) {
super();
this.id = data.playlistId;
this.title = new Text(data.title);
this.author = data.shortBylineText?.simpleText ?
new Text(data.shortBylineText) : data.longBylineText?.simpleText ?
new Text(data.longBylineText) : null;
this.thumbnails = Thumbnail.fromResponse(data.thumbnail);
this.video_count = new Text(data.videoCountText);
this.video_count_short = new Text(data.videoCountShortText);
this.endpoint = new NavigationEndpoint(data.navigationEndpoint);
this.secondary_endpoint = new NavigationEndpoint(data.secondaryNavigationEndpoint);
this.thumbnail_overlays = Parser.parseArray(data.thumbnailOverlays);
}
}
export default GridMix;

View File

@@ -194,6 +194,8 @@ import { default as GridChannel } from './classes/GridChannel.js';
export { GridChannel };
import { default as GridHeader } from './classes/GridHeader.js';
export { GridHeader };
import { default as GridMix } from './classes/GridMix.js';
export { GridMix };
import { default as GridMovie } from './classes/GridMovie.js';
export { GridMovie };
import { default as GridPlaylist } from './classes/GridPlaylist.js';
@@ -792,6 +794,7 @@ const map: Record<string, YTNodeConstructor> = {
Grid,
GridChannel,
GridHeader,
GridMix,
GridMovie,
GridPlaylist,
GridVideo,