transcript

package
v0.0.0-...-b434367 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConcatenateTranscript

func ConcatenateTranscript(entries []TranscriptEntry) string

ConcatenateTranscript combines all transcript entries into a single string

func ExtractVideoID

func ExtractVideoID(input string) string

ExtractVideoID extracts the video ID from various YouTube URL formats or returns the ID directly. It supports full youtube.com URLs, short youtu.be URLs, and direct video IDs.

Types

type Client

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

Client represents the YouTube Transcript API client

func NewClient

func NewClient(options ...ClientOption) *Client

NewClient creates a new YouTube Transcript API client

func (*Client) FetchMultipleTranscripts

func (c *Client) FetchMultipleTranscripts(videoIDs []string) map[string][]TranscriptEntry

FetchMultipleTranscripts fetches transcripts for multiple video IDs concurrently

func (*Client) GetTranscript

func (c *Client) GetTranscript(videoID string) ([]TranscriptEntry, error)

GetTranscript fetches the transcript for a given video ID, preferring English if available

func (*Client) GetTranscriptString

func (c *Client) GetTranscriptString(videoID string) (string, error)

GetTranscriptString fetches the transcript and returns it as a single string

func (*Client) GetTranscriptWithLanguage

func (c *Client) GetTranscriptWithLanguage(videoID string, languageCode string) ([]TranscriptEntry, error)

GetTranscriptWithLanguage fetches the transcript for a given video ID in the specified language code If the specified language is not available, it returns an error

func (*Client) ListAvailableTranscripts

func (c *Client) ListAvailableTranscripts(videoID string) ([]Transcript, error)

ListAvailableTranscripts returns a list of available transcript languages for a video

type ClientOption

type ClientOption func(*Client)

ClientOption defines a function to configure the Client

func WithProxy

func WithProxy(proxyURLStr string) ClientOption

WithProxy sets a proxy for the HTTP client

type ErrNoTranscriptFound

type ErrNoTranscriptFound struct {
	VideoID string
}

func (ErrNoTranscriptFound) Error

func (e ErrNoTranscriptFound) Error() string

type ErrTranscriptsDisabled

type ErrTranscriptsDisabled struct {
	VideoID string
}

func (ErrTranscriptsDisabled) Error

func (e ErrTranscriptsDisabled) Error() string

type ErrVideoUnavailable

type ErrVideoUnavailable struct {
	VideoID string
}

Error types

func (ErrVideoUnavailable) Error

func (e ErrVideoUnavailable) Error() string

type Transcript

type Transcript struct {
	BaseURL      string
	LanguageCode string
	Language     string
	IsGenerated  bool
}

Transcript represents a single transcript

type TranscriptEntry

type TranscriptEntry struct {
	Text     string
	Start    float64
	Duration float64
}

TranscriptEntry represents a single entry in the transcript

Jump to

Keyboard shortcuts

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