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
- Variables
- func NormalizeChannelURL(raw string) (string, error)
- type BulkOptions
- type CaptionKind
- type ChannelVideo
- type Error
- type ErrorKind
- type ExtractOptions
- type Extractor
- func (extractor *Extractor) BulkExtract(ctx context.Context, videos []ChannelVideo, options BulkOptions, ...) error
- func (extractor *Extractor) Extract(ctx context.Context, rawURL string, options ExtractOptions) (*Result, error)
- func (extractor *Extractor) ListChannelVideos(ctx context.Context, normalizedURL string, limit int) ([]ChannelVideo, error)
- type Metadata
- type Result
- type TranscriptSource
- type TranscriptionPolicy
- type VideoOutcome
Constants ¶
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 ErrorKindPrivate = mediadl.ErrorKindPrivate ErrorKindAgeRestricted = mediadl.ErrorKindAgeRestricted ErrorKindRateLimited = mediadl.ErrorKindRateLimited ErrorKindNetworkBlocked = mediadl.ErrorKindNetworkBlocked )
Variables ¶
var ParseTranscriptionPolicy = mediadl.ParseTranscriptionPolicy
ParseTranscriptionPolicy validates a transcription policy string.
Functions ¶
func NormalizeChannelURL ¶ added in v0.0.10
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
ChannelVideo identifies a single video resolved from a channel or playlist.
type Error ¶
Shared types re-exported from mediadl so existing callers (CLI, channel ingestion) keep compiling against the youtube package surface.
type 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 ¶
Shared types re-exported from mediadl so existing callers (CLI, channel ingestion) keep compiling against the youtube package surface.
type 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.