yt_transcript

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2026 License: MIT Imports: 11 Imported by: 0

README

yt-transcript

Go Reference Go Report Card CI

Fetch YouTube transcripts. No API key needed.

Install

go install github.com/shanehull/yt-transcript/cmd/yt-transcript@latest

CLI

yt-transcript dQw4w9WgXcQ                  # plain text
yt-transcript -fmt json dQw4w9WgXcQ        # JSON with timestamps
yt-transcript -fmt srt dQw4w9WgXcQ         # SRT subtitles
yt-transcript -lang fr dQw4w9WgXcQ         # French transcript

Library

import (
    "context"
    yt "github.com/shanehull/yt-transcript"
)

client := yt.NewClient()
segments, _ := client.FetchTranscript(context.Background(), "dQw4w9WgXcQ", "en")
for _, s := range segments {
    fmt.Println(s.Text)
}

Server

go run github.com/shanehull/yt-transcript/cmd/server@latest
docker run -p 8080:8080 ghcr.io/shanehull/yt-transcript
GET /{video_id}[?lang=en][&fmt=text|srt]  → transcript
curl https://yt-transcript.net/dQw4w9WgXcQ
curl https://yt-transcript.net/dQw4w9WgXcQ?fmt=text
curl https://yt-transcript.net/dQw4w9WgXcQ?fmt=srt
curl https://yt-transcript.net/dQw4w9WgXcQ?lang=fr

Documentation

Overview

Package yt_transcript fetches YouTube video transcripts via the innertube API. Stdlib only, zero dependencies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client fetches YouTube transcripts.

func NewClient

func NewClient() *Client

NewClient returns a Client with a default 30s timeout and cookie jar.

func (*Client) FetchTranscript

func (c *Client) FetchTranscript(ctx context.Context, videoID, lang string) ([]Segment, error)

FetchTranscript retrieves the transcript for a YouTube video in the given language.

func (*Client) WithHTTPClient

func (c *Client) WithHTTPClient(h *http.Client) *Client

WithHTTPClient sets a custom http.Client.

type Segment

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

Segment represents a single transcript line with timing.

Directories

Path Synopsis
cmd
server command
Command yt-transcript-server serves YouTube transcripts over HTTP.
Command yt-transcript-server serves YouTube transcripts over HTTP.
yt-transcript command
Command yt-transcript fetches YouTube transcripts from the command line.
Command yt-transcript fetches YouTube transcripts from the command line.
internal
cache
Package cache provides a simple in-memory TTL cache for transcript segments.
Package cache provides a simple in-memory TTL cache for transcript segments.
handlers
Package handlers provides HTTP handlers for the yt-transcript server.
Package handlers provides HTTP handlers for the yt-transcript server.
middleware
Package middleware provides HTTP middleware for the yt-transcript server.
Package middleware provides HTTP middleware for the yt-transcript server.

Jump to

Keyboard shortcuts

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