Grab the caption track of a YouTube video straight to text. No video download, no API key, no Whisper run. The captions already exist on YouTube's servers, this just fetches them.
v1.1 - a simple, quick wrapper. The heavy lifting is done by the excellent youtube-transcript-api package. This wraps it into a single-file tool with URL parsing and output shaped for the way I actually use transcripts: feeding them to LLMs.
If you work with AI, the transcript is usually what you want, not the video. The official YouTube Data API can't fetch captions for videos you don't own, and downloading audio to run Whisper on a video that already has captions is a sledgehammer. This gets you the text in about a second.
Either install it as a command:
pipx install git+https://github.com/Rendeverance/yt-transcript
Or just take yt_transcript.py and run it. It's one file with one dependency:
pip install youtube-transcript-api
python yt_transcript.py <url_or_id>
Both work. The rest of this README uses the installed command.
yt-transcript <url_or_id> [-o PATH] [--plain | --timestamps]
Accepts a full URL, a share link, a shorts/embed/live link, or a bare 11-character video id.
yt-transcript https://youtu.be/8jPQjjsBbIc # -> transcripts/8jPQjjsBbIc.txt
yt-transcript 8jPQjjsBbIc -o talk.txt # somewhere else
yt-transcript 8jPQjjsBbIc -o - | llm "summarise" # straight down a pipe
-o - writes the transcript to stdout with no file header, so it pipes cleanly. The segment and word counts go to stderr and stay out of the pipe.
Default is the transcript text on its own, because that is what goes into a context window.
| flag | what you get |
|---|---|
--plain (default) |
the whole transcript as one lump of text |
--timestamps |
one line per segment, prefixed [hh:mm:ss] |
Only ask for timestamps when you actually want to find your place in the video. They cost about 20% more tokens for the same words, measured on a 15 minute talk: 12.4 kB plain, 14.9 kB timestamped.
The underlying package makes the same requests your browser makes when you turn on captions. No official API is involved, which is why no key is needed. Worth knowing: that route is unofficial, and heavy automated use from datacenter IPs tends to get blocked by YouTube. For personal desktop use it just works.
MIT