diff --git a/src/parser/classes/AddToPlaylist.ts b/src/parser/classes/AddToPlaylist.ts new file mode 100644 index 000000000..8e97fc82c --- /dev/null +++ b/src/parser/classes/AddToPlaylist.ts @@ -0,0 +1,18 @@ +import { type ObservedArray, YTNode } from '../helpers.js'; +import { Parser, type RawNode } from '../index.js'; +import Button from './Button.js'; +import MenuTitle from './MenuTitle.js'; +import PlaylistAddToOption from './PlaylistAddToOption.js'; + +export default class AddToPlaylist extends YTNode { + static type = 'AddToPlaylist'; + + public actions: ObservedArray; + public playlists: ObservedArray; + + constructor(data: RawNode) { + super(); + this.actions = Parser.parseArray(data.actions, [ MenuTitle, Button ]); + this.playlists = Parser.parseArray(data.playlists, PlaylistAddToOption); + } +} \ No newline at end of file diff --git a/src/parser/classes/MenuTitle.ts b/src/parser/classes/MenuTitle.ts new file mode 100644 index 000000000..139217e73 --- /dev/null +++ b/src/parser/classes/MenuTitle.ts @@ -0,0 +1,14 @@ +import { YTNode } from '../helpers.js'; +import { Text } from '../misc.js'; +import type { RawNode } from '../index.js'; + +export default class MenuTitle extends YTNode { + static type = 'MenuTitle'; + + 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/PlaylistAddToOption.ts b/src/parser/classes/PlaylistAddToOption.ts new file mode 100644 index 000000000..c877eba07 --- /dev/null +++ b/src/parser/classes/PlaylistAddToOption.ts @@ -0,0 +1,31 @@ +import { YTNode } from '../helpers.js'; +import { Text } from '../misc.js'; +import NavigationEndpoint from './NavigationEndpoint.js'; +import type { RawNode } from '../index.js'; + +export type PrivacyIcon = { + icon_type: string | null; +}; + +export default class PlaylistAddToOption extends YTNode { + static type = 'PlaylistAddToOption'; + + public add_to_playlist_service_endpoint: NavigationEndpoint; + public contains_selected_videos: boolean; + public playlist_id: string; + public privacy: string; + public privacy_icon: PrivacyIcon; + public remove_from_playlist_service_endpoint: NavigationEndpoint; + public title: Text; + + constructor(data: RawNode) { + super(); + this.add_to_playlist_service_endpoint = new NavigationEndpoint(data.addToPlaylistServiceEndpoint); + this.contains_selected_videos = data.containsSelectedVideos; + this.playlist_id = data.playlistId; + this.privacy = data.privacy; + this.privacy_icon = { icon_type: data.privacyIcon?.iconType || null }; + this.remove_from_playlist_service_endpoint = new NavigationEndpoint(data.removeFromPlaylistServiceEndpoint); + this.title = new Text(data.title); + } +} \ No newline at end of file diff --git a/src/parser/nodes.ts b/src/parser/nodes.ts index b44c214c0..95f526217 100644 --- a/src/parser/nodes.ts +++ b/src/parser/nodes.ts @@ -14,6 +14,7 @@ export { default as OpenPopupAction } from './classes/actions/OpenPopupAction.js export { default as SignalAction } from './classes/actions/SignalAction.js'; export { default as UpdateEngagementPanelAction } from './classes/actions/UpdateEngagementPanelAction.js'; export { default as UpdateSubscribeButtonAction } from './classes/actions/UpdateSubscribeButtonAction.js'; +export { default as AddToPlaylist } from './classes/AddToPlaylist.js'; export { default as Alert } from './classes/Alert.js'; export { default as AlertWithButton } from './classes/AlertWithButton.js'; export { default as AnalyticsMainAppKeyMetrics } from './classes/analytics/AnalyticsMainAppKeyMetrics.js'; @@ -240,6 +241,7 @@ export { default as MusicMenuItemDivider } from './classes/menus/MusicMenuItemDi export { default as MusicMultiSelectMenu } from './classes/menus/MusicMultiSelectMenu.js'; export { default as MusicMultiSelectMenuItem } from './classes/menus/MusicMultiSelectMenuItem.js'; export { default as SimpleMenuHeader } from './classes/menus/SimpleMenuHeader.js'; +export { default as MenuTitle } from './classes/MenuTitle.js'; export { default as MerchandiseItem } from './classes/MerchandiseItem.js'; export { default as MerchandiseShelf } from './classes/MerchandiseShelf.js'; export { default as Message } from './classes/Message.js'; @@ -307,6 +309,7 @@ export { default as PlayerOverlayAutoplay } from './classes/PlayerOverlayAutopla export { default as PlayerOverlayVideoDetails } from './classes/PlayerOverlayVideoDetails.js'; export { default as PlayerStoryboardSpec } from './classes/PlayerStoryboardSpec.js'; export { default as Playlist } from './classes/Playlist.js'; +export { default as PlaylistAddToOption } from './classes/PlaylistAddToOption.js'; export { default as PlaylistCustomThumbnail } from './classes/PlaylistCustomThumbnail.js'; export { default as PlaylistHeader } from './classes/PlaylistHeader.js'; export { default as PlaylistInfoCardContent } from './classes/PlaylistInfoCardContent.js';