youtubetranscript

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

youtubetranscript-go

Go client for the YouTubeTranscript.net API: transcripts with timestamps, your transcript library, and batches. Standard library only, Go 1.22 or newer.

Install

go get github.com/youtube-transcript/youtubetranscript-go

Create an API key at https://youtubetranscript.net/account/api-keys. Requests spend the same credits as the website.

Quick start

package main

import (
	"context"
	"fmt"
	"log"

	yt "github.com/youtube-transcript/youtubetranscript-go"
)

func main() {
	client, err := yt.NewClient() // reads YTT_API_KEY
	if err != nil {
		log.Fatal(err)
	}

	res, err := client.Transcripts.Get(context.Background(), "https://youtu.be/jNQXAC9IVRw", nil)
	if err != nil {
		log.Fatal(err)
	}
	for _, seg := range res.Transcript.Segments {
		fmt.Printf("[%.1fs] %s\n", seg.Start, seg.Text)
	}
}

video accepts a watch link, a youtu.be link, a Shorts link or an 11-character video id. The SDK passes it to the server unchanged.

Client

client, err := yt.NewClient(
	yt.WithAPIKey("ytt_..."),               // default: $YTT_API_KEY
	yt.WithBaseURL("http://127.0.0.1:3461"), // default: $YTT_BASE_URL, then https://api.youtubetranscript.net
	yt.WithTimeout(30*time.Second),          // per HTTP request, default 60s
	yt.WithMaxRetries(2),                    // default 2, 0 disables retries
	yt.WithHTTPClient(myHTTPClient),         // proxies, custom transports
)

Without a key (neither WithAPIKey nor YTT_API_KEY) NewClient returns an *Error with code API_KEY_REQUIRED and sends nothing.

Every method takes a context.Context first. Optional parameters go in an options struct pointer; pass nil for the defaults. Optional booleans and integers are pointers: use yt.Bool(true) and yt.Int(0).

Methods

client.Transcripts
Method Request Returns
Get(ctx, video, *GetOptions) POST /v1/transcript, then polls GET /v1/transcript/job/{id} on 202 *TranscriptResult
Submit(ctx, video, *SubmitOptions) POST /v1/transcript, once *TranscriptResult (finished, or a job with JobID)
Job(ctx, jobID) GET /v1/transcript/job/{id} *TranscriptResult
Info(ctx, video) GET /v1/transcript/info (free) *VideoInfo
List(ctx, *ListOptions) GET /v1/library/transcripts *TranscriptList
Download(ctx, videoID, *DownloadOptions) GET /v1/library/transcripts/youtube/{id}/download string
Delete(ctx, videoID, *DeleteOptions) DELETE /v1/library/transcripts/youtube/{id} *Removed
res, err := client.Transcripts.Get(ctx, "jNQXAC9IVRw", &yt.GetOptions{
	Language:         "en",            // priority list: "en,auto", "asr", "asr-de"; default "auto"
	Format:           "json",          // or "text"
	IncludeTimestamp: yt.Bool(true),
	SendMetadata:     yt.Bool(true),
	ConfirmCredits:   yt.Bool(true),   // accept videos that cost more than 10 credits
	Timeout:          5 * time.Minute, // whole call including polling, default 300s
	PollInterval:     2 * time.Second, // default 2s
})

Get sends waitMs: 10000, so most videos return in the first response. A 202 is followed by polling every PollInterval until the job succeeds. A failed job returns an *Error whose Code is the job's error.code (or TRANSCRIPT_FAILED); running past Timeout returns code TIMEOUT with the JobID. A 429 while polling waits for Retry-After and continues.

Submit never polls. Use it to start a job yourself:

job, err := client.Transcripts.Submit(ctx, "jNQXAC9IVRw", &yt.SubmitOptions{WaitMs: yt.Int(0)})
// job.Status is "pending"/"processing" (job.JobID) or "success"
final, err := client.Transcripts.Job(ctx, job.JobID)

