diff --git a/README.md b/README.md index 1b299fa8..c58749f0 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,12 @@ Fabric is graciously supported by… ## Updates > [!NOTE] +>June 11, 2025 +> +> - Fabric's YouTube transcription now needs `yt-dlp` to be installed. Make sure to install the latest +> version (2025.06.09 as of this note). The YouTube API key is only needed for comments (the `--comments` flag) +> and metadata extraction (the `--metadata` flag). +> > May 22, 2025 > > - Fabric now supports Anthropic's Claude 4. Read the [blog post from Anthropic](https://www.anthropic.com/news/claude-4). diff --git a/plugins/tools/youtube/youtube.go b/plugins/tools/youtube/youtube.go index 2aff111b..6035ea68 100644 --- a/plugins/tools/youtube/youtube.go +++ b/plugins/tools/youtube/youtube.go @@ -1,7 +1,12 @@ // Package youtube provides YouTube video transcript and comment extraction functionality. -// This implementation relies on yt-dlp for reliable transcript extraction, which must be -// installed separately. The old YouTube API scraping methods have been removed due to -// YouTube's frequent changes and rate limiting. +// +// 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. package youtube import ( @@ -30,7 +35,7 @@ func NewYouTube() (ret *YouTube) { ret.PluginBase = &plugins.PluginBase{ Name: label, - SetupDescription: label + " - to grab video transcripts and comments", + SetupDescription: label + " - to grab video transcripts (via yt-dlp) and comments/metadata (via YouTube API)", EnvNamePrefix: plugins.BuildEnvVariablePrefix(label), } @@ -49,6 +54,10 @@ type YouTube struct { func (o *YouTube) initService() (err error) { if o.service == nil { + if o.ApiKey.Value == "" { + err = fmt.Errorf("YouTube API key required for comments and metadata. Run 'fabric --setup' to configure") + return + } o.normalizeRegex = regexp.MustCompile(`[^a-zA-Z0-9]+`) ctx := context.Background() o.service, err = youtube.NewService(ctx, option.WithAPIKey(o.ApiKey.Value)) @@ -57,10 +66,6 @@ func (o *YouTube) initService() (err error) { } func (o *YouTube) GetVideoOrPlaylistId(url string) (videoId string, playlistId string, err error) { - if err = o.initService(); err != nil { - return - } - // Video ID pattern videoPattern := `(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:live\/|[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|(?:s(?:horts)\/)|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]*)` videoRe := regexp.MustCompile(videoPattern)