mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-19 04:21:35 +00:00
* tests: improve coverage * refactor: clean up nodes * chore: lint * feat(parser): ignore `BrandVideoShelf` Seems to be used for ads. * feat(parser): ignore `BrandVideoSingleton` too
41 lines
1.4 KiB
TypeScript
41 lines
1.4 KiB
TypeScript
import { YTNode, type ObservedArray } from '../helpers.js';
|
|
import Parser, { type RawNode } from '../index.js';
|
|
import Author from './misc/Author.js';
|
|
import Text from './misc/Text.js';
|
|
import Thumbnail from './misc/Thumbnail.js';
|
|
import NavigationEndpoint from './NavigationEndpoint.js';
|
|
|
|
export default class GridPlaylist extends YTNode {
|
|
static type = 'GridPlaylist';
|
|
|
|
id: string;
|
|
title: Text;
|
|
author?: Author;
|
|
badges: ObservedArray<YTNode>;
|
|
endpoint: NavigationEndpoint;
|
|
view_playlist: Text;
|
|
thumbnails: Thumbnail[];
|
|
thumbnail_renderer;
|
|
sidebar_thumbnails: Thumbnail[] | null;
|
|
video_count: Text;
|
|
video_count_short: Text;
|
|
|
|
constructor(data: RawNode) {
|
|
super();
|
|
this.id = data.playlistId;
|
|
this.title = new Text(data.title);
|
|
|
|
if (Reflect.has(data, 'shortBylineText')) {
|
|
this.author = new Author(data.shortBylineText, data.ownerBadges);
|
|
}
|
|
|
|
this.badges = Parser.parseArray(data.ownerBadges);
|
|
this.endpoint = new NavigationEndpoint(data.navigationEndpoint);
|
|
this.view_playlist = new Text(data.viewPlaylistText);
|
|
this.thumbnails = Thumbnail.fromResponse(data.thumbnail);
|
|
this.thumbnail_renderer = Parser.parseItem(data.thumbnailRenderer);
|
|
this.sidebar_thumbnails = [].concat(...data.sidebarThumbnails?.map((thumbnail: any) => Thumbnail.fromResponse(thumbnail)) || []) || null;
|
|
this.video_count = new Text(data.thumbnailText);
|
|
this.video_count_short = new Text(data.videoCountShortText);
|
|
}
|
|
} |