mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-07-04 03:51:00 +00:00
feat: add music#getRecap() (#165)
* dev: add recap renderer parsers
* dev: finish implementation ✨
* docs: update YouTube Music API ref
This commit is contained in:
59
src/parser/classes/MusicLargeCardItemCarousel.ts
Normal file
59
src/parser/classes/MusicLargeCardItemCarousel.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
import NavigationEndpoint from './NavigationEndpoint';
|
||||
import { YTNode } from '../helpers';
|
||||
|
||||
class ActionButton {
|
||||
static type = 'ActionButton';
|
||||
|
||||
icon_name: string;
|
||||
endpoint: NavigationEndpoint;
|
||||
a11y_text: string;
|
||||
style: string;
|
||||
|
||||
constructor(data: any) {
|
||||
this.icon_name = data.iconName;
|
||||
this.endpoint = new NavigationEndpoint(data.onTap);
|
||||
this.a11y_text = data.a11yText;
|
||||
this.style = data.style;
|
||||
}
|
||||
}
|
||||
|
||||
class Panel {
|
||||
static type = 'Panel';
|
||||
|
||||
image: {
|
||||
url: string;
|
||||
width: number;
|
||||
height: number;
|
||||
}[];
|
||||
|
||||
content_mode: string;
|
||||
crop_options: string;
|
||||
image_aspect_ratio: string;
|
||||
caption: string;
|
||||
action_buttons: ActionButton[];
|
||||
|
||||
constructor (data: any) {
|
||||
this.image = data.image.image.sources;
|
||||
this.content_mode = data.image.contentMode;
|
||||
this.crop_options = data.image.cropOptions;
|
||||
this.image_aspect_ratio = data.imageAspectRatio;
|
||||
this.caption = data.caption;
|
||||
this.action_buttons = data.actionButtons.map((el: any) => new ActionButton(el));
|
||||
}
|
||||
}
|
||||
|
||||
class MusicLargeCardItemCarousel extends YTNode {
|
||||
static type = 'MusicLargeCardItemCarousel';
|
||||
|
||||
panels: Panel[];
|
||||
header;
|
||||
|
||||
constructor(data: any) {
|
||||
super();
|
||||
// TODO: check this
|
||||
this.header = data.shelf.header;
|
||||
this.panels = data.shelf.panels.map((el: any) => new Panel(el));
|
||||
}
|
||||
}
|
||||
|
||||
export default MusicLargeCardItemCarousel;
|
||||
Reference in New Issue
Block a user