Load YouTube Video Transcripts
LlamaIndex reader that fetches YouTube video transcripts into documents.
Why it matters
Ingest and process transcripts from YouTube videos to extract valuable textual information for further analysis or summarization.
Outcomes
What it gets done
Fetch transcripts from YouTube video URLs.
Support multiple YouTube URL formats.
Extract text data for integration with LlamaIndex.
Enable programmatic URL validation.
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/li-reader-readers-youtube-transcript | bash Overview
Youtube Transcript Loader
The YouTube Transcript Loader fetches video transcripts via the youtube_transcript_api package, given a list of YouTube links, and includes a helper to check whether a URL is a supported YouTube format. Use it when you need YouTube video transcripts loaded into LlamaIndex. It supports three specific YouTube URL formats: watch, embed, and youtu.be links.
What it does
The YouTube Transcript Loader fetches the text transcript of YouTube videos using the youtube_transcript_api Python package. You pass an array of YouTube links to load_data, and it returns each video's transcript as a document.
When to use - and when NOT to
Use it when you need YouTube video transcripts pulled into LlamaIndex documents. It supports three URL formats -- youtube.com/watch?v={video_id}, youtube.com/embed?v={video_id} (each with or without www.), and youtu.be/{video_id} (never with www.) -- so it is not usable with other video-hosting URLs or unsupported YouTube link formats.
Inputs and outputs
Install with:
pip install llama-hub-youtube-transcript
pip install llama-index-readers-youtube-transcript
You will also need youtube_transcript_api: pip install youtube_transcript_api.
Load transcripts by passing a list of YouTube links:
from llama_index.readers.youtube_transcript import YoutubeTranscriptReader
loader = YoutubeTranscriptReader()
documents = loader.load_data(
ytlinks=["https://www.youtube.com/watch?v=i3OYlaoj-BM"]
)
To check whether a URL is a supported YouTube link before passing it in, use the is_youtube_video utility:
from llama_index.readers.youtube_transcript.utils import is_youtube_video
is_youtube_video("https://youtube.com/watch?v=j83jrh2") # => True
is_youtube_video("https://vimeo.com/272134160") # => False
Who it's for
Developers building LlamaIndex pipelines that need YouTube video transcripts loaded as documents.
Source README
Youtube Transcript Loader
pip install llama-hub-youtube-transcript
pip install llama-index-readers-youtube-transcript
This loader fetches the text transcript of Youtube videos using the youtube_transcript_api Python package.
Usage
To use this loader, you will need to first pip install youtube_transcript_api.
Then, simply pass an array of YouTube links into load_data:
from llama_index.readers.youtube_transcript import YoutubeTranscriptReader
loader = YoutubeTranscriptReader()
documents = loader.load_data(
ytlinks=["https://www.youtube.com/watch?v=i3OYlaoj-BM"]
)
Supported URL formats: + youtube.com/watch?v={video_id} (with or without 'www.') + youtube.com/embed?v={video_id} (with or without 'www.') + youtu.be/{video_id} (never includes www subdomain)
To programmatically check if a URL is supported:
from llama_index.readers.youtube_transcript.utils import is_youtube_video
is_youtube_video("https://youtube.com/watch?v=j83jrh2") # => True
is_youtube_video("https://vimeo.com/272134160") # => False
This loader is designed to be used as a way to load data into LlamaIndex.
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.