diff --git a/src/parser/classes/SharePanelHeader.ts b/src/parser/classes/SharePanelHeader.ts new file mode 100644 index 000000000..846d0c84c --- /dev/null +++ b/src/parser/classes/SharePanelHeader.ts @@ -0,0 +1,13 @@ +import { type RawNode, Parser } from '../index.js'; +import { YTNode } from '../helpers.js'; + +export default class SharePanelHeader extends YTNode { + static type = 'SharePanelHeader'; + + public title: YTNode; + + constructor(data: RawNode) { + super(); + this.title = Parser.parseItem(data.title); + } +} \ No newline at end of file diff --git a/src/parser/classes/SharePanelTitleV15.ts b/src/parser/classes/SharePanelTitleV15.ts new file mode 100644 index 000000000..3aa16e0dc --- /dev/null +++ b/src/parser/classes/SharePanelTitleV15.ts @@ -0,0 +1,14 @@ +import type { RawNode } from '../index.js'; +import { YTNode } from '../helpers.js'; +import { Text } from '../misc.js'; + +export default class SharePanelTitleV15 extends YTNode { + static type = 'SharePanelTitleV15'; + + public title: Text; + + constructor(data: RawNode) { + super(); + this.title = new Text(data.title); + } +} \ No newline at end of file diff --git a/src/parser/classes/ShareTarget.ts b/src/parser/classes/ShareTarget.ts new file mode 100644 index 000000000..8b561c09e --- /dev/null +++ b/src/parser/classes/ShareTarget.ts @@ -0,0 +1,25 @@ +import type { RawNode } from '../index.js'; +import { Text } from '../misc.js'; +import { YTNode } from '../helpers.js'; +import NavigationEndpoint from './NavigationEndpoint.js'; + +export default class ShareTarget extends YTNode { + static type = 'ShareTarget'; + + public endpoint?: NavigationEndpoint; + public service_name: string; + public target_id: string; + public title: Text; + + constructor(data: RawNode) { + super(); + if (Reflect.has(data, 'serviceEndpoint')) + this.endpoint = new NavigationEndpoint(data.serviceEndpoint); + else if (Reflect.has(data, 'navigationEndpoint')) + this.endpoint = new NavigationEndpoint(data.navigationEndpoint); + + this.service_name = data.serviceName; + this.target_id = data.targetId; + this.title = new Text(data.title); + } +} \ No newline at end of file diff --git a/src/parser/classes/StartAt.ts b/src/parser/classes/StartAt.ts new file mode 100644 index 000000000..f786f0905 --- /dev/null +++ b/src/parser/classes/StartAt.ts @@ -0,0 +1,14 @@ +import type { RawNode } from '../index.js'; +import { YTNode } from '../helpers.js'; +import { Text } from '../misc.js'; + +export default class StartAt extends YTNode { + static type = 'StartAt'; + + public start_at_option_label: Text; + + constructor(data: RawNode) { + super(); + this.start_at_option_label = new Text(data.startAtOptionLabel); + } +} \ No newline at end of file diff --git a/src/parser/classes/ThirdPartyShareTargetSection.ts b/src/parser/classes/ThirdPartyShareTargetSection.ts new file mode 100644 index 000000000..80f02efb8 --- /dev/null +++ b/src/parser/classes/ThirdPartyShareTargetSection.ts @@ -0,0 +1,14 @@ +import { type RawNode, Parser } from '../index.js'; +import { type ObservedArray, YTNode } from '../helpers.js'; +import ShareTarget from './ShareTarget.js'; + +export default class ThirdPartyShareTargetSection extends YTNode { + static type = 'ThirdPartyShareTargetSection'; + + public share_targets: ObservedArray; + + constructor(data: RawNode) { + super(); + this.share_targets = Parser.parseArray(data.shareTargets, ShareTarget); + } +} \ No newline at end of file diff --git a/src/parser/classes/UnifiedSharePanel .ts b/src/parser/classes/UnifiedSharePanel .ts new file mode 100644 index 000000000..1db210585 --- /dev/null +++ b/src/parser/classes/UnifiedSharePanel .ts @@ -0,0 +1,37 @@ +import { YTNode } from '../helpers.js'; +import { Parser, type RawNode } from '../index.js'; + +import StartAt from './StartAt.js'; +import CopyLink from './CopyLink.js'; +import SharePanelHeader from './SharePanelHeader.js'; +import ThirdPartyShareTargetSection from './ThirdPartyShareTargetSection.js'; + +export type ThirdPartyNetworkSection = { + share_target_container: ThirdPartyShareTargetSection | null, + copy_link_container: CopyLink | null, + start_at_container: StartAt | null +}; + +export default class UnifiedSharePanel extends YTNode { + static type = 'UnifiedSharePanel'; + + public third_party_network_section?: ThirdPartyNetworkSection; + public header: SharePanelHeader | null; + public share_panel_version: number; + + constructor(data: RawNode) { + super(); + const contents = data.contents.find((content: RawNode) => content.thirdPartyNetworkSection); + + if (!contents) { + this.third_party_network_section = { + share_target_container: Parser.parseItem(contents.thirdPartyNetworkSection.shareTargetContainer, ThirdPartyShareTargetSection), + copy_link_container: Parser.parseItem(contents.thirdPartyNetworkSection.copyLinkContainer, CopyLink), + start_at_container: Parser.parseItem(contents.thirdPartyNetworkSection.startAtContainer, StartAt) + }; + } + + this.header = Parser.parseItem(data.header, SharePanelHeader); + this.share_panel_version = data.sharePanelVersion; + } +} \ No newline at end of file diff --git a/src/parser/nodes.ts b/src/parser/nodes.ts index 068f82c67..7b08938c3 100644 --- a/src/parser/nodes.ts +++ b/src/parser/nodes.ts @@ -358,6 +358,9 @@ export { default as SettingsOptions } from './classes/SettingsOptions.js'; export { default as SettingsSidebar } from './classes/SettingsSidebar.js'; export { default as SettingsSwitch } from './classes/SettingsSwitch.js'; export { default as SharedPost } from './classes/SharedPost.js'; +export { default as SharePanelHeader } from './classes/SharePanelHeader.js'; +export { default as SharePanelTitleV15 } from './classes/SharePanelTitleV15.js'; +export { default as ShareTarget } from './classes/ShareTarget.js'; export { default as Shelf } from './classes/Shelf.js'; export { default as ShortsLockupView } from './classes/ShortsLockupView.js'; export { default as ShowCustomThumbnail } from './classes/ShowCustomThumbnail.js'; @@ -373,6 +376,7 @@ export { default as SlimOwner } from './classes/SlimOwner.js'; export { default as SlimVideoMetadata } from './classes/SlimVideoMetadata.js'; export { default as SortFilterHeader } from './classes/SortFilterHeader.js'; export { default as SortFilterSubMenu } from './classes/SortFilterSubMenu.js'; +export { default as StartAt } from './classes/StartAt.js'; export { default as StructuredDescriptionContent } from './classes/StructuredDescriptionContent.js'; export { default as StructuredDescriptionPlaylistLockup } from './classes/StructuredDescriptionPlaylistLockup.js'; export { default as SubFeedOption } from './classes/SubFeedOption.js'; @@ -383,6 +387,7 @@ export { default as Tab } from './classes/Tab.js'; export { default as Tabbed } from './classes/Tabbed.js'; export { default as TabbedSearchResults } from './classes/TabbedSearchResults.js'; export { default as TextHeader } from './classes/TextHeader.js'; +export { default as ThirdPartyShareTargetSection } from './classes/ThirdPartyShareTargetSection.js'; export { default as ThumbnailBadgeView } from './classes/ThumbnailBadgeView.js'; export { default as ThumbnailHoverOverlayView } from './classes/ThumbnailHoverOverlayView.js'; export { default as ThumbnailLandscapePortrait } from './classes/ThumbnailLandscapePortrait.js'; @@ -417,6 +422,7 @@ export { default as TranscriptSegmentList } from './classes/TranscriptSegmentLis export { default as TwoColumnBrowseResults } from './classes/TwoColumnBrowseResults.js'; export { default as TwoColumnSearchResults } from './classes/TwoColumnSearchResults.js'; export { default as TwoColumnWatchNextResults } from './classes/TwoColumnWatchNextResults.js'; +export { default as UnifiedSharePanel } from './classes/UnifiedSharePanel .js'; export { default as UniversalWatchCard } from './classes/UniversalWatchCard.js'; export { default as UploadTimeFactoid } from './classes/UploadTimeFactoid.js'; export { default as UpsellDialog } from './classes/UpsellDialog.js';