Skip to main content

YouTube transcripts to RAG-ready volumes

Project description

ytrag

YouTube transcripts → RAG-ready volumes.

Download YouTube subtitles, clean them to markdown, 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

Full Pipeline (recommended)

Process an entire YouTube channel in one command:

ytrag all "https://youtube.com/@ChannelName"

This will:

  1. Download all available subtitles
  2. Clean VTT files to readable markdown
  3. Consolidate into LLM-ready volumes

Individual Commands

Run each step separately if needed:

# Download subtitles only
ytrag download "https://youtube.com/@ChannelName"

# Clean VTT files to markdown
ytrag clean

# Consolidate to volumes
ytrag consolidate

Command Options

# Specify languages (default: es,en)
ytrag all "https://..." --lang es,en,pt

# Custom output directory
ytrag all "https://..." --output ./my-transcripts

# Adjust transcripts per volume (default: 100)
ytrag all "https://..." --per-volume 50

# Check status of current directory
ytrag status

# Show version
ytrag --version

# Show all commands and options
ytrag --help

Programmatic Usage

You can also use ytrag as a Python library:

from pathlib import Path
from ytrag.downloader import Downloader
from ytrag.utils import create_subtitle_callback

# Setup output directory
output_dir = Path("./transcripts")

# Create callback to clean subtitles as they download
callback = create_subtitle_callback(output_dir, verbose=True)

# Initialize downloader
downloader = Downloader(output_dir, on_subtitle_downloaded=callback)

# Download subtitles
stats = downloader.download("https://youtube.com/@ChannelName", langs=["en", "es"])
print(f"Downloaded: {stats['downloaded']}, Errors: {stats['errors']}")

For consolidation:

from ytrag.consolidator import consolidate_all

# Consolidate cleaned transcripts into volumes
manifest = consolidate_all(
    base_dir=".",  # Directory containing _biblioteca/
    transcripts_per_volume=100
)
print(f"Processed channels: {list(manifest['channels'].keys())}")

Output Structure

After running ytrag all, your directory will look like:

./
├── ChannelName/                    # Raw VTT files
│   ├── 20230101_Video Title.en.vtt
│   └── ...
├── _biblioteca/                    # Cleaned markdown
│   └── ChannelName/
│       └── 20230101_Video Title [EN].md
├── _exports/                       # LLM-ready volumes
│   ├── ChannelName_Vol01.txt
│   ├── ChannelName_Vol02.txt
│   └── manifest.json
└── .ytrag_archive.txt              # Resume tracking

What Each Folder Contains

Folder Purpose
ChannelName/ Raw subtitle files (VTT format)
_biblioteca/ Individual cleaned transcripts (Markdown)
_exports/ Consolidated volumes ready for LLMs

Examples

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"

Process a Channel

ytrag all "https://youtube.com/@ChannelName"

Spanish-Only Transcripts

ytrag all "https://youtube.com/@ChannelName" --lang es

Features

  • Stream processing: Files are cleaned as they download
  • Adaptive rate limiting: Automatically handles YouTube rate limits
  • Resume support: Re-run to continue where you left off
  • Smart deduplication: Skips regional variants (en-US if en exists)
  • Subtitle priority: Prefers manual > auto-original > skips translated

Requirements

  • Python 3.10+

Troubleshooting

"No subtitles found"

Some videos don't have subtitles enabled. Try:

  • Using --lang with different language codes
  • Using auto-generated subtitles (these are downloaded by default)

Rate limiting errors

YouTube may rate-limit downloads. ytrag handles this automatically with exponential backoff, but for large channels you may need to wait or run again later.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ytrag-1.0.1.tar.gz (27.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ytrag-1.0.1-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

Details for the file ytrag-1.0.1.tar.gz.

File metadata

  • Download URL: ytrag-1.0.1.tar.gz
  • Upload date:
  • Size: 27.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for ytrag-1.0.1.tar.gz
Algorithm Hash digest
SHA256 6216b860257fbe64062cf7cc68c259596dba375e84039337159208872ad3c6e6
MD5 a5c2ac86bea3003f2c1938af08978c18
BLAKE2b-256 a4236d4bde9296d6009bf5b951ff4bc087fafd0a754a4851873a746fe3e5e390

See more details on using hashes here.

File details

Details for the file ytrag-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: ytrag-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 15.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for ytrag-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f716f7f1c94254b3290905311f60d2e007dd462f9fe626f0551944e2295e2612
MD5 f2128fbadd1c3bc64966c571924051b8
BLAKE2b-256 c384fa58e94149d4415b3c8b5ed4b68f80053bac8ab415683324e83c7c4f3147

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page