Files
YouTube.js/src/parser/classes/MusicShelf.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

49 lines
1.3 KiB
TypeScript

import Parser from '../index.js';
import Text from './misc/Text.js';
import NavigationEndpoint from './NavigationEndpoint.js';
import MusicResponsiveListItem from './MusicResponsiveListItem.js';
import { YTNode } from '../helpers.js';
import Button from './Button.js';
class MusicShelf extends YTNode {
static type = 'MusicShelf';
title: Text;
contents;
endpoint?: NavigationEndpoint;
continuation?: string;
bottom_text?: Text;
bottom_button?: Button | null;
subheaders?: Array<any>;
constructor(data: any) {
super();
this.title = new Text(data.title);
this.contents = Parser.parseArray<MusicResponsiveListItem>(data.contents, MusicResponsiveListItem);
if (data.bottomEndpoint) {
this.endpoint = new NavigationEndpoint(data.bottomEndpoint);
}
if (data.continuations) {
this.continuation =
data.continuations?.[0].nextContinuationData?.continuation ||
data.continuations?.[0].reloadContinuationData?.continuation;
}
if (data.bottomText) {
this.bottom_text = new Text(data.bottomText);
}
if (data.bottomButton) {
this.bottom_button = Parser.parseItem(data.bottomButton, Button);
}
if (data.subheaders) {
this.subheaders = Parser.parseArray(data.subheaders);
}
}
}
export default MusicShelf;