Files
YouTube.js/src/parser/classes/GridPlaylist.ts
Daniel Wykerd b13bf6e992 refactor(Parser)!: general refactoring of parsers (#344)
* refactor: move common info into MediaInfo

* refactor: better inference on Memo

* refactor: improved typesafety in parser methods

* refactor: remove PlaylistAuthor in favor of Author

* refactor: cleanup live chat parsers

- Replace non standard author type with Author class
- Remove redundant code

* fix: new errors due to changes

* fix: pass actions to FormatUtils#toDash

* refactor!: merge NavigatableText and Text into single class
2023-03-15 18:25:12 -03:00

43 lines
1.4 KiB
TypeScript

import { YTNode } from '../helpers.js';
import Parser, { 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';
class GridPlaylist extends YTNode {
static type = 'GridPlaylist';
id: string;
title: Text;
author?: Author;
badges;
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 (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);
}
}
export default GridPlaylist;