Skip to main content

Documentation

Library Exports.Caption

A caption track.

Constructors

constructor

new Caption(youtube, data, full?)

Parameters

NameTypeDefault value
youtubeYouTubeundefined
dataanyundefined
fullbooleantrue

Defined in

entities/caption.ts:108

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

entities/caption.ts:70


autoSynced

autoSynced: boolean

Whether or not this caption track has been autosynced to the audio by YouTube.

Defined in

entities/caption.ts:95


closedCaptions

closedCaptions: boolean

Whether or not this caption track is for the deaf/hard of hearing.

Defined in

entities/caption.ts:75


data

data: any

The raw data of this caption track.

Defined in

entities/caption.ts:35


draft

draft: boolean

Whether or not this caption track is a draft. If so, it won't be shown to users.

Defined in

entities/caption.ts:90


easyReader

easyReader: boolean

Whether or not this caption track is written at a third-grade level (for language learners).

Defined in

entities/caption.ts:85


failureReason

Optional failureReason: "processingFailed" | "unknownFormat" | "unsupportedFormat"

If Caption.status is failed, then this is populated with the reason failure.

Defined in

entities/caption.ts:106


full

full: boolean = true

Whether or not this is a full caption track object.

Defined in

entities/caption.ts:30


id

id: string

The ID of this caption track.

Defined in

entities/caption.ts:40


kind

kind: "standard" | "ASR" | "forced"

The kind of caption track this is (automatic speech recognition, forced due to foreign language, or standard).

Defined in

entities/caption.ts:55


language

language: string

The language that this caption track is written in.

Defined in

entities/caption.ts:60


large

large: boolean

Whether or not this caption track uses large text for the vision-impaired.

Defined in

entities/caption.ts:80


lastUpdated

lastUpdated: Date

When this caption track was last updated.

Defined in

entities/caption.ts:50


name

name: string

The name of this caption track.

Defined in

entities/caption.ts:65


status

status: "failed" | "serving" | "syncing"

The processing status of the caption track.

Defined in

entities/caption.ts:100


videoId

videoId: string

The ID of the Video that this caption track is for.

Defined in

entities/caption.ts:45


youtube

youtube: YouTube

The YouTube object that created this caption track object.

Defined in

entities/caption.ts:25


endpoint

Static endpoint: string = 'i18nRegions'

The name of the endpoint used for this entity.

Defined in

entities/caption.ts:10


fields

Static fields: string = 'items(kind,id,snippet)'

The fields to request for this entity.

Defined in

entities/caption.ts:20


part

Static part: string = 'snippet'

The parts to request for this entity.

Defined in

entities/caption.ts:15

Methods

delete

delete(): Promise<void>

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

Returns

Promise<void>

Defined in

entities/caption.ts:179


download

download(format?, language?): Promise<Buffer>

Downloads this caption's track. Must be using an access token with correct scopes.

Parameters

NameTypeDescription
format?"sbv" | "scc" | "srt" | "ttml" | "vtt"The file format to download the track in.
language?stringThe language to download the track in.

Returns

Promise<Buffer>

Defined in

entities/caption.ts:171


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

entities/caption.ts:149


update

update(track?, draft?): Promise<Caption>

Updates this caption. Must be using an access token with correct scopes.

Parameters

NameTypeDefault valueDescription
track?BufferundefinedThe modified caption track to upload.
draftbooleannullWhether or not the track is a draft.

Returns

Promise<Caption>

Defined in

entities/caption.ts:160