A tool to generate YouTube video summaries with LlmaIndex
The project was named
yt-summaryinitially but PyPI rejected it for being too similar to an existing project. Hence it's renamed toyt-plsfor the CLI tool (YouTube please)
pip install yt-plsIf you want to use the Gemini and/or Claude models, you need to install the optional dependencies:
pip install "yt-pls[google]"
pip install "yt-pls[anthropic]"
# or
pip install "yt-pls[all]"You can install the package globally with pipx or uvx:
pipx install yt-plsuvx run yt-plsInstall uv and run:
git clone https://github.com/nelnn/yt-summary.git
cd yt-summary
make install
source .venv/bin/activateExport your API key(s) as an environment variable:
export OPENAI_API_KEY="sk-..."
export GOOGLE_API_KEY="..."
export ANTHROPIC_API_KEY="..."Then execute
yt-pls [url/video_id]You can specify the LLM provider and model:
yt-pls --provider openai --model gpt-5-mini-2025-08-07 [url/video_id]You can also specify the summariser type:
yt-pls --summariser refined [url/video_id]To save the output to a file, for example in markdown:
yt-pls [url/video_id] > summary.mdYou can also use yt-summary as a library:
from yt_summary.run import get_youtube_summary
summary = await get_youtube_summary("https://www.youtube.com/watch?v=abc123")Remember to export your LLM API key as an environment variable before running
the function. Alternatively, you can save them in a .env file in your project
root directory.
To fetch the transcript and metadata:
from yt_summary.extractors import TranscriptExtractor
url = "url or video id"
transcript_extractor = TranscriptExtractor()
transcript_raw = await transcript_extractor.fetch(url)This will return a Pydantic model YoutubeTranscriptRaw which looks like:
YoutubeTranscriptRaw(
metadata=YoutubeMetadata(
video_id="abc123",
title="Video Title",
author="Author Name",
channel_id="channel123",
video_url="https://www.youtube.com/watch?v=abc123",
channel_url="https://www.youtube.com/channel/channel123",
thumbnail_url="https://i.ytimg.com/vi/abc123/hqdefault.jpg",
is_generated=True,
language="English (auto-generated)",
language_code="en",
),
text="[00:00 (0s)] First sentence. Second sentence. [00:10 (10s)] Third sentence...",
)Note: The extractor is just a wrapper around youtube-transcript-api which you can pass the same parameters to
fetchas you would toYouTubeTranscriptApi.fetchbut here we stitch the transcript snippets into a single string with timestamps embedded in the text. You can also pass the proxy settings toTranscriptExtractoras you would toYouTubeTranscriptApi.
There are currently two summariser implementations: CompactSummariser and
RefineSummariser.
CompactSummariser lists metadata, high level summary and
Q&A with timestamps. It utilises the DocumentSummaryIndex from LLamaIndex.
RefineSummariser achieves the same by chunking the transcript to generate
summaries for each chunk before consolidating them by making multiple calls to
the LLM asynchronously. Be aware of the rate limits of your chosen LLM
provider.
For example, to generate summary with CompactSummariser:
from yt_summary.extractors import TranscriptExtractor
from yt_summary.schemas import LLMModel, LLMProvidersEnum
from yt_summary.summarisers import CompactSummariser, RefinedSummariser
transcript_extractor = TranscriptExtractor()
transcript_raw = await transcript_extractor.fetch(url)
summariser = CompactSummariser(
llm=LLMModel(
provider=LLMProvidersEnum.OPENAI,
model="gpt-5-mini-2025-08-07",
)
)
summary = await summariser.summarise(transcript)The repository is under development, expect breaking changes. Sugguestions and contributions are welcome!