-
-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(parser): add InfoPanelContent and InfoPanelContainer nodes
These are usually used to add more context to videos that discuss misinformation. Fixes: #326
- Loading branch information
Showing
3 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { YTNode } from '../helpers.js'; | ||
import Parser, { RawNode } from '../index.js'; | ||
import InfoPanelContent from './InfoPanelContent.js'; | ||
import Menu from './menus/Menu.js'; | ||
import Text from './misc/Text.js'; | ||
|
||
export default class InfoPanelContainer extends YTNode { | ||
static type = 'InfoPanelContainer'; | ||
|
||
icon_type?: string; | ||
title: Text; | ||
menu: Menu | null; | ||
content: YTNode | null; | ||
background: string; | ||
|
||
constructor(data: RawNode) { | ||
super(); | ||
this.title = new Text(data.title); | ||
this.menu = Parser.parseItem(data.menu, Menu); | ||
this.content = Parser.parseItem(data.content, InfoPanelContent); | ||
this.background = data.background; | ||
|
||
if (data.icon?.iconType) { | ||
this.icon_type = data.icon.iconType; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters