Documentation
Library Exports.Playlist
A YouTube playlist.
Constructors
constructor
• new Playlist(youtube
, data
, full?
)
Parameters
Name | Type | Default value |
---|---|---|
youtube | YouTube | undefined |
data | any | undefined |
full | boolean | false |
Defined in
Properties
creatorId
• creatorId: string
The ID of the creator of the playlist.
Defined in
data
• data: any
The raw data of this playlist.
Defined in
dateCreated
• dateCreated: Date
The date the playlist was created.
Defined in
description
• description: string
The description of the playlist.
Defined in
embedHtml
• embedHtml: string
An \<iframe> tag that embeds a player that will play the playlist.
Defined in
full
• full: boolean
Whether or not this is a full playlist object.
Defined in
id
• id: string
The ID of this playlist.
Defined in
length
• length: number
The number of items in the playlist.
Defined in
privacy
• privacy: "private"
| "public"
| "unlisted"
Information on this playlist's privacy.
Defined in
tags
• tags: string
[]
The tags of the playlist.
Defined in
thumbnails
• thumbnails: Object
The thumbnails for the playlist.
Type declaration
Name | Type |
---|---|
default? | Thumbnail |
high? | Thumbnail |
maxres? | Thumbnail |
medium? | Thumbnail |
standard? | Thumbnail |
Defined in
title
• title: string
The title of the playlist.
Defined in
url
• url: string
The url of the playlist.
Defined in
videos
• videos: PaginatedResponse
<Video
>
The videos in the playlist. Only available after calling Playlist.fetchVideos()
.
These are partial, meaning they are missing some data.
See the properties they include here.
Use YouTube.getVideo(playlist.videos)
to fetch the full objects while not spamming your quota
like you would using a loop.
Defined in
youtube
• youtube: YouTube
The YouTube object that created this playlist.
Defined in
endpoint
▪ Static
endpoint: string
= 'playlists'
The name of the endpoint used for this entity.
Defined in
fields
▪ Static
fields: string
The fields to request for this entity.
Defined in
part
▪ Static
part: string
= 'snippet,contentDetails,player,status'
The parts to request for this entity.
Defined in
Methods
addVideo
▸ addVideo(videoResolvable
, position?
, note?
): Promise
<Video
>
Adds a Video to the playlist. Must be using an access token with correct scopes.
Parameters
Name | Type | Description |
---|---|---|
videoResolvable | VideoResolvable | The URL, ID, or search query of the video. |
position? | number | The zero-based position to insert the video in. |
note? | string | A note on the video. |
Returns
Promise
<Video
>
Defined in
delete
▸ delete(): Promise
<void
>
Deletes the playlist. Must be using an access token with correct scopes.
Returns
Promise
<void
>
Defined in
fetch
▸ fetch(parts?
): Promise
<Playlist
>
Fetches this playlist from the API and reassigns this object to the new playlist object.
Only useful if this.full
is false, or if you want updated playlist info.
Parameters
Name | Type |
---|---|
parts? | PlaylistParts |
Returns
Promise
<Playlist
>
Defined in
fetchVideos
▸ fetchVideos(pageOptions?
, parts?
): Promise
<PaginatedResponse
<Video
>>
Fetches the videos in this playlist from the API and adds them to the videos
property.
These are partial, meaning they are missing some data.
See the properties they include here.
Use YouTube.getVideo(playlist.videos)
to fetch the full objects while not spamming your quota
like you would using a loop.
Parameters
Name | Type | Description |
---|---|---|
pageOptions? | PageOptions | The number of pages and maximum number of items per page. Fetches the maximum number of items allowed by the API per page by default. Set pages to a value <=0 to fetch all. |
parts? | PlaylistItemParts | The parts of the object to fetch (saves quota if you aren't using certain properties!) |
Returns
Promise
<PaginatedResponse
<Video
>>
Defined in
removeItem
▸ removeItem(playlistItemId
): Promise
<void
>
Removes a Video from the playlist. Must be using an access token with correct scopes.
Parameters
Name | Type | Description |
---|---|---|
playlistItemId | string | The playlist item ID (not the same as video ID; see Playlist.removeVideo() ). |
Returns
Promise
<void
>
Defined in
removeVideo
▸ removeVideo(videoResolvable
): Promise
<void
>
Removes a Video from the playlist. Must be using an access token with correct scopes.
Parameters
Name | Type | Description |
---|---|---|
videoResolvable | VideoResolvable | The URL, ID, or (not recommended) search query of the video. |
Returns
Promise
<void
>
Defined in
update
▸ update(title
, description?
, privacy?
, tags?
, language?
, localizations?
): Promise
<Playlist
>
Edits the playlist.
Must be using an access token with correct scopes.
If your request does not specify a value for a property that already has a value,
the property's existing value will be deleted.
Parameters
Name | Type | Description |
---|---|---|
title | string | A title for the playlist. |
description? | string | A description of the playlist. |
privacy? | "private" | "public" | "unlisted" | Whether the video is private, public, or unlisted. |
tags? | string [] | Tags pertaining to the playlist. |
language? | string | The language of the playlist's default title and description. |
localizations? | Object | Translated titles and descriptions. |
Returns
Promise
<Playlist
>
Defined in
updateVideo
▸ updateVideo(videoResolvable
, position?
, note?
, itemId?
): Promise
<Video
>
Updates a Video in the playlist. Must be using an access token with correct scopes.
Parameters
Name | Type | Description |
---|---|---|
videoResolvable | VideoResolvable | The URL, ID, or (not recommended) search query of the video. |
position? | number | The zero-based position to move the video to. |
note? | string | A new note on the video. |
itemId? | string | The playlist item ID if you have it. |
Returns
Promise
<Video
>