youtube

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2026 License: MIT Imports: 11 Imported by: 0 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.

Documentation

Overview

Package youtube extracts transcripts and metadata from YouTube videos by parsing YouTube URLs and delegating extraction to the shared mediadl core.

Index

Constants

View Source
const (
	TranscriptionPolicyCaptions = mediadl.TranscriptionPolicyCaptions
	TranscriptionPolicyAuto     = mediadl.TranscriptionPolicyAuto
	TranscriptionPolicySTT      = mediadl.TranscriptionPolicySTT

	TranscriptSourceCaptions = mediadl.TranscriptSourceCaptions
	TranscriptSourceSTT      = mediadl.TranscriptSourceSTT

	CaptionKindManual    = mediadl.CaptionKindManual
	CaptionKindAutomatic = mediadl.CaptionKindAutomatic

	ErrorKindInvalidURL            = mediadl.ErrorKindInvalidURL
	ErrorKindUnavailable           = mediadl.ErrorKindUnavailable
	ErrorKindPrivate               = mediadl.ErrorKindPrivate
	ErrorKindAgeRestricted         = mediadl.ErrorKindAgeRestricted
	ErrorKindTranscriptUnavailable = mediadl.ErrorKindTranscriptUnavailable
	ErrorKindAudioUnavailable      = mediadl.ErrorKindAudioUnavailable
	ErrorKindRateLimited           = mediadl.ErrorKindRateLimited
	ErrorKindNetworkBlocked        = mediadl.ErrorKindNetworkBlocked
)

Variables

View Source
var ParseTranscriptionPolicy = mediadl.ParseTranscriptionPolicy

ParseTranscriptionPolicy validates a transcription policy string.

Functions

func NormalizeChannelURL added in v0.0.10

func NormalizeChannelURL(raw string) (string, error)

NormalizeChannelURL canonicalizes a channel or playlist URL to the form yt-dlp enumerates cleanly. Channel handles and the /shorts and /streams tabs are rewritten to /videos; playlist URLs keep their list query. Single-video URLs are rejected so callers route them to single-video ingestion instead.

Types

type BulkOptions added in v0.0.10

type BulkOptions struct {
	TranscriptionPolicy     TranscriptionPolicy
	PreferredLanguages      []string
	AllowTranslatedCaptions bool
	Concurrency             int
	Throttle                time.Duration
	BackoffMax              time.Duration
	MaxRetries              int
}

BulkOptions controls channel/playlist bulk transcript extraction. Concurrency, Throttle, BackoffMax, and MaxRetries form the rate-limit defense: a small worker pool, an inter-request throttle with jitter, and adaptive exponential backoff when YouTube starts blocking requests.

type CaptionKind added in v0.0.8

type CaptionKind = mediadl.CaptionKind

Shared types re-exported from mediadl so existing callers (CLI, channel ingestion) keep compiling against the youtube package surface.

type ChannelVideo added in v0.0.10

type ChannelVideo struct {
	VideoID string
	Title   string
	URL     string
}

ChannelVideo identifies a single video resolved from a channel or playlist.

type Error

type Error = mediadl.Error

Shared types re-exported from mediadl so existing callers (CLI, channel ingestion) keep compiling against the youtube package surface.

type ErrorKind

type ErrorKind = mediadl.ErrorKind

Shared types re-exported from mediadl so existing callers (CLI, channel ingestion) keep compiling against the youtube package surface.

type ExtractOptions

type ExtractOptions = mediadl.ExtractOptions

Shared types re-exported from mediadl so existing callers (CLI, channel ingestion) keep compiling against the youtube package surface.

type Extractor

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

Extractor extracts YouTube transcripts by parsing YouTube URLs and delegating to the shared mediadl core.

func NewExtractorWithConfig added in v0.0.8

func NewExtractorWithConfig(
	sttConfig config.STTConfig,
	openRouterConfig config.OpenRouterConfig,
	youtubeConfigs ...config.YouTubeConfig,
) *Extractor

NewExtractorWithConfig constructs an extractor with explicit STT provider configuration.

func (*Extractor) BulkExtract added in v0.0.10

func (extractor *Extractor) BulkExtract(
	ctx context.Context,
	videos []ChannelVideo,
	options BulkOptions,
	sink func(VideoOutcome),
) error

BulkExtract extracts transcripts for the supplied videos using a bounded worker pool with an inter-request throttle and adaptive backoff on YouTube rate limits. sink is invoked exactly once per video (serialized, so it need not be thread-safe) so callers can persist incrementally. It returns the context error if the run was canceled.

func (*Extractor) Extract

func (extractor *Extractor) Extract(ctx context.Context, rawURL string, options ExtractOptions) (*Result, error)

Extract fetches video metadata and transcript markdown from a YouTube URL.

func (*Extractor) ListChannelVideos added in v0.0.10

func (extractor *Extractor) ListChannelVideos(ctx context.Context, normalizedURL string, limit int) ([]ChannelVideo, error)

ListChannelVideos resolves the videos for an already-normalized channel or playlist URL. A limit greater than zero caps the result to the newest uploads.

type Metadata

type Metadata = mediadl.Metadata

Shared types re-exported from mediadl so existing callers (CLI, channel ingestion) keep compiling against the youtube package surface.

type Result

type Result = mediadl.Result

Shared types re-exported from mediadl so existing callers (CLI, channel ingestion) keep compiling against the youtube package surface.

type TranscriptSource

type TranscriptSource = mediadl.TranscriptSource

Shared types re-exported from mediadl so existing callers (CLI, channel ingestion) keep compiling against the youtube package surface.

type TranscriptionPolicy added in v0.0.8

type TranscriptionPolicy = mediadl.TranscriptionPolicy

Shared types re-exported from mediadl so existing callers (CLI, channel ingestion) keep compiling against the youtube package surface.

type VideoOutcome added in v0.0.10

type VideoOutcome struct {
	Video  ChannelVideo
	Result *Result
	Err    error
}

VideoOutcome reports the result of extracting a single video during a bulk run. Exactly one of Result or Err is set.

Jump to

Keyboard shortcuts

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