Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(parser): add GridMix #356

Merged
merged 1 commit into from
Mar 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions src/parser/classes/GridMix.ts
Original file line number Diff line number Diff line change
@@ -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;
3 changes: 3 additions & 0 deletions src/parser/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -792,6 +794,7 @@ const map: Record<string, YTNodeConstructor> = {
Grid,
GridChannel,
GridHeader,
GridMix,
GridMovie,
GridPlaylist,
GridVideo,
Expand Down