mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-07-04 12:47:04 +00:00
feat(parser): Add UnifiedSharePanel
This commit is contained in:
13
src/parser/classes/SharePanelHeader.ts
Normal file
13
src/parser/classes/SharePanelHeader.ts
Normal file
@@ -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);
|
||||
}
|
||||
}
|
||||
14
src/parser/classes/SharePanelTitleV15.ts
Normal file
14
src/parser/classes/SharePanelTitleV15.ts
Normal file
@@ -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);
|
||||
}
|
||||
}
|
||||
25
src/parser/classes/ShareTarget.ts
Normal file
25
src/parser/classes/ShareTarget.ts
Normal file
@@ -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);
|
||||
}
|
||||
}
|
||||
14
src/parser/classes/StartAt.ts
Normal file
14
src/parser/classes/StartAt.ts
Normal file
@@ -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);
|
||||
}
|
||||
}
|
||||
14
src/parser/classes/ThirdPartyShareTargetSection.ts
Normal file
14
src/parser/classes/ThirdPartyShareTargetSection.ts
Normal file
@@ -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<ShareTarget>;
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
this.share_targets = Parser.parseArray(data.shareTargets, ShareTarget);
|
||||
}
|
||||
}
|
||||
37
src/parser/classes/UnifiedSharePanel .ts
Normal file
37
src/parser/classes/UnifiedSharePanel .ts
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user