Skip to main content

Documentation

Library Exports.Video

A YouTube video.

Constructors

constructor

new Video(youtube, data, full?)

Parameters

NameTypeDefault value
youtubeYouTubeundefined
dataSchema$Video | Schema$PlaylistItem | Schema$SearchResultundefined
fullbooleanfalse

Defined in

entities/video.ts:201

Properties

captions

captions: Caption[]

The caption data associated with this video. Only available after running Video.fetchCaptions.

Defined in

entities/video.ts:184


category

category: string

The video category associated with the video.

Defined in

entities/video.ts:164


channel

channel: Object

Information on the channel that uploaded the video.

Type declaration

NameType
idstring
namestring

Defined in

entities/video.ts:90


commentCount

commentCount: number

The number of comments on the video.

Defined in

entities/video.ts:152


comments

comments: PaginatedResponse\<Comment>

The video's comments. Only defined when Video.fetchComments is called.

Defined in

entities/video.ts:147


data

data: any

The raw data of the video.

Defined in

entities/video.ts:39


datePublished

datePublished: Date

The date the video was published.

Defined in

entities/video.ts:80


dateRecorded

dateRecorded: Date

The date the video was recorded. This is specified by the uploader.

Defined in

entities/video.ts:85


description

description: string

The description of the video.

Defined in

entities/video.ts:59


dislikes

dislikes: number

The number of dislikes the video has.

Defined in

entities/video.ts:128


full

full: boolean

Whether or not this is a full video object (would it be the same if we ran Video.fetch under the same conditions as last time?).

Defined in

entities/video.ts:44


id

id: string

The ID of the video.

Defined in

entities/video.ts:49


kids

kids: Object

Properties to do with videos made for children.

Type declaration

NameTypeDescription
madeForKidsbooleanWhether or not the video was made for children.
selfDeclaredMadeForKidsbooleanWhether or not the poster of the video marked it as made for kids.

Defined in

entities/video.ts:169


license

license: "creativeCommon" | "youtube"

The license this video falls under.

Defined in

entities/video.ts:194


likes

likes: number

The number of likes the video has.

Defined in

entities/video.ts:123


liveStatus

liveStatus: false | "live" | "upcoming"

If this is a ongoing livestream, this is live. If this is an upcoming livestream, this is upcoming. If this is not a livestream, this is false.

Defined in

entities/video.ts:159


localizations

localizations: Object

The localized titles and descriptions of this video, if any.

Index signature

[language: string]: { description?: string ; title?: string }

Defined in

entities/video.ts:199


minutes

minutes: number

The minutes of the video.

Defined in

entities/video.ts:103


note

note: string

If this video was fetched from a playlist, this can be populated with a user-created note about the video.

Defined in

entities/video.ts:189


private

private: boolean

Whether or not this video COULD BE private. True if the video might be private, as you cannot check if playlist items are private.

I would recommend that you try and fetch the video and catch an error if it is from a playlist & marked as private.

Defined in

entities/video.ts:142


seconds

seconds: number

The seconds of the video.

Defined in

entities/video.ts:108


shortUrl

shortUrl: string

The short url of the video, i.e. https://youtu.be/id

Defined in

entities/video.ts:118


tags

tags: string[]

The tags of the video.

Defined in

entities/video.ts:75


thumbnails

thumbnails: Object

The thumbnails of the video.

Type declaration

NameType
default?Thumbnail
high?Thumbnail
maxres?Thumbnail
medium?Thumbnail
standard?Thumbnail

Defined in

entities/video.ts:64


title

title: string

The title of the video.

Defined in

entities/video.ts:54


url

url: string

The url of the video.

Defined in

entities/video.ts:113


views

views: number

The number of views the video has.

Defined in

entities/video.ts:133


youtube

youtube: YouTube

YouTube object that created the video.

Defined in

entities/video.ts:34


endpoint

Static endpoint: string = 'videos'

The name of the endpoint used for this entity.

Defined in

entities/video.ts:15


fields

Static fields: string

The fields to request for this entity.

Defined in

entities/video.ts:26


part

