Skip to main content

Caption

popyt


popyt / Library Exports / Caption

Class: Caption

Defined in: entities/caption.ts:7

A caption track.

Constructors

Constructor

new Caption(youtube, data, full?): Caption

Defined in: entities/caption.ts:109

Parameters

youtube

YouTube

data

Schema$Caption

full?

boolean = true

Returns

Caption

Properties

audioType

audioType: "commentary" | "descriptive" | "primary" | "unknown"

Defined in: entities/caption.ts:71

Whether the audio is a commentary/descriptive (alternate audio tracks), the primary audio track, or unknown.


autoSynced

autoSynced: boolean

Defined in: entities/caption.ts:96

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


closedCaptions

closedCaptions: boolean

Defined in: entities/caption.ts:76

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


data

data: any

Defined in: entities/caption.ts:36

The raw data of this caption track.


draft

draft: boolean

Defined in: entities/caption.ts:91

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


easyReader

easyReader: boolean

Defined in: entities/caption.ts:86

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


failureReason?

optional failureReason?: "processingFailed" | "unknownFormat" | "unsupportedFormat"

Defined in: entities/caption.ts:107

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


full

full: boolean = true

Defined in: entities/caption.ts:31

Whether or not this is a full caption track object.


id

id: string

Defined in: entities/caption.ts:41

The ID of this caption track.


kind

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

Defined in: entities/caption.ts:56

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


language

language: string

Defined in: entities/caption.ts:61

The language that this caption track is written in.


large

large: boolean

Defined in: entities/caption.ts:81

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


lastUpdated

lastUpdated: Date

Defined in: entities/caption.ts:51

When this caption track was last updated.


name

name: string

Defined in: entities/caption.ts:66

The name of this caption track.


status

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

Defined in: entities/caption.ts:101

The processing status of the caption track.


videoId

videoId: string

Defined in: entities/caption.ts:46

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


youtube

youtube: YouTube

Defined in: entities/caption.ts:26

The YouTube object that created this caption track object.


endpoint

static endpoint: string = 'i18nRegions'

Defined in: entities/caption.ts:11

The name of the endpoint used for this entity.


fields

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

Defined in: entities/caption.ts:21

The fields to request for this entity.


part

static part: string = 'snippet'

Defined in: entities/caption.ts:16

The parts to request for this entity.

Methods

delete()

delete(): Promise<void>

Defined in: entities/caption.ts:180

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

Returns

Promise<void>


download()

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

Defined in: entities/caption.ts:172

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

Parameters

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<ArrayBufferLike>>


fetch()

fetch(): Promise<Caption>

Defined in: entities/caption.ts:150

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>


update()

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

Defined in: entities/caption.ts:161

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

Parameters

track?

Buffer

The modified caption track to upload.

draft?

boolean = null

Whether or not the track is a draft.

Returns

Promise<Caption>