Documentation
¶
Overview ¶
Package youtube extracts transcripts and metadata from YouTube videos.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewTranscriber ¶ added in v0.0.8
func NewTranscriber(sttConfig config.STTConfig, openRouterConfig config.OpenRouterConfig) sttClient
NewTranscriber constructs the configured STT backend.
Types ¶
type CaptionKind ¶ added in v0.0.8
type CaptionKind string
CaptionKind identifies whether fetched YouTube captions were manual or ASR.
const ( CaptionKindManual CaptionKind = "manual" CaptionKindAutomatic CaptionKind = "automatic" )
type Error ¶
Error carries structured failure details for callers that need to branch on YouTube-specific failure modes.
type ErrorKind ¶
type ErrorKind string
ErrorKind categorizes user-facing YouTube extraction failures.
const ( // ErrorKindInvalidURL reports a malformed or unsupported YouTube URL. ErrorKindInvalidURL ErrorKind = "invalid_url" ErrorKindUnavailable ErrorKind = "unavailable" // ErrorKindPrivate reports a private video. ErrorKindPrivate ErrorKind = "private" // ErrorKindAgeRestricted reports a video that requires login/age confirmation. ErrorKindAgeRestricted ErrorKind = "age_restricted" ErrorKindTranscriptUnavailable ErrorKind = "transcript_unavailable" ErrorKindAudioUnavailable ErrorKind = "audio_unavailable" // ErrorKindNetworkBlocked reports a YouTube network block or bot-detection response. ErrorKindNetworkBlocked ErrorKind = "network_blocked" )
type ExtractOptions ¶
type ExtractOptions struct {
TranscriptionPolicy TranscriptionPolicy
PreferredLanguages []string
}
ExtractOptions controls transcript extraction behavior.
type Extractor ¶
type Extractor struct {
// contains filtered or unexported fields
}
Extractor orchestrates transcript extraction and optional STT fallback.
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.
type Metadata ¶
type Metadata struct {
VideoID string
URL string
Title string
Channel string
ChannelID string
UploaderID string
Duration time.Duration
DurationString string
PublishDate time.Time
ViewCount *int64
LikeCount *int64
CommentCount *int64
ChannelFollowerCount *int64
Categories []string
VideoTags []string
Language string
LiveStatus string
WasLive *bool
ChapterCount int
}
Metadata contains normalized video metadata.
type OpenAITranscriber ¶ added in v0.0.8
type OpenAITranscriber struct {
// contains filtered or unexported fields
}
OpenAITranscriber calls OpenAI's audio transcriptions endpoint.
func NewOpenAITranscriber ¶ added in v0.0.8
func NewOpenAITranscriber(cfg config.STTConfig) *OpenAITranscriber
NewOpenAITranscriber constructs an OpenAI STT provider from runtime config.
func (*OpenAITranscriber) Configured ¶ added in v0.0.8
func (client *OpenAITranscriber) Configured() bool
func (*OpenAITranscriber) Model ¶ added in v0.0.8
func (client *OpenAITranscriber) Model() string
func (*OpenAITranscriber) Provider ¶ added in v0.0.8
func (client *OpenAITranscriber) Provider() string
func (*OpenAITranscriber) Transcribe ¶ added in v0.0.8
type OpenRouterClient ¶
type OpenRouterClient struct {
// contains filtered or unexported fields
}
OpenRouterClient calls the OpenRouter chat completions API as an STT provider.
func NewOpenRouterClient ¶
func NewOpenRouterClient(cfg config.OpenRouterConfig) *OpenRouterClient
NewOpenRouterClient constructs an STT client from runtime configuration.
func NewOpenRouterClientWithPrompt ¶ added in v0.0.8
func NewOpenRouterClientWithPrompt(cfg config.OpenRouterConfig, prompt string) *OpenRouterClient
func (*OpenRouterClient) Configured ¶
func (client *OpenRouterClient) Configured() bool
Configured reports whether the client has the credentials needed to call the OpenRouter API.
func (*OpenRouterClient) Model ¶ added in v0.0.8
func (client *OpenRouterClient) Model() string
func (*OpenRouterClient) Provider ¶ added in v0.0.8
func (client *OpenRouterClient) Provider() string
func (*OpenRouterClient) Transcribe ¶
func (client *OpenRouterClient) Transcribe(ctx context.Context, audio []byte, format string) (string, error)
Transcribe sends audio bytes to OpenRouter and returns the transcript text.
type Result ¶
type Result struct {
Metadata Metadata
Markdown string
Source TranscriptSource
Language string
CaptionKind CaptionKind
TranscriptionPolicy TranscriptionPolicy
STTProvider string
STTModel string
}
Result contains the extracted metadata and transcript markdown.
type TranscriptSource ¶
type TranscriptSource string
TranscriptSource identifies how the transcript was produced.
const ( // TranscriptSourceCaptions means YouTube captions were fetched directly. TranscriptSourceCaptions TranscriptSource = "captions" // TranscriptSourceSTT means audio was transcribed through an STT provider. TranscriptSourceSTT TranscriptSource = "stt" )
type TranscriptionPolicy ¶ added in v0.0.8
type TranscriptionPolicy string
TranscriptionPolicy controls whether captions or STT are used.
const ( TranscriptionPolicyCaptions TranscriptionPolicy = "captions" TranscriptionPolicyAuto TranscriptionPolicy = "auto" TranscriptionPolicySTT TranscriptionPolicy = "stt" )
func ParseTranscriptionPolicy ¶ added in v0.0.8
func ParseTranscriptionPolicy(value string) (TranscriptionPolicy, error)
ParseTranscriptionPolicy validates a transcription policy string.