Video
popyt / Library Exports / Video
Class: Video
Defined in: entities/video.ts:11
A YouTube video.
Constructors
Constructor
new Video(
youtube,data,full?):Video
Defined in: entities/video.ts:201
Parameters
youtube
data
Schema$Video | Schema$PlaylistItem | Schema$SearchResult
full?
boolean = false
Returns
Video
Properties
captions
captions:
Caption[]
Defined in: entities/video.ts:184
The caption data associated with this video. Only available after running Video.fetchCaptions.
category
category:
string
Defined in: entities/video.ts:164
The video category associated with the video.
channel
channel:
object
Defined in: entities/video.ts:90
Information on the channel that uploaded the video.
id
id:
string
name
name:
string
commentCount
commentCount:
number
Defined in: entities/video.ts:152
The number of comments on the video.
comments
comments:
PaginatedResponse<Comment>
Defined in: entities/video.ts:147
The video's comments. Only defined when Video.fetchComments is called.
data
data:
any
Defined in: entities/video.ts:39
The raw data of the video.
datePublished
datePublished:
Date
Defined in: entities/video.ts:80
The date the video was published.
dateRecorded
dateRecorded:
Date
Defined in: entities/video.ts:85
The date the video was recorded. This is specified by the uploader.
description
description:
string
Defined in: entities/video.ts:59
The description of the video.
dislikes
dislikes:
number
Defined in: entities/video.ts:128
The number of dislikes the video has.
full
full:
boolean
Defined in: entities/video.ts:44
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?).
id
id:
string
Defined in: entities/video.ts:49
The ID of the video.
kids
kids:
object
Defined in: entities/video.ts:169
Properties to do with videos made for children.
madeForKids
madeForKids:
boolean
Whether or not the video was made for children.
selfDeclaredMadeForKids
selfDeclaredMadeForKids:
boolean
Whether or not the poster of the video marked it as made for kids.
license
license:
"creativeCommon"|"youtube"
Defined in: entities/video.ts:194
The license this video falls under.
likes
likes:
number
Defined in: entities/video.ts:123
The number of likes the video has.
liveStatus
liveStatus:
false|"live"|"upcoming"
Defined in: entities/video.ts:159
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.
localizations
localizations:
object
Defined in: entities/video.ts:199
The localized titles and descriptions of this video, if any.
Index Signature
[language: string]: object
minutes
minutes:
number
Defined in: entities/video.ts:103
The minutes of the video.
note
note:
string
Defined in: entities/video.ts:189
If this video was fetched from a playlist, this can be populated with a user-created note about the video.
private
private:
boolean
Defined in: entities/video.ts:142
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.
seconds
seconds:
number
Defined in: entities/video.ts:108
The seconds of the video.
shortUrl
shortUrl:
string
Defined in: entities/video.ts:118
The short url of the video, i.e. https://youtu.be/id
tags
tags:
string[]
Defined in: entities/video.ts:75
The tags of the video.
thumbnails
thumbnails:
object
Defined in: entities/video.ts:64
The thumbnails of the video.
default?
optionaldefault?:Thumbnail
high?
optionalhigh?:Thumbnail
maxres?
optionalmaxres?:Thumbnail
medium?
optionalmedium?:Thumbnail
standard?
optionalstandard?:Thumbnail
title
title:
string
Defined in: entities/video.ts:54
The title of the video.
url
url:
string
Defined in: entities/video.ts:113
The url of the video.
views
views:
number
Defined in: entities/video.ts:133
The number of views the video has.
youtube
youtube:
YouTube
Defined in: entities/video.ts:34
YouTube object that created the video.
endpoint
staticendpoint:string='videos'
Defined in: entities/video.ts:15
The name of the endpoint used for this entity.
fields
staticfields:string
Defined in: entities/video.ts:26
The fields to request for this entity.
part
staticpart:string='contentDetails,localizations,recordingDetails,snippet,statistics,status'
Defined in: entities/video.ts:20
The parts to request for this entity.
Methods
delete()
delete():
Promise<void>
Defined in: entities/video.ts:381
Deletes the video. Must be using an access token with correct scopes.
Returns
Promise<void>
dislike()
dislike():
Promise<void>
Defined in: entities/video.ts:353
Dislikes the video. Must be using an access token with correct scopes.
Returns
Promise<void>
fetch()
fetch(
parts?):Promise<Video>
Defined in: entities/video.ts:315
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
parts?
Returns
Promise<Video>
fetchCaptions()
fetchCaptions():
Promise<Caption[]>
Defined in: entities/video.ts:411
Fetches the captions for the video from the API. Must be using an access token with correct scopes.
Returns
Promise<Caption[]>
fetchComments()
fetchComments(
pageOptions?,order?,parts?):Promise<PaginatedResponse<Comment>>
Defined in: entities/video.ts:327
Fetches the video's comments from the API and assigns them to Video.comments.
Parameters
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?
"relevance" | "time"
parts?
The parts of the object to fetch (saves quota if you aren't using certain properties!)
Returns
Promise<PaginatedResponse<Comment>>
getRating()
getRating():
Promise<"none"|"like"|"dislike"|"unspecified">
Defined in: entities/video.ts:336
Gets the user's rating on the video. Must be using an access token with correct scopes.
Returns
Promise<"none" | "like" | "dislike" | "unspecified">
like()
like():
Promise<void>
Defined in: entities/video.ts:345
Likes the video. Must be using an access token with correct scopes.
Returns
Promise<void>
postComment()
postComment(
text):Promise<Comment>
Defined in: entities/video.ts:302
Posts a comment to the video. Must be using an access token with correct scopes.
Parameters
text
string
The text of the comment.
Returns
Promise<Comment>
reportAbuse()
reportAbuse(
reasonId,secondaryReasonId?,comments?,language?):Promise<void>
Defined in: entities/video.ts:373
Reports the video for abuse. Must be using an access token with correct scopes.
Parameters
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>
setThumbnail()
setThumbnail(
image):Promise<{default?:Thumbnail;high?:Thumbnail;maxres?:Thumbnail;medium?:Thumbnail;standard?:Thumbnail; }>
Defined in: entities/video.ts:402
Sets a new thumbnail for a video. Must be using an access token with correct scopes.
Parameters
image
The image data and type to upload.
data
Buffer
type
"jpeg" | "png"
Returns
Promise<{ default?: Thumbnail; high?: Thumbnail; maxres?: Thumbnail; medium?: Thumbnail; standard?: Thumbnail; }>
unrate()
unrate():
Promise<void>
Defined in: entities/video.ts:361
Removes the user's like/dislike on the video. Must be using an access token with correct scopes.
Returns
Promise<void>
update()
update(
video):Promise<Video>
Defined in: entities/video.ts:392
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
video
Omit<VideoUpdateResource, "id">
The updated video object.
Returns
Promise<Video>
uploadCaption()
uploadCaption(
language,name,track,draft?):Promise<Caption>
Defined in: entities/video.ts:424
Uploads a caption track for a video. Must be using an access token with correct scopes.
Parameters
language
string
The language of the track.
name
string
The name of the track.
track
Buffer
The caption track to upload.
draft?
boolean = false
Whether or not the track is a draft.
Returns
Promise<Caption>