TranscriptResult fields: Status, JobID, Language, Format, Cached, LengthSeconds, LengthText, Transcript (Platform, ExternalID, Lang, Origin, Title, Channel, DurationSec, Segments []Segment{Text, Start, Duration}), Text (when Format is "text"), Metadata (when requested), and Raw, the original JSON, for fields the SDK does not model.

list, _ := client.Transcripts.List(ctx, &yt.ListOptions{Q: "zoo", Sort: "recent", Page: 1, PageSize: 20})
srt, _ := client.Transcripts.Download(ctx, "jNQXAC9IVRw", &yt.DownloadOptions{Format: "srt"}) // txt, srt, vtt, json, md
_, _ = client.Transcripts.Delete(ctx, "jNQXAC9IVRw", nil)
client.Batches
Method Request Returns
Create(ctx, *BatchCreateOptions) POST /v1/batch *Batch
Get(ctx, batchID, *BatchGetOptions) GET /v1/batch/{id} *BatchDetail (Batch, Items, NextPageToken)
Wait(ctx, batchID, *BatchWaitOptions) polls Get until completed or failed *BatchDetail
Export(ctx, batchID, *BatchExportOptions) GET /v1/batch/{id}/export []byte
Retry(ctx, batchID) POST /v1/batch/{id}/retry *BatchRetryResult
Delete(ctx, batchID) DELETE /v1/library/batches/{id} *Removed
batch, err := client.Batches.Create(ctx, &yt.BatchCreateOptions{
	Items:    []string{"https://youtu.be/jNQXAC9IVRw", "https://youtu.be/9bZkp7q19f0"},
	Language: "en",
	Name:     "demo",
})
// Or Playlist: "PL..." / Channel: "@handle", with Limit: 50.
// Exactly one of Items, Playlist, Channel; otherwise INVALID_REQUEST locally.

done, err := client.Batches.Wait(ctx, batch.ID, &yt.BatchWaitOptions{Timeout: 30 * time.Minute, PollInterval: 3 * time.Second})
zip, err := client.Batches.Export(ctx, batch.ID, &yt.BatchExportOptions{Format: "zip", Files: "srt", Timestamps: yt.Bool(true)})

Batches need a bought credit pack. Wait defaults to a 1800 s timeout and a 3 s poll interval.

client.Account
usage, err := client.Account.Usage(ctx)
fmt.Println(usage.Credits.Available, usage.Credits.FreeToday.Remaining, usage.Batch.ItemsPerJob)

Error handling

Every failure is an *yt.Error. Get it with errors.As:

res, err := client.Transcripts.Get(ctx, "jNQXAC9IVRw", nil)
if err != nil {
	var apiErr *yt.Error
	if errors.As(err, &apiErr) {
		fmt.Println(apiErr.Status, apiErr.Code, apiErr.Message, apiErr.RequestID)
		if apiErr.Code == "LANGUAGE_NOT_AVAILABLE" {
			fmt.Println(apiErr.Details["availableLanguages"])
		}
	}
	return err
}
Field Meaning
Status HTTP status; 0 for local errors
Code the server's error.code; HTTP_<status> for non-JSON responses; NETWORK_ERROR; TIMEOUT; API_KEY_REQUIRED; INVALID_REQUEST; TRANSCRIPT_FAILED; CANCELED (your context was canceled)
Message human readable text
RequestID the X-Request-Id response header, quote it to support
RetryAfter the Retry-After header as a time.Duration; 0 when absent
Details the server's error object as returned (availableLanguages, creditsRequired, ...)
Retryable true for 429, 5xx and NETWORK_ERROR
JobID the transcript job, for failed jobs and polling timeouts

If your own context is canceled or expires, the error also unwraps to context.Canceled / context.DeadlineExceeded, so errors.Is works.

Retries

