Documentation
Library Exports.Caption
A caption track.
Constructors
constructor
• new Caption(youtube
, data
, full?
)
Parameters
Name | Type | Default value |
---|---|---|
youtube | YouTube | undefined |
data | any | undefined |
full | boolean | true |
Defined in
Properties
audioType
• audioType: "unknown"
| "commentary"
| "descriptive"
| "primary"
Whether the audio is a commentary/descriptive (alternate audio tracks), the primary audio track, or unknown.
Defined in
autoSynced
• autoSynced: boolean
Whether or not this caption track has been autosynced to the audio by YouTube.
Defined in
closedCaptions
• closedCaptions: boolean
Whether or not this caption track is for the deaf/hard of hearing.
Defined in
data
• data: any
The raw data of this caption track.
Defined in
draft
• draft: boolean
Whether or not this caption track is a draft. If so, it won't be shown to users.
Defined in
easyReader
• easyReader: boolean
Whether or not this caption track is written at a third-grade level (for language learners).
Defined in
failureReason
• Optional
failureReason: "processingFailed"
| "unknownFormat"
| "unsupportedFormat"
If Caption.status is failed
, then this is populated with the reason failure.
Defined in
full
• full: boolean
= true
Whether or not this is a full caption track object.
Defined in
id
• id: string
The ID of this caption track.
Defined in
kind
• kind: "standard"
| "ASR"
| "forced"
The kind of caption track this is (automatic speech recognition, forced due to foreign language, or standard).
Defined in
language
• language: string
The language that this caption track is written in.
Defined in
large
• large: boolean
Whether or not this caption track uses large text for the vision-impaired.
Defined in
lastUpdated
• lastUpdated: Date
When this caption track was last updated.
Defined in
name
• name: string
The name of this caption track.
Defined in
status
• status: "failed"
| "serving"
| "syncing"
The processing status of the caption track.
Defined in
videoId
• videoId: string
The ID of the Video that this caption track is for.
Defined in
youtube
• youtube: YouTube
The YouTube object that created this caption track object.
Defined in
endpoint
▪ Static
endpoint: string
= 'i18nRegions'
The name of the endpoint used for this entity.
Defined in
fields
▪ Static
fields: string
= 'items(kind,id,snippet)'
The fields to request for this entity.
Defined in
part
▪ Static
part: string
= 'snippet'
The parts to request for this entity.
Defined in
Methods
delete
▸ delete(): Promise
<void
>
Deletes the caption. Must be using an access token with correct scopes.
Returns
Promise
<void
>
Defined in
download
▸ download(format?
, language?
): Promise
<Buffer
>
Downloads this caption's track. Must be using an access token with correct scopes.
Parameters
Name | Type | Description |
---|---|---|
format? | "sbv" | "scc" | "srt" | "ttml" | "vtt" | The file format to download the track in. |
language? | string | The language to download the track in. |
Returns
Promise
<Buffer
>
Defined in
fetch
▸ fetch(): Promise
<Caption
>
Fetches this caption from the API and reassigns this object to the new caption object.
Only useful if this.full
is false, or if you want updated caption info.
Must be using an access token with correct scopes.
Returns
Promise
<Caption
>
Defined in
update
▸ update(track?
, draft?
): Promise
<Caption
>
Updates this caption. 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
>