youtube

package
v1.4.310 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2025 License: MIT Imports: 17 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 provides YouTube video transcript and comment extraction functionality.

Requirements: - yt-dlp: Required for transcript extraction (must be installed separately) - YouTube API key: Optional, only needed for comments and metadata extraction

The implementation uses yt-dlp for reliable transcript extraction and the YouTube API for comments/metadata. Old YouTube scraping methods have been removed due to frequent changes and rate limiting.

Index

Constants

View Source
const TimeGapForRepeats = 10 // seconds

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	Duration                 bool
	Transcript               bool
	TranscriptWithTimestamps bool
	Comments                 bool
	Lang                     string
	Metadata                 bool
}

type VideoInfo

type VideoInfo struct {
	Transcript string         `json:"transcript"`
	Duration   int            `json:"duration"`
	Comments   []string       `json:"comments"`
	Metadata   *VideoMetadata `json:"metadata,omitempty"`
}

type VideoMeta

type VideoMeta struct {
	Id              string
	Title           string
	TitleNormalized string
}

type VideoMetadata

type VideoMetadata struct {
	Id           string   `json:"id"`
	Title        string   `json:"title"`
	Description  string   `json:"description"`
	PublishedAt  string   `json:"publishedAt"`
	ChannelId    string   `json:"channelId"`
	ChannelTitle string   `json:"channelTitle"`
	CategoryId   string   `json:"categoryId"`
	Tags         []string `json:"tags"`
	ViewCount    uint64   `json:"viewCount"`
	LikeCount    uint64   `json:"likeCount"`
}

type YouTube

type YouTube struct {
	*plugins.PluginBase
	ApiKey *plugins.SetupQuestion
	// contains filtered or unexported fields
}

func NewYouTube

func NewYouTube() (ret *YouTube)

func (*YouTube) FetchAndPrintPlaylist

func (o *YouTube) FetchAndPrintPlaylist(playlistID string) (err error)

func (*YouTube) FetchAndSavePlaylist

func (o *YouTube) FetchAndSavePlaylist(playlistID, filename string) (err error)

FetchAndSavePlaylist fetches all videos in a playlist and saves them to a CSV file.

func (*YouTube) FetchPlaylistVideos

func (o *YouTube) FetchPlaylistVideos(playlistID string) (ret []*VideoMeta, err error)

FetchPlaylistVideos fetches all videos from a YouTube playlist.

func (*YouTube) GetVideoOrPlaylistId

func (o *YouTube) GetVideoOrPlaylistId(url string) (videoId string, playlistId string, err error)

func (*YouTube) Grab

func (o *YouTube) Grab(url string, options *Options) (ret *VideoInfo, err error)

func (*YouTube) GrabByFlags

func (o *YouTube) GrabByFlags() (ret *VideoInfo, err error)

func (*YouTube) GrabComments

func (o *YouTube) GrabComments(videoId string) (ret []string, err error)

func (*YouTube) GrabDuration

func (o *YouTube) GrabDuration(videoId string) (ret int, err error)

func (*YouTube) GrabDurationForUrl

func (o *YouTube) GrabDurationForUrl(url string) (ret int, err error)

func (*YouTube) GrabMetadata

func (o *YouTube) GrabMetadata(videoId string) (metadata *VideoMetadata, err error)

func (*YouTube) GrabTranscript

func (o *YouTube) GrabTranscript(videoId string, language string) (ret string, err error)

func (*YouTube) GrabTranscriptForUrl

func (o *YouTube) GrabTranscriptForUrl(url string, language string) (ret string, err error)

func (*YouTube) GrabTranscriptWithArgs added in v1.4.278

func (o *YouTube) GrabTranscriptWithArgs(videoId string, language string, additionalArgs string) (ret string, err error)

func (*YouTube) GrabTranscriptWithTimestamps

func (o *YouTube) GrabTranscriptWithTimestamps(videoId string, language string) (ret string, err error)

func (*YouTube) GrabTranscriptWithTimestampsWithArgs added in v1.4.278

func (o *YouTube) GrabTranscriptWithTimestampsWithArgs(videoId string, language string, additionalArgs string) (ret string, err error)

func (*YouTube) SaveVideosToCSV

func (o *YouTube) SaveVideosToCSV(filename string, videos []*VideoMeta) (err error)

SaveVideosToCSV saves the list of videos to a CSV file.

Jump to

Keyboard shortcuts

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