Retryable failures (429, 5xx, network errors) are retried up to WithMaxRetries times (default 2) for:

  • GET and DELETE requests, and
  • POST /v1/transcript, which always carries an Idempotency-Key (a fresh UUID v4 per call). Every retry of the same call reuses the same key, so the server never starts or charges a second extraction.

POST /v1/batch and POST /v1/batch/{id}/retry are never retried automatically, because a repeat would charge twice. Check Retryable and decide yourself.

The wait before a retry is Retry-After when the server sends it (at most 60 s), otherwise 0.5 s × 2ⁿ plus 0 to 250 ms of jitter. A request timeout (TIMEOUT) is not retried.

End-to-end check

examples/e2e runs the whole API surface against a live server:

YTT_API_KEY=ytt_... YTT_BASE_URL=https://api.youtubetranscript.net go run ./examples/e2e

Documentation

Overview

Package youtubetranscript is the Go client for the YouTubeTranscript.net API.

client, err := youtubetranscript.NewClient() // reads YTT_API_KEY
if err != nil { log.Fatal(err) }
res, err := client.Transcripts.Get(ctx, "jNQXAC9IVRw", nil)

Only the standard library is used.

Index

Constants

View Source
const (
	// Version is the SDK version.
	Version = "0.1.0"
	// DefaultBaseURL is used when neither WithBaseURL nor YTT_BASE_URL is set.
	DefaultBaseURL = "https://api.youtubetranscript.net"
	// DefaultTimeout is the per-request HTTP timeout.
	DefaultTimeout = 60 * time.Second
	// DefaultMaxRetries is the number of automatic retries.
	DefaultMaxRetries = 2
)

Variables

This section is empty.

Functions

func Bool

func Bool(v bool) *bool

Bool returns a pointer to v, for optional boolean fields in option structs.

func Int

func Int(v int) *int

Int returns a pointer to v, for optional integer fields in option structs.

Types

type AccountService

type AccountService struct {
	// contains filtered or unexported fields
}

AccountService covers account information.

func (*AccountService) Usage

func (s *AccountService) Usage(ctx context.Context) (*Usage, error)

Usage returns the credit balance, today's free allowance and the limits (GET /v1/usage).

type Batch

type Batch struct {
	ID           string      `json:"id"`
	Status       string      `json:"status"` // pending, processing, completed, failed
	Name         string      `json:"name"`
	SourceType   string      `json:"sourceType"`
	Lang         string      `json:"lang"`
	TotalCredits int         `json:"totalCredits"`
	Counts       BatchCounts `json:"counts"`
	CreatedAt    string      `json:"createdAt"`
	UpdatedAt    string      `json:"updatedAt"`
}

Batch is a batch job.

type BatchCounts

type BatchCounts struct {
	Total   int `json:"total"`
	Pending int `json:"pending"`
	Success int `json:"success"`
	Failed  int `json:"failed"`
}

BatchCounts are the per-status video counts of a batch.

type BatchCreateOptions

type BatchCreateOptions struct {
	// Items are video links (or ids).
	Items []string
	// Playlist is a playlist link or id.
	Playlist string
	// Channel is a channel link, @handle or id.
	Channel string
	// Language is a comma-separated priority list (default "auto").
	Language string
	// Limit caps the videos taken from a playlist or channel (1-500).
	Limit int
	// Name labels the batch (up to 200 characters).
	Name string
}

BatchCreateOptions describes a batch. Set exactly one of Items, Playlist, Channel.

type BatchDetail

type BatchDetail struct {
	Batch         Batch       `json:"batch"`
	Items         []BatchItem `json:"items"`
	NextPageToken string      `json:"nextPageToken"`
}

BatchDetail is a batch with one page of its videos.

type BatchExportOptions

type BatchExportOptions struct {
	// Format is zip (default), csv, txt, json, srt or vtt.
	Format string
	// Files is the format of each file inside a zip: txt, srt, vtt, json or csv.
	Files string
	// Timestamps keeps timestamps; nil means the server default (true).
	Timestamps *bool
}

BatchExportOptions are the optional parameters of Export.

