Fetch YouTube video and playlist transcripts from the command line
Project description
yt-transcript-cli
Fetch YouTube video and playlist transcripts from the command line.
Installation
Install from PyPI:
pip install yt-transcript-cli
Install from GitHub
pip install git+https://github.com/kirinmurphy/youtube-transcript-cli.git
Or install locally for development:
git clone https://github.com/kirinmurphy/youtube-transcript-cli.git
cd youtube-transcript-cli
pip install -e .
Usage
After installation, the yt-transcript-cli command is available.
Single video
yt-transcript-cli "https://www.youtube.com/watch?v=VIDEO_ID"
Multiple videos
yt-transcript-cli "URL1" "URL2" "URL3"
Playlist
yt-transcript-cli "https://www.youtube.com/playlist?list=PLAYLIST_ID"
Public and unlisted playlists are supported. Private playlists are not accessible.
From a file
yt-transcript-cli -f urls.txt
Where urls.txt contains one URL per line. Lines starting with # are ignored.
Interactive mode
yt-transcript-cli -i
Or just run with no arguments:
yt-transcript-cli
This opens a REPL where you can paste URLs one at a time, then press Enter on an empty line to process them all.
REPL commands
| Command | Description |
|---|---|
/help, /h |
Show help |
/status, /s |
Show pending URLs |
/clear, /c |
Clear pending URLs |
/process, /p |
Process pending URLs |
/quit, /q |
Exit |
Options
| Flag | Description | Default |
|---|---|---|
-o, --output-dir |
Output directory for transcript files | . (current directory) |
-l, --lang |
Language code (e.g., en, es) |
auto-detect |
-q, --quiet |
Suppress progress messages | off |
-d, --delay |
Seconds between requests (rate limiting) | 1.5 |
-f, --file |
Read URLs from a file | - |
-i, --interactive |
Force interactive REPL mode | - |
Supported URL formats
https://www.youtube.com/watch?v=VIDEO_IDhttps://youtu.be/VIDEO_IDhttps://youtube.com/shorts/VIDEO_IDhttps://youtube.com/embed/VIDEO_IDhttps://www.youtube.com/playlist?list=PLAYLIST_ID- Plain video ID (11 characters)
Behavior
- Transcripts are saved as
transcript_{VIDEO_ID}.txtin the output directory - Existing transcripts are skipped automatically (won't re-download)
- Playlists are expanded to individual videos
- A rate limit delay is applied between requests (configurable with
-d) - Output is a single continuous block of text (no line breaks between segments)
Use as a library
from yt_transcript import fetch_transcript, to_text, parse_youtube_url
video_id = parse_youtube_url("https://www.youtube.com/watch?v=VIDEO_ID")
segments = fetch_transcript(video_id)
text = to_text(segments)
Available functions
| Function | Description |
|---|---|
parse_youtube_url(url) |
Extract video ID from a YouTube URL |
fetch_transcript(video_id, lang=None) |
Fetch transcript segments |
to_text(segments) |
Convert segments to plain text |
is_playlist_url(url) |
Check if a URL contains a playlist |
fetch_playlist_video_ids(url) |
Get all video IDs from a playlist |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file yt_transcript_cli-0.1.2.tar.gz.
File metadata
- Download URL: yt_transcript_cli-0.1.2.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
842bbb50e725ad3fea79c436438f77e812bec93315f8b6a48a8f3c555bd35406
|
|
| MD5 |
917dbb409b5fdcf5886645307ef62977
|
|
| BLAKE2b-256 |
707b04273055127b170d5fb463096d6bd4769908149c6af9962a2e61967a2ed7
|
File details
Details for the file yt_transcript_cli-0.1.2-py3-none-any.whl.
File metadata
- Download URL: yt_transcript_cli-0.1.2-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32be3761cc9a58569ecc91c725fbcbd313068974ae1d5b010039e4129d3b97a8
|
|
| MD5 |
69c573d030442d561c3941b18714828a
|
|
| BLAKE2b-256 |
70bd1365b3df3e9cc7233c7c7b3410ae67e51e6f4f54a42803621c3ea66bc286
|