Static part: string = 'contentDetails,localizations,recordingDetails,snippet,statistics,status'

The parts to request for this entity.

Defined in

entities/video.ts:20

Methods

delete

delete(): Promise\<void>

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

Returns

Promise\<void>

Defined in

entities/video.ts:381


dislike

dislike(): Promise\<void>

Dislikes the video. Must be using an access token with correct scopes.

Returns

Promise\<void>

Defined in

entities/video.ts:353


fetch

fetch(parts?): Promise\<Video>

Fetches this video from the API and reassigns this object to the new video object. Only useful if this.full is false, or if you want updated video info.

Parameters

NameType
parts?VideoParts

Returns

Promise\<Video>

Defined in

entities/video.ts:315


fetchCaptions

fetchCaptions(): Promise\<Caption[]>

Fetches the captions for the video from the API. Must be using an access token with correct scopes.

Returns

Promise\<Caption[]>

Defined in

entities/video.ts:411


fetchComments

fetchComments(pageOptions?, order?, parts?): Promise\<PaginatedResponse\<Comment>>

Fetches the video's comments from the API and assigns them to Video.comments.

Parameters

NameTypeDescription
pageOptions?PageOptionsThe 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.
order?"time" | "relevance"-
parts?CommentThreadPartsThe parts of the object to fetch (saves quota if you aren't using certain properties!)

Returns

Promise\<PaginatedResponse\<Comment>>

Defined in

entities/video.ts:327


getRating

getRating(): Promise\<"none" | "like" | "dislike" | "unspecified">

Gets the user's rating on the video. Must be using an access token with correct scopes.

Returns

Promise\<"none" | "like" | "dislike" | "unspecified">

Defined in

entities/video.ts:336


like

like(): Promise\<void>

Likes the video. Must be using an access token with correct scopes.

Returns

Promise\<void>

Defined in

entities/video.ts:345


postComment

postComment(text): Promise\<Comment>

Posts a comment to the video. Must be using an access token with correct scopes.

Parameters

NameTypeDescription
textstringThe text of the comment.

Returns

Promise\<Comment>

Defined in

entities/video.ts:302


reportAbuse

reportAbuse(reasonId, secondaryReasonId?, comments?, language?): Promise\<void>

Reports the video for abuse. Must be using an access token with correct scopes.

Parameters

NameTypeDescription
reasonIdstringThe reason for reporting. (IDs can be found here)
secondaryReasonId?stringAn optional second reason for reporting.
comments?stringAny additional information.
language?stringThe language that the reporter speaks.

Returns

Promise\<void>

Defined in

entities/video.ts:373


setThumbnail

setThumbnail(image): Promise\<{ default?: Thumbnail ; high?: Thumbnail ; maxres?: Thumbnail ; medium?: Thumbnail ; standard?: Thumbnail }>

Sets a new thumbnail for a video. Must be using an access token with correct scopes.

Parameters

NameTypeDescription
imageObjectThe image data and type to upload.
image.dataBuffer-
image.type"jpeg" | "png"-

Returns

Promise\<{ default?: Thumbnail ; high?: Thumbnail ; maxres?: Thumbnail ; medium?: Thumbnail ; standard?: Thumbnail }>

Defined in

entities/video.ts:402


unrate

unrate(): Promise\<void>

Removes the user's like/dislike on the video. Must be using an access token with correct scopes.

Returns

Promise\<void>

Defined in

entities/video.ts:361


update

update(video): Promise\<Video>

Edits the video. 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

NameTypeDescription
videoOmit\<VideoUpdateResource, "id">The updated video object.

Returns

Promise\<Video>

Defined in

entities/video.ts:392


uploadCaption

uploadCaption(language, name, track, draft?): Promise\<Caption>

Uploads a caption track for a video. Must be using an access token with correct scopes.

Parameters

NameTypeDefault valueDescription
languagestringundefinedThe language of the track.
namestringundefinedThe name of the track.
trackBufferundefinedThe caption track to upload.
draftbooleanfalseWhether or not the track is a draft.

Returns

Promise\<Caption>

Defined in

entities/video.ts:424