Skip to main content

Playlist

popyt


popyt / Library Exports / Playlist

Class: Playlist

Defined in: entities/playlist.ts:9

A YouTube playlist.

Constructors​

Constructor​

new Playlist(youtube, data, full?): Playlist

Defined in: entities/playlist.ts:114

Parameters​

youtube​

YouTube

data​

Schema$SearchResult | Schema$Playlist

full?​

boolean = false

Returns​

Playlist

Properties​

creatorId​

creatorId: string

Defined in: entities/playlist.ts:71

The ID of the creator of the playlist.


data​

data: any

Defined in: entities/playlist.ts:37

The raw data of this playlist.


dateCreated​

dateCreated: Date

Defined in: entities/playlist.ts:81

The date the playlist was created.


description​

description: string

Defined in: entities/playlist.ts:57

The description of the playlist.


embedHtml​

embedHtml: string

Defined in: entities/playlist.ts:102

An <iframe> tag that embeds a player that will play the playlist.


full​

full: boolean

Defined in: entities/playlist.ts:42

Whether or not this is a full playlist object.


id​

id: string

Defined in: entities/playlist.ts:47

The ID of this playlist.


length​

length: number

Defined in: entities/playlist.ts:97

The number of items in the playlist.


privacy​

privacy: "private" | "public" | "unlisted"

Defined in: entities/playlist.ts:112

Information on this playlist's privacy.


tags​

tags: string[]

Defined in: entities/playlist.ts:107

The tags of the playlist.


thumbnails​

thumbnails: object

Defined in: entities/playlist.ts:86

The thumbnails for the playlist.

default?​

optional default?: Thumbnail

high?​

optional high?: Thumbnail

maxres?​

optional maxres?: Thumbnail

medium?​

optional medium?: Thumbnail

standard?​

optional standard?: Thumbnail


title​

title: string

Defined in: entities/playlist.ts:52

The title of the playlist.


url​

url: string

Defined in: entities/playlist.ts:76

The url of the playlist.


videos​

videos: PaginatedResponse<Video>

Defined in: entities/playlist.ts:66

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.


youtube​

youtube: YouTube

Defined in: entities/playlist.ts:32

The YouTube object that created this playlist.


endpoint​

static endpoint: string = 'playlists'

Defined in: entities/playlist.ts:13

The name of the endpoint used for this entity.


fields​

static fields: string

Defined in: entities/playlist.ts:23

The fields to request for this entity.


part​

static part: string = 'contentDetails,player,snippet,status'

Defined in: entities/playlist.ts:18

The parts to request for this entity.

Methods​

addVideo()​

addVideo(videoResolvable, position?, note?): Promise<Video>

Defined in: entities/playlist.ts:204

Adds a Video to the playlist. Must be using an access token with correct scopes.

Parameters​

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>


delete()​

delete(): Promise<void>

Defined in: entities/playlist.ts:283

Deletes the playlist. Must be using an access token with correct scopes.

Returns​

Promise<void>


fetch()​

fetch(parts?): Promise<Playlist>

Defined in: entities/playlist.ts:173

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​

parts?​

PlaylistParts

Returns​

Promise<Playlist>


fetchVideos()​

fetchVideos(pageOptions?, parts?): Promise<PaginatedResponse<Video>>

Defined in: entities/playlist.ts:164

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​

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>>


removeItem()​

removeItem(playlistItemId): Promise<void>

Defined in: entities/playlist.ts:267

Removes a Video from the playlist. Must be using an access token with correct scopes.

Parameters​

playlistItemId​

string

The playlist item ID (not the same as video ID; see Playlist.removeVideo()).

Returns​

Promise<void>


removeVideo()​

removeVideo(videoResolvable): Promise<void>

Defined in: entities/playlist.ts:243

Removes a Video from the playlist. Must be using an access token with correct scopes.

Parameters​

videoResolvable​

VideoResolvable

The URL, ID, or (not recommended) search query of the video.

Returns​

Promise<void>


update()​

update(title, description?, privacy?, tags?, language?, localizations?): Promise<Playlist>

Defined in: entities/playlist.ts:190

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​

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?​

Translated titles and descriptions.

Returns​

Promise<Playlist>


updateVideo()​

updateVideo(videoResolvable, position?, note?, itemId?): Promise<Video>

Defined in: entities/playlist.ts:223

Updates a Video in the playlist. Must be using an access token with correct scopes.

Parameters​

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>