type BatchGetOptions

type BatchGetOptions struct {
	// MaxResults is the page size (1-500); 0 means the server default.
	MaxResults int
	// PageToken continues from BatchDetail.NextPageToken.
	PageToken string
}

BatchGetOptions are the optional parameters of Get.

type BatchItem

type BatchItem struct {
	ID          string `json:"id"`
	Platform    string `json:"platform"`
	ExternalID  string `json:"externalId"`
	SourceURL   string `json:"sourceUrl"`
	Lang        string `json:"lang"`
	Status      string `json:"status"` // pending, processing, success, failed
	Title       string `json:"title"`
	Channel     string `json:"channel"`
	DurationSec int    `json:"durationSec"`
	Words       int    `json:"words"`
	Error       string `json:"error"`
}

BatchItem is one video of a batch.

type BatchLimits

type BatchLimits struct {
	ItemsPerJob int `json:"itemsPerJob"`
}

BatchLimits are the batch limits of the account.

type BatchRetryResult

type BatchRetryResult struct {
	Batch   Batch `json:"batch"`
	Retried int   `json:"retried"`
	Credits int   `json:"credits"`
}

BatchRetryResult is the answer of Batches.Retry.

type BatchWaitOptions

type BatchWaitOptions struct {
	// Timeout bounds the wait (default 1800s).
	Timeout time.Duration
	// PollInterval is the wait between polls (default 3s).
	PollInterval time.Duration
}

BatchWaitOptions are the optional parameters of Wait.

type BatchesService

type BatchesService struct {
	// contains filtered or unexported fields
}

BatchesService covers batch jobs.

func (*BatchesService) Create

func (s *BatchesService) Create(ctx context.Context, opts *BatchCreateOptions) (*Batch, error)

Create starts a batch (POST /v1/batch). It is never retried automatically: a repeated request would be charged twice. Giving none or more than one of Items, Playlist and Channel fails locally with INVALID_REQUEST.

func (*BatchesService) Delete

func (s *BatchesService) Delete(ctx context.Context, batchID string) (*Removed, error)

Delete removes a batch (DELETE /v1/library/batches/{batchId}).

func (*BatchesService) Export

func (s *BatchesService) Export(ctx context.Context, batchID string, opts *BatchExportOptions) ([]byte, error)

Export downloads a batch (GET /v1/batch/{batchId}/export) and returns the raw bytes (a zip archive by default).

func (*BatchesService) Get

func (s *BatchesService) Get(ctx context.Context, batchID string, opts *BatchGetOptions) (*BatchDetail, error)

Get returns a batch with one page of its videos (GET /v1/batch/{batchId}).

func (*BatchesService) Retry

func (s *BatchesService) Retry(ctx context.Context, batchID string) (*BatchRetryResult, error)

Retry re-runs the failed videos of a finished batch (POST /v1/batch/{batchId}/retry). It is never retried automatically.

func (*BatchesService) Wait

func (s *BatchesService) Wait(ctx context.Context, batchID string, opts *BatchWaitOptions) (*BatchDetail, error)

Wait polls Get until the batch status is "completed" or "failed" and returns the last result. Running past the timeout returns an *Error with code TIMEOUT. A 429 while polling waits for Retry-After and continues.

type CaptionTrack

type CaptionTrack struct {
	Lang          string `json:"lang"`
	AutoGenerated bool   `json:"autoGenerated"`
}

CaptionTrack describes one caption track.

type Chapter

type Chapter struct {
	Title string  `json:"title"`
	Start float64 `json:"start"`
}

Chapter is a video chapter.

type Client

type Client struct {
	// Transcripts covers transcript extraction, jobs, info and the library.
	Transcripts *TranscriptsService
	// Batches covers batch jobs.
	Batches *BatchesService
	// Account covers usage and limits.
	Account *AccountService
	// contains filtered or unexported fields
}

Client talks to the API. It is safe for concurrent use.

func NewClient

