mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-19 12:31:17 +00:00
feat(parser): add InfoPanelContent and InfoPanelContainer nodes
These are usually used to add more context to videos that discuss misinformation. Fixes: #326
This commit is contained in:
33
src/parser/classes/InfoPanelContent.ts
Normal file
33
src/parser/classes/InfoPanelContent.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { YTNode } from '../helpers.js';
|
||||
import { RawNode } from '../index.js';
|
||||
import Text from './misc/Text.js';
|
||||
import Thumbnail from './misc/Thumbnail.js';
|
||||
import NavigationEndpoint from './NavigationEndpoint.js';
|
||||
|
||||
export default class InfoPanelContent extends YTNode {
|
||||
static type = 'InfoPanelContent';
|
||||
|
||||
title: Text;
|
||||
inline_link_icon_type?: string;
|
||||
source: Text;
|
||||
paragraphs: Text[];
|
||||
thumbnail: Thumbnail[];
|
||||
source_endpoint: NavigationEndpoint;
|
||||
truncate_paragraphs: boolean;
|
||||
background: string;
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
this.title = new Text(data.title);
|
||||
this.source = new Text(data.source);
|
||||
this.paragraphs = data.paragraphs.map((p: RawNode) => new Text(p));
|
||||
this.thumbnail = Thumbnail.fromResponse(data.thumbnail);
|
||||
this.source_endpoint = new NavigationEndpoint(data.sourceEndpoint);
|
||||
this.truncate_paragraphs = !!data.truncateParagraphs;
|
||||
this.background = data.background;
|
||||
|
||||
if (data.inlineLinkIcon?.iconType) {
|
||||
this.inline_link_icon_type = data.inlineLinkIcon.iconType;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user