mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-26 16:18:51 +00:00
refactor(parser): improve typings and do some refactoring (#305)
* dev: add response types * dev: refactor `Parser#parseResponse()` * dev: update YouTube parsers * dev: update YouTube Music classes * dev: update YouTube Kids classes * dev: update core classes * dev(Parser): fix some inconsistencies * chore: update docs * chore: update docs x2 * fix: export response types * chore(docs): update parser example
This commit is contained in:
@@ -11,23 +11,35 @@ class MusicShelf extends YTNode {
|
||||
|
||||
title: Text;
|
||||
contents;
|
||||
endpoint: NavigationEndpoint | null;
|
||||
continuation: string | null;
|
||||
bottom_text: Text | null;
|
||||
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);
|
||||
this.endpoint = Reflect.has(data, 'bottomEndpoint') ? new NavigationEndpoint(data.bottomEndpoint) : null;
|
||||
this.continuation =
|
||||
data.continuations?.[0].nextContinuationData?.continuation ||
|
||||
data.continuations?.[0].reloadContinuationData?.continuation || null;
|
||||
this.bottom_text = Reflect.has(data, 'bottomText') ? new Text(data.bottomText) : null;
|
||||
this.bottom_button = Parser.parseItem(data.bottomButton, Button);
|
||||
|
||||
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<Button>(data.bottomButton);
|
||||
}
|
||||
|
||||
if (data.subheaders) {
|
||||
this.subheaders = Parser.parseArray(data.subheaders);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user