Documentation
Library Exports.Video
A YouTube video.
Constructors
constructor
• new Video(youtube
, data
, full?
)
Parameters
Name | Type | Default value |
---|---|---|
youtube | YouTube | undefined |
data | any | undefined |
full | boolean | false |
Defined in
Properties
captions
• captions: Caption
[]
The caption data associated with this video. Only available after running Video.fetchCaptions.
Defined in
category
• category: string
The video category associated with the video.
Defined in
channel
• channel: Object
Information on the channel that uploaded the video.
Type declaration
Name | Type |
---|---|
id | string |
name | string |
Defined in
commentCount
• commentCount: number
The number of comments on the video.
Defined in
comments
• comments: PaginatedResponse
<Comment
>
The video's comments. Only defined when Video.fetchComments is called.
Defined in
data
• data: any
The raw data of the video.
Defined in
datePublished
• datePublished: Date
The date the video was published.
Defined in
description
• description: string
The description of the video.
Defined in
dislikes
• dislikes: number
The number of dislikes the video has.
Defined in
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
id
• id: string
The ID of the video.
Defined in
kids
• kids: Object
Properties to do with videos made for children.
Type declaration
Name | Type | Description |
---|---|---|
madeForKids | boolean | Whether or not the video was made for children. |
selfDeclaredMadeForKids | boolean | Whether or not the poster of the video marked it as made for kids. |
Defined in
likes
• likes: number
The number of likes the video has.
Defined in
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
minutes
• minutes: number
The minutes of the video.
Defined in
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
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
seconds
• seconds: number
The seconds of the video.
Defined in
shortUrl
• shortUrl: string
The short url of the video, i.e. https://youtu.be/id
Defined in
tags
• tags: string
[]
The tags of the video.
Defined in
thumbnails
• thumbnails: Object
The thumbnails of the video.
Type declaration
Name | Type |
---|---|
default? | Thumbnail |
high? | Thumbnail |
maxres? | Thumbnail |
medium? | Thumbnail |
standard? | Thumbnail |
Defined in
title
• title: string
The title of the video.
Defined in
url
• url: string
The url of the video.
Defined in
views
• views: number
The number of views the video has.
Defined in
youtube
• youtube: YouTube
YouTube object that created the video.
Defined in
endpoint
▪ Static
endpoint: string
= 'videos'
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,statistics,status'
The parts to request for this entity.
Defined in
Methods
delete
▸ delete(): Promise
<void
>
Deletes the video. Must be using an access token with correct scopes.
Returns
Promise
<void
>
Defined in
dislike
▸ dislike(): Promise
<void
>
Dislikes the video. Must be using an access token with correct scopes.
Returns
Promise
<void
>
Defined in
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
Name | Type |
---|---|
parts? | VideoParts |
Returns
Promise
<Video
>
Defined in
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
fetchComments
▸ fetchComments(pageOptions?
, order?
, parts?
): Promise
<PaginatedResponse
<Comment
>>
Fetches the video's comments from the API and assigns them to Video.comments.
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. |
order? | "time" | "relevance" | - |
parts? | CommentThreadParts | The parts of the object to fetch (saves quota if you aren't using certain properties!) |
Returns
Promise
<PaginatedResponse
<Comment
>>
Defined in
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
like
▸ like(): Promise
<void
>
Likes the video. Must be using an access token with correct scopes.
Returns
Promise
<void
>
Defined in
postComment
▸ postComment(text
): Promise
<Comment
>
Posts a comment to the video. Must be using an access token with correct scopes.
Parameters
Name | Type | Description |
---|---|---|
text | string | The text of the comment. |
Returns
Promise
<Comment
>
Defined in
reportAbuse
▸ reportAbuse(reasonId
, secondaryReasonId?
, comments?
, language?
): Promise
<void
>
Reports the video for abuse. Must be using an access token with correct scopes.
Parameters
Name | Type | Description |
---|---|---|
reasonId | string | The reason for reporting. (IDs can be found here) |
secondaryReasonId? | string | An optional second reason for reporting. |
comments? | string | Any additional information. |
language? | string | The language that the reporter speaks. |
Returns
Promise
<void
>
Defined in
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
Name | Type | Description |
---|---|---|
image | Object | The image data and type to upload. |
image.data | Buffer | - |
image.type | "jpeg" | "png" | - |
Returns
Promise
<{ default?
: Thumbnail
; high?
: Thumbnail
; maxres?
: Thumbnail
; medium?
: Thumbnail
; standard?
: Thumbnail
}>
Defined in
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
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
Name | Type | Description |
---|---|---|
video | VideoUpdateResource | The updated video object. |
Returns
Promise
<Video
>
Defined in
updateCaption
▸ updateCaption(track
, draft?
): Promise
<Caption
>
Updates a caption track of a video. Must be using an access token with correct scopes.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
track | Buffer | undefined | The modified caption track to upload. |
draft | boolean | null | Whether or not the track is a draft. |
Returns
Promise
<Caption
>
Defined in
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
Name | Type | Default value | Description |
---|---|---|---|
language | string | undefined | The language of the track. |
name | string | undefined | The name of the track. |
track | Buffer | undefined | The caption track to upload. |
draft | boolean | false | Whether or not the track is a draft. |
Returns
Promise
<Caption
>