diff --git a/src/parser/classes/AvatarView.ts b/src/parser/classes/AvatarView.ts new file mode 100644 index 000000000..faeb826c9 --- /dev/null +++ b/src/parser/classes/AvatarView.ts @@ -0,0 +1,30 @@ +import { YTNode } from '../helpers.js'; +import { type RawNode } from '../index.js'; +import { Thumbnail } from '../misc.js'; + +export default class AvatarView extends YTNode { + static type = 'AvatarView'; + + image: { + sources: Thumbnail[], + processor: { + border_image_processor: { + circular: boolean + } + } + }; + avatar_image_size: string; + + constructor(data: RawNode) { + super(); + this.image = { + sources: data.image.sources.map((x: any) => new Thumbnail(x)).sort((a: Thumbnail, b: Thumbnail) => b.width - a.width), + processor: { + border_image_processor: { + circular: data.image.processor.borderImageProcessor.circular + } + } + }; + this.avatar_image_size = data.avatarImageSize; + } +} \ No newline at end of file diff --git a/src/parser/classes/DecoratedAvatarView.ts b/src/parser/classes/DecoratedAvatarView.ts new file mode 100644 index 000000000..c6fd82ae9 --- /dev/null +++ b/src/parser/classes/DecoratedAvatarView.ts @@ -0,0 +1,19 @@ +import { YTNode } from '../helpers.js'; +import type { RawNode } from '../index.js'; +import NavigationEndpoint from './NavigationEndpoint.js'; +import AvatarView from './AvatarView.js'; + +export default class DecoratedAvatarView extends YTNode { + static type = 'DecoratedAvatarView'; + + avatar: AvatarView; + a11y_label: string; + on_tap_endpoint: NavigationEndpoint; + + constructor(data: RawNode) { + super(); + this.avatar = new AvatarView(data.avatar.avatarViewModel); + this.a11y_label = data.a11yLabel; + this.on_tap_endpoint = new NavigationEndpoint(data.rendererContext.commandContext.onTap.innertubeCommand); + } +} \ No newline at end of file diff --git a/src/parser/classes/PageHeaderView.ts b/src/parser/classes/PageHeaderView.ts index cd7dbc646..be75187a6 100644 --- a/src/parser/classes/PageHeaderView.ts +++ b/src/parser/classes/PageHeaderView.ts @@ -2,6 +2,7 @@ import { YTNode } from '../helpers.js'; import { Parser, type RawNode } from '../index.js'; import ContentMetadataView from './ContentMetadataView.js'; import ContentPreviewImageView from './ContentPreviewImageView.js'; +import DecoratedAvatarView from './DecoratedAvatarView.js'; import DynamicTextView from './DynamicTextView.js'; import FlexibleActionsView from './FlexibleActionsView.js'; @@ -9,14 +10,14 @@ export default class PageHeaderView extends YTNode { static type = 'PageHeaderView'; title: DynamicTextView | null; - image: ContentPreviewImageView | null; + image: ContentPreviewImageView | DecoratedAvatarView | null; metadata: ContentMetadataView | null; actions: FlexibleActionsView | null; constructor(data: RawNode) { super(); this.title = Parser.parseItem(data.title, DynamicTextView); - this.image = Parser.parseItem(data.image, ContentPreviewImageView); + this.image = Parser.parseItem(data.image, [ ContentPreviewImageView, DecoratedAvatarView ]); this.metadata = Parser.parseItem(data.metadata, ContentMetadataView); this.actions = Parser.parseItem(data.actions, FlexibleActionsView); } diff --git a/src/parser/nodes.ts b/src/parser/nodes.ts index 88d7c3138..f974cec3d 100644 --- a/src/parser/nodes.ts +++ b/src/parser/nodes.ts @@ -22,6 +22,7 @@ export { default as DataModelSection } from './classes/analytics/DataModelSectio export { default as StatRow } from './classes/analytics/StatRow.js'; export { default as AudioOnlyPlayability } from './classes/AudioOnlyPlayability.js'; export { default as AutomixPreviewVideo } from './classes/AutomixPreviewVideo.js'; +export { default as AvatarView } from './classes/AvatarView.js'; export { default as BackstageImage } from './classes/BackstageImage.js'; export { default as BackstagePost } from './classes/BackstagePost.js'; export { default as BackstagePostThread } from './classes/BackstagePostThread.js'; @@ -93,6 +94,7 @@ export { default as ContinuationItem } from './classes/ContinuationItem.js'; export { default as ConversationBar } from './classes/ConversationBar.js'; export { default as CopyLink } from './classes/CopyLink.js'; export { default as CreatePlaylistDialog } from './classes/CreatePlaylistDialog.js'; +export { default as DecoratedAvatarView } from './classes/DecoratedAvatarView.js'; export { default as DecoratedPlayerBar } from './classes/DecoratedPlayerBar.js'; export { default as DefaultPromoPanel } from './classes/DefaultPromoPanel.js'; export { default as DidYouMean } from './classes/DidYouMean.js';