mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-13 01:22:11 +00:00
feat(parser): Add PlaylistThumbnailOverlay
This commit is contained in:
17
src/parser/classes/PlaylistThumbnailOverlay.ts
Normal file
17
src/parser/classes/PlaylistThumbnailOverlay.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { YTNode } from '../helpers.js';
|
||||
import { type RawNode } from '../index.js';
|
||||
import Text from './misc/Text.js';
|
||||
|
||||
export default class PlaylistThumbnailOverlay extends YTNode {
|
||||
static type = 'PlaylistThumbnailOverlay';
|
||||
|
||||
public icon_type?: string;
|
||||
public text: Text;
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
if (Reflect.has(data, 'icon'))
|
||||
this.icon_type = data.icon.iconType;
|
||||
this.text = new Text(data.text);
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,7 @@ export default class Video extends YTNode {
|
||||
show_action_menu: boolean;
|
||||
is_watched: boolean;
|
||||
menu: Menu | null;
|
||||
byline_text?: Text;
|
||||
search_video_result_entity_key?: string;
|
||||
|
||||
constructor(data: RawNode) {
|
||||
@@ -91,6 +92,10 @@ export default class Video extends YTNode {
|
||||
if (Reflect.has(data, 'searchVideoResultEntityKey')) {
|
||||
this.search_video_result_entity_key = data.searchVideoResultEntityKey;
|
||||
}
|
||||
|
||||
if (Reflect.has(data, 'bylineText')) {
|
||||
this.byline_text = new Text(data.bylineText);
|
||||
}
|
||||
}
|
||||
|
||||
get description(): string {
|
||||
|
||||
@@ -5,16 +5,20 @@ import Video from './Video.js';
|
||||
|
||||
export default class VideoCard extends Video {
|
||||
static type = 'VideoCard';
|
||||
|
||||
public metadata_text?: Text;
|
||||
public byline_text?: Text;
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super(data);
|
||||
if (Reflect.has(data, 'metadataText')) {
|
||||
const metadata = new Text(data.metadataText);
|
||||
if (metadata.text) {
|
||||
this.short_view_count = new Text({ simpleText: metadata.text.split('·')[0].trim() } as RawNode);
|
||||
this.published = new Text({ simpleText: metadata.text.split('·')[1].trim() } as RawNode);
|
||||
this.metadata_text = new Text(data.metadataText);
|
||||
if (this.metadata_text.text) {
|
||||
this.short_view_count = new Text({ simpleText: this.metadata_text.text.split('·')[0]?.trim() } as RawNode);
|
||||
this.published = new Text({ simpleText: this.metadata_text.text.split('·')[1]?.trim() } as RawNode);
|
||||
}
|
||||
}
|
||||
|
||||
if (Reflect.has(data, 'bylineText')) {
|
||||
this.author = new Author(data.bylineText, data.ownerBadges, data.channelThumbnailSupportedRenderers?.channelThumbnailWithLinkRenderer?.thumbnail);
|
||||
}
|
||||
|
||||
@@ -8,20 +8,21 @@ import SegmentedLikeDislikeButtonView from '../SegmentedLikeDislikeButtonView.js
|
||||
import MenuFlexibleItem from './MenuFlexibleItem.js';
|
||||
import LikeButton from '../LikeButton.js';
|
||||
import ToggleButton from '../ToggleButton.js';
|
||||
import FlexibleActionsView from '../FlexibleActionsView.js';
|
||||
|
||||
export default class Menu extends YTNode {
|
||||
static type = 'Menu';
|
||||
|
||||
public items: ObservedArray<YTNode>;
|
||||
public flexible_items: ObservedArray<MenuFlexibleItem>;
|
||||
public top_level_buttons: ObservedArray<ToggleButton | LikeButton | Button |ButtonView | SegmentedLikeDislikeButtonView>;
|
||||
public top_level_buttons: ObservedArray<ToggleButton | LikeButton | Button |ButtonView | SegmentedLikeDislikeButtonView | FlexibleActionsView>;
|
||||
public label?: string;
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
this.items = Parser.parseArray(data.items);
|
||||
this.flexible_items = Parser.parseArray(data.flexibleItems, MenuFlexibleItem);
|
||||
this.top_level_buttons = Parser.parseArray(data.topLevelButtons, [ ToggleButton, LikeButton, Button, ButtonView, SegmentedLikeDislikeButtonView ]);
|
||||
this.top_level_buttons = Parser.parseArray(data.topLevelButtons, [ ToggleButton, LikeButton, Button, ButtonView, SegmentedLikeDislikeButtonView, FlexibleActionsView ]);
|
||||
|
||||
if (Reflect.has(data, 'accessibility') && Reflect.has(data.accessibility, 'accessibilityData')) {
|
||||
this.label = data.accessibility.accessibilityData.label;
|
||||
|
||||
@@ -361,6 +361,7 @@ export { default as PlaylistPanelVideoWrapper } from './classes/PlaylistPanelVid
|
||||
export { default as PlaylistSidebar } from './classes/PlaylistSidebar.js';
|
||||
export { default as PlaylistSidebarPrimaryInfo } from './classes/PlaylistSidebarPrimaryInfo.js';
|
||||
export { default as PlaylistSidebarSecondaryInfo } from './classes/PlaylistSidebarSecondaryInfo.js';
|
||||
export { default as PlaylistThumbnailOverlay } from './classes/PlaylistThumbnailOverlay.js';
|
||||
export { default as PlaylistVideo } from './classes/PlaylistVideo.js';
|
||||
export { default as PlaylistVideoList } from './classes/PlaylistVideoList.js';
|
||||
export { default as PlaylistVideoThumbnail } from './classes/PlaylistVideoThumbnail.js';
|
||||
|
||||
Reference in New Issue
Block a user