ytrag
YouTube transcripts → RAG-ready volumes.
Download YouTube subtitles and consolidate them into LLM-ready volumes.
Quick Start
# Install from PyPI
pipx install ytrag
# Download and process a YouTube channel
ytrag all "https://youtube.com/@ChannelName"
That's it! The transcripts will be cleaned and organized into volumes ready for use with LLMs.
Installation
With pipx (recommended)
pipx install ytrag
With pip
pip install ytrag
From Source
git clone https://github.com/chakkyy/ytrag.git
cd ytrag
pip install .
Usage
# Process a YouTube channel
ytrag all "https://youtube.com/@ChannelName"
# Process a single video
ytrag all "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
# Process a playlist
ytrag all "https://www.youtube.com/playlist?list=PLxxxxxxx"
Options
# Specify languages (default: auto-detect from video)
ytrag all "https://..." --lang es,en,pt
# Custom output directory
ytrag all "https://..." --output ./my-transcripts
# Target a source limit for NotebookLM (default: 50, Plus can use 100)
ytrag all "https://..." --target-volumes 100
# Advanced override: fixed transcripts per volume
ytrag all "https://..." --per-volume 50
# Prefer a language for download and deduplication
ytrag all "https://..." --lang es
# Rebuild outputs from an existing folder of .vtt subtitle files
ytrag rebuild "./ChannelName" "Channel Name" --target-volumes 100
# Slow down large channel downloads to avoid YouTube rate limits
ytrag all "https://..." --sleep-interval 15 --max-sleep-interval 30
# Check status of current directory
ytrag status
# Show version
ytrag --version
Output Structure
After running ytrag all, your directory will look like:
./
└── ytrag-ChannelName/
├── raw-subtitles/ # Downloaded .vtt subtitle files
├── clean-transcripts/ # One cleaned .md transcript per video
├── rag-volumes/ # NotebookLM/RAG-ready volumes only
│ ├── ChannelName_Vol01.txt
│ └── ChannelName_Vol02.txt
├── manifest.json # Metadata
└── .ytrag_archive # Resume tracking
Each volume contains cleaned, consolidated transcripts ready for use with LLMs and RAG systems.
raw-subtitles/ is only created when --keep-raw is used. By default ytrag keeps the cleaned transcripts and RAG-ready volumes.
Features
- Simple: One command does everything
- Auto language detection: Defaults to video's original language
- Resume support: Re-run to continue where you left off
- Clear progress: Shows current/total videos and ETA while downloading large channels
- Accurate channel counts: Channel root URLs automatically target the Videos tab
- NotebookLM-friendly volumes: Smaller default volumes and a dedicated
rag-volumesfolder - Citable source markers: Repeats video/date markers throughout transcripts so NotebookLM hovers show useful context
- Language-aware deduplication: Honors
--lang, otherwise prefers the majority subtitle language - Smart deduplication: Skips regional variants (en-US if en exists)
- Adaptive rate limiting: Automatically handles YouTube rate limits
- Clean output: No intermediate files, just the volumes you need
Requirements
- Python 3.10+
Troubleshooting
"No subtitles found"
Some videos don't have subtitles enabled. Try:
- Using
--langwith different language codes - Auto-generated subtitles are downloaded by default
Rate limiting errors
YouTube may rate-limit large channel downloads. ytrag uses conservative delays by default and retries extractor failures with exponential backoff. If YouTube still rate-limits the session, failed videos are not added to .ytrag_archive; run the same command again later and ytrag will retry the missing videos.
Useful controls:
ytrag all "https://..." \
--sleep-interval 15 \
--max-sleep-interval 30 \
--stop-after-errors 3
License
MIT
Metadata
Release files for ytrag 2.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ytrag-2.3.0.tar.gz | 28.9 kB | Without provenance | Details for ytrag-2.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ytrag-2.3.0-py3-none-any.whl | Python 3 | none | any | Details for ytrag-2.3.0-py3-none-any.whl |
Total release size: 46.3 kB
Release files / ytrag-2.3.0.tar.gz
| Download URL | ytrag-2.3.0.tar.gz |
|---|---|
| Size | 28.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
753fb5e97d370d15eb0457f3282a71ccd14b53b9dcd6425ab00e996562036c7e
|
|
BLAKE2b-256 checksum How to use checksums |
fdc8e2719c22903b6ad851f32ea264f1de08651d51c663f8da8ba1763f614749
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.15
|
Release files / ytrag-2.3.0-py3-none-any.whl
| Download URL | ytrag-2.3.0-py3-none-any.whl |
|---|---|
| Size | 17.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fa95db1f001b213908beb45c551350a37c9d34fe5c650f7a74dc257193263fb5
|
|
BLAKE2b-256 checksum How to use checksums |
d2eeab360aa07aefc0346e37eb3a80ccd22bf8ca27403eead3bd9ffbf6b9cbc4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.15
|
Security for ytrag 2.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.