func NewClient(opts ...Option) (*Client, error)

NewClient builds a client. When no API key is given and YTT_API_KEY is empty it returns an *Error with code API_KEY_REQUIRED without sending a request.

type Credits

type Credits struct {
	Balance      int         `json:"balance"`
	FreeToday    FreeCredits `json:"freeToday"`
	Available    int         `json:"available"`
	HasPurchased bool        `json:"hasPurchased"`
}

Credits is the credit balance.

type DeleteOptions

type DeleteOptions struct {
	// Language removes one language only; empty uses the server default.
	Language string
}

DeleteOptions are the optional parameters of Delete.

type DownloadOptions

type DownloadOptions struct {
	// Format is txt (default), srt, vtt, json or md.
	Format string
	// Language selects a saved language; empty means the latest.
	Language string
}

DownloadOptions are the optional parameters of Download.

type Error

type Error struct {
	// Status is the HTTP status code; 0 for errors raised locally
	// (API_KEY_REQUIRED, INVALID_REQUEST, TIMEOUT while polling, ...).
	Status int
	// Code is the server's error.code, or HTTP_<status> for non-JSON
	// responses, NETWORK_ERROR for connection failures, TIMEOUT for timeouts.
	Code string
	// Message is the human readable message.
	Message string
	// RequestID is the X-Request-Id response header, when present.
	RequestID string
	// RetryAfter is the Retry-After response header; 0 when absent.
	RetryAfter time.Duration
	// Details is the server's error object as returned (for example
	// availableLanguages, creditsRequired); nil for local errors.
	Details map[string]any
	// Retryable is true for 429, 5xx and NETWORK_ERROR.
	Retryable bool
	// JobID is set when the error belongs to a transcript job
	// (a failed job or a polling TIMEOUT).
	JobID string
	// contains filtered or unexported fields
}

Error is the single error type returned by every method of this package. Extract it with errors.As:

var apiErr *youtubetranscript.Error
if errors.As(err, &apiErr) { fmt.Println(apiErr.Code, apiErr.Status) }

func (*Error) Error

func (e *Error) Error() string

Error implements the error interface.

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap returns the underlying cause (for example context.Canceled), if any.

type FreeCredits

type FreeCredits struct {
	Limit     int    `json:"limit"`
	Used      int    `json:"used"`
	Remaining int    `json:"remaining"`
	ResetsAt  string `json:"resetsAt"`
}

FreeCredits is today's free allowance.

type GetOptions

type GetOptions struct {
	// Language is a comma-separated priority list: BCP-47 codes, "auto",
	// "asr" or "asr-<code>". Default "auto".
	Language string
	// Format is "json" (default) or "text".
	Format string
	// IncludeTimestamp keeps start/duration (json) or [m:ss] prefixes (text).
	IncludeTimestamp *bool
	// SendMetadata adds the Metadata object.
	SendMetadata *bool
	// ConfirmCredits accepts a cost above 10 credits.
	ConfirmCredits *bool
	// Timeout bounds the whole call including polling (default 300s).
	Timeout time.Duration
	// PollInterval is the wait between job polls (default 2s).
	PollInterval time.Duration
}

GetOptions are the optional parameters of Get. Zero values mean "server default".

type JobError

type JobError struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

JobError is the error object of a failed job.

type LibraryItem

type LibraryItem struct {
	ID           string `json:"id"`
	Platform     string `json:"platform"`
	ExternalID   string `json:"externalId"`
	SourceURL    string `json:"sourceUrl"`
	Lang         string `json:"lang"`
	Title        string `json:"title"`
	Channel      string `json:"channel"`
	ThumbnailURL string `json:"thumbnailUrl"`
	Words        int    `json:"words"`
	DurationSec  int    `json:"durationSec"`
	Starred      bool   `json:"starred"`
	Origin       string `json:"origin"`
	CreatedAt    string `json:"createdAt"`
}

LibraryItem is one row of the transcript library.

type Limits

type Limits struct {
	TaskConcurrency int `json:"taskConcurrency"`
	ActiveTasks     int `json:"activeTasks"`
}

Limits are the concurrency limits of the account.

type ListOptions

type ListOptions struct {
	// Q searches titles and channels.
	Q string
	// Lang filters by language.
	Lang string
	// Sort is "recent" (default), "oldest" or "title".
	Sort string
	// Page starts at 1; 0 means the server default.
	Page int
	// PageSize is 1-100; 0 means the server default (24).
	PageSize int
}

ListOptions are the optional parameters of List.

type Option

type Option func(*config)

Option configures NewClient.

func WithAPIKey

func WithAPIKey(key string) Option

WithAPIKey sets the API key (default: the YTT_API_KEY environment variable).

func WithBaseURL

func WithBaseURL(u string) Option

WithBaseURL sets the API origin (default: YTT_BASE_URL, then DefaultBaseURL). Trailing slashes are removed.

func WithHTTPClient

func WithHTTPClient(h *http.Client) Option

WithHTTPClient replaces the underlying *http.Client (proxies, custom transports). Per-request timeouts are applied with contexts, so the client's own Timeout can stay zero.

func WithMaxRetries

func WithMaxRetries(n int) Option

WithMaxRetries sets how many times a retryable request is retried (default 2; 0 disables retries).

func WithTimeout

func WithTimeout(d time.Duration) Option

WithTimeout sets the timeout of a single HTTP request (default 60s).

type Removed

type Removed struct {
	Removed bool `json:"removed"`
}

Removed is the answer of the delete calls.

type Segment

type Segment struct {
	Text     string  `json:"text"`
	Start    float64 `json:"start"`
	Duration float64 `json:"duration"`
}

Segment is one caption line. Start and Duration are in seconds.

type SubmitOptions

type SubmitOptions struct {
	Language         string
	Format           string
	IncludeTimestamp *bool
	SendMetadata     *bool
	ConfirmCredits   *bool
	// WaitMs is how long the server may hold the request for a fast result
	// before answering 202 (0-10000). Nil sends no value (server default).
	WaitMs *int
}

SubmitOptions are the optional parameters of Submit.

type Transcript

type Transcript struct {
	ID           string    `json:"id"`
	Platform     string    `json:"platform"`
	ExternalID   string    `json:"externalId"`
	SourceURL    string    `json:"sourceUrl"`
	Lang         string    `json:"lang"`
	Origin       string    `json:"origin"` // original, auto or asr
	Title        string    `json:"title"`
	Channel      string    `json:"channel"`
	ThumbnailURL string    `json:"thumbnailUrl"`
	DurationSec  int       `json:"durationSec"`
	PublishedAt  string    `json:"publishedAt"`
	Segments     []Segment `json:"segments"`
	CreatedAt    string    `json:"createdAt"`
}

Transcript is a saved transcript.

type TranscriptList

type TranscriptList struct {
	Transcripts []LibraryItem `json:"transcripts"`
	Total       int           `json:"total"`
	Page        int           `json:"page"`
	PageSize    int           `json:"pageSize"`
	Langs       []string      `json:"langs"`
}

TranscriptList is one page of the library.

type TranscriptResult

type TranscriptResult struct {
	Status         string         `json:"status"`
	JobID          string         `json:"jobId"`
	Stage          string         `json:"stage"`
	Cached         bool           `json:"cached"`
	Language       string         `json:"language"`
	Format         string         `json:"format"` // json or text
	MetadataStatus string         `json:"metadataStatus"`
	LengthSeconds  int            `json:"lengthSeconds"`
	LengthText     string         `json:"lengthText"`
	Metadata       *VideoMetadata `json:"metadata"`
	// Transcript is set when Format is "json".
	Transcript *Transcript `json:"transcript"`
	// Text is set when Format is "text".
	Text  string    `json:"text"`
	Error *JobError `json:"error"`

	// Raw is the original JSON response body.
	Raw json.RawMessage `json:"-"`
}

TranscriptResult is either a finished transcript (Status "success") or a job still running (Status "pending" or "processing", with JobID). Unknown fields are ignored; Raw keeps the complete response body.

func (*TranscriptResult) Done

func (r *TranscriptResult) Done() bool

Done reports whether the transcript is ready.

type TranscriptsService

type TranscriptsService struct {
	// contains filtered or unexported fields
}

TranscriptsService covers transcripts and the transcript library.

func (*TranscriptsService) Delete

func (s *TranscriptsService) Delete(ctx context.Context, videoID string, opts *DeleteOptions) (*Removed, error)

Delete removes a transcript from the library (DELETE /v1/library/transcripts/youtube/{videoId}).

func (*TranscriptsService) Download

func (s *TranscriptsService) Download(ctx context.Context, videoID string, opts *DownloadOptions) (string, error)

Download returns a saved transcript as text in the given format (GET /v1/library/transcripts/youtube/{videoId}/download). JSON is returned as a string too.

func (*TranscriptsService) Get

Get returns the transcript of a video, polling the job when the server answers 202. A failed job returns an *Error (code from the job's error.code, else TRANSCRIPT_FAILED); running past opts.Timeout returns an *Error with code TIMEOUT and the JobID.

func (*TranscriptsService) Info

func (s *TranscriptsService) Info(ctx context.Context, video string) (*VideoInfo, error)

Info returns the video details and caption languages; it is free (GET /v1/transcript/info).

func (*TranscriptsService) Job

Job returns a transcript job as the server reports it (GET /v1/transcript/job/{jobId}).

func (*TranscriptsService) List

List returns one page of the transcript library (GET /v1/library/transcripts).

func (*TranscriptsService) Submit

func (s *TranscriptsService) Submit(ctx context.Context, video string, opts *SubmitOptions) (*TranscriptResult, error)

Submit sends the request once (with an Idempotency-Key) and returns the first response as is: a finished transcript (Status "success") or a job (Status "pending"/"processing" with JobID) to follow with Job. video is a watch / youtu.be / Shorts link or an 11 character video id.

type Usage

type Usage struct {
	Credits Credits     `json:"credits"`
	Batch   BatchLimits `json:"batch"`
	Limits  Limits      `json:"limits"`

	// Raw is the original JSON response body.
	Raw json.RawMessage `json:"-"`
}

Usage is the answer of Account.Usage.

type VideoInfo

type VideoInfo struct {
	Platform           string         `json:"platform"`
	ExternalID         string         `json:"externalId"`
	Title              string         `json:"title"`
	Channel            string         `json:"channel"`
	ChannelID          string         `json:"channelId"`
	ThumbnailURL       string         `json:"thumbnailUrl"`
	LengthSeconds      int            `json:"lengthSeconds"`
	LengthText         string         `json:"lengthText"`
	PublishedAt        string         `json:"publishedAt"`
	Description        string         `json:"description"`
	Chapters           []Chapter      `json:"chapters"`
	AvailableLanguages []string       `json:"availableLanguages"`
	CaptionTracks      []CaptionTrack `json:"captionTracks"`
	SourceURL          string         `json:"sourceUrl"`
}

VideoInfo is the free video lookup.

type VideoMetadata

type VideoMetadata struct {
	Platform      string `json:"platform"`
	ExternalID    string `json:"externalId"`
	SourceURL     string `json:"sourceUrl"`
	Title         string `json:"title"`
	Channel       string `json:"channel"`
	ThumbnailURL  string `json:"thumbnailUrl"`
	PublishedAt   string `json:"publishedAt"`
	LengthSeconds int    `json:"lengthSeconds"`
	Language      string `json:"language"`
}

VideoMetadata is returned when SendMetadata is set.

Directories

Path Synopsis
examples
e2e command
Command e2e runs the end-to-end acceptance against a real API.
Command e2e runs the end-to-end acceptance against a real API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL