-
-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(parser): Add
AddToPlaylist
node
- Loading branch information
Showing
4 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<MenuTitle | Button>; | ||
public playlists: ObservedArray<PlaylistAddToOption>; | ||
|
||
constructor(data: RawNode) { | ||
super(); | ||
this.actions = Parser.parseArray(data.actions, [ MenuTitle, Button ]); | ||
this.playlists = Parser.parseArray(data.playlists, PlaylistAddToOption); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters