YouTubeTranscriptNet.Transcripts (youtubetranscript_net v0.1.0)

Copy Markdown View Source

Transcripts of single videos, and your transcript library.

video is a YouTube link (watch, youtu.be, Shorts) or an 11-character video id. language is a priority list such as "en", "pt-BR,pt", "auto" (the video's own captions) or "asr" (speech-to-text when there are no captions).

Summary

Functions

DELETE /v1/library/transcripts/youtube/{video_id}. Returns %{"removed" => true}. Option: :language.

Downloads a saved transcript as a string. Options: :format ("txt" default, "srt", "vtt", "json", "md"), :language.

Gets a transcript and waits for it: POST /v1/transcript, then polls the job while it is pending (speech-to-text, long videos).

GET /v1/transcript/info: video details and caption languages. Free.

GET /v1/transcript/job/{job_id}: a TranscriptResult once finished, otherwise a Job.

GET /v1/library/transcripts. Returns %{"transcripts", "total", "page", "pageSize", "langs"}.

Sends the request once and returns the first answer as-is: a TranscriptResult (status: "success") or a Job (pending / processing, with job_id).

Functions

delete(client, video_id, opts \\ [])

@spec delete(YouTubeTranscriptNet.Client.t(), String.t(), keyword()) ::
  {:ok, map()} | {:error, YouTubeTranscriptNet.Error.t()}

DELETE /v1/library/transcripts/youtube/{video_id}. Returns %{"removed" => true}. Option: :language.

download(client, video_id, opts \\ [])

@spec download(YouTubeTranscriptNet.Client.t(), String.t(), keyword()) ::
  {:ok, String.t()} | {:error, YouTubeTranscriptNet.Error.t()}

Downloads a saved transcript as a string. Options: :format ("txt" default, "srt", "vtt", "json", "md"), :language.

get(client, video, opts \\ [])

Gets a transcript and waits for it: POST /v1/transcript, then polls the job while it is pending (speech-to-text, long videos).

Options: :language, :format ("json" default, or "text" for result.text), :include_timestamp, :send_metadata, :confirm_credits (accept a cost above 10 credits), :timeout (ms to wait in total, default 300_000), :poll_interval (ms, default 2_000).

Errors: TIMEOUT (with job_id) when the job is not done in time; a failed job returns its own error.code (or TRANSCRIPT_FAILED) with status: 0 and job_id.

info(client, video)

@spec info(YouTubeTranscriptNet.Client.t(), String.t()) ::
  {:ok, map()} | {:error, YouTubeTranscriptNet.Error.t()}

GET /v1/transcript/info: video details and caption languages. Free.

job(client, job_id)

GET /v1/transcript/job/{job_id}: a TranscriptResult once finished, otherwise a Job.

list(client, opts \\ [])

@spec list(YouTubeTranscriptNet.Client.t(), keyword()) ::
  {:ok, map()} | {:error, YouTubeTranscriptNet.Error.t()}

GET /v1/library/transcripts. Returns %{"transcripts", "total", "page", "pageSize", "langs"}.

Options: :q, :lang, :sort, :page, :page_size.

submit(client, video, opts \\ [])

Sends the request once and returns the first answer as-is: a TranscriptResult (status: "success") or a Job (pending / processing, with job_id).

Options: those of get/3 except :timeout and :poll_interval, plus :wait_ms (how long the server may hold the request, up to 10_000).