Skip to main content

yt-transcript-extractor

Extract YouTube video transcripts from the command line and save them in LLM-friendly formats (Markdown with frontmatter, JSON, TXT, and SRT).

Lightweight Python CLI for transcript extraction, subtitle generation, and downstream content workflows.

Features

  • CLI input supports full YouTube URLs or raw video IDs.
  • Output formats: markdown, json, txt, srt, or all.
  • Optional timestamped transcript output.
  • Language preference fallback via repeated --language options.
  • Structured metadata for downstream LLM/RAG pipelines.

Use Cases

  • Build subtitle files (.srt) from available captions.
  • Archive transcripts in structured Markdown and JSON.
  • Prepare source text for search, analytics, and summarization.
  • Feed normalized transcripts into RAG or ingestion pipelines.

Requirements

  • Python >=3.9
  • uv (recommended) or pip

Installation

# clone and enter repository
git clone https://github.com/alikhalajii/yt-transcript-extractor.git
cd yt-transcript-extractor

# create environment and install
uv venv
source .venv/bin/activate
uv pip install -e .

With development tools:

uv pip install -e ".[dev]"

Quick Start

# basic (markdown output)
yt-transcript https://www.youtube.com/watch?v=rfscVS0vtbw

# all formats, with timestamps
yt-transcript rfscVS0vtbw -f all -t

# subtitle file (SRT)
yt-transcript rfscVS0vtbw -f srt

# custom output directory
yt-transcript rfscVS0vtbw -o outputs

# language preference order
yt-transcript rfscVS0vtbw -l en -l es

CLI Reference

yt-transcript [OPTIONS] URL
Option Short Description Default
--output-dir -o Directory for output files transcripts
--format -f markdown, json, txt, srt, all markdown
--timestamps / --no-timestamps -t / -T Include timestamps in text output --no-timestamps
--language -l Preferred language code(s), repeatable en

Output

Markdown (.md)

Best for LLM ingestion. Includes YAML frontmatter:

video_id: rfscVS0vtbw
video_url: https://www.youtube.com/watch?v=rfscVS0vtbw
language: English
language_code: en
is_generated: false
is_translatable: true
extracted_at: 2026-03-08T13:35:26.502073
total_segments: 2935

JSON (.json)

Machine-friendly metadata and transcript segments with timing.

Text (.txt)

Plain transcript content, optionally timestamped.

SubRip (.srt)

Subtitle-ready output using the standard HH:MM:SS,mmm --> HH:MM:SS,mmm format.

Project Structure

yt-transcript-extractor/
├── examples/
│   ├── demo.py
│   └── examples.sh
├── youtube_transcript/
│   ├── __init__.py
│   ├── cli.py
│   ├── extractor.py
│   └── writer.py
├── .gitignore
├── LICENSE
├── pyproject.toml
└── README.md

Development

black youtube_transcript/
ruff check youtube_transcript/
pytest

Install a commit-time gate that mirrors CI checks:

uv pip install -e ".[dev]"
pre-commit install

This runs black --check, ruff check, mypy, and pytest before each commit.

Contributing

See CONTRIBUTING.md for development setup, local testing, and release procedures.

Troubleshooting

  • If captions are disabled by the video owner, transcript extraction will fail.
  • If a requested language does not exist, pass multiple -l values as fallback.
  • If yt-transcript is not found, ensure your virtual environment is activated.

License

This project is licensed under the MIT License. See LICENSE.

Metadata

Release files for yt-transcript-extractor 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for yt-transcript-extractor 0.1.0
File Size Uploaded
yt_transcript_extractor-0.1.0.tar.gz 11.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for yt-transcript-extractor 0.1.0
File Interpreter ABI Platform
yt_transcript_extractor-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 20.8 kB

Release files / yt_transcript_extractor-0.1.0.tar.gz

Download URL yt_transcript_extractor-0.1.0.tar.gz
Size 11.1 kB
Tags Source
SHA-256 checksum
How to use checksums
a64fc152b7b8d6cf119e90b20cba7ad9fa9a6581ece777ba02fe563f76837fc0
BLAKE2b-256 checksum
How to use checksums
cb654c0e2e8dad4f4b23acb133a80491193c5795e457d24faa34102c594b4e1e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 8, 2026.

Transparency log

Release files / yt_transcript_extractor-0.1.0-py3-none-any.whl

Download URL yt_transcript_extractor-0.1.0-py3-none-any.whl
Size 9.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a6d1b817519af785c2751d04d8b6e652e125e415a0718dee95180f01638a1823
BLAKE2b-256 checksum
How to use checksums
ae072e4fbb56bf555af47a74a9bdd1cb7d6bb35fae23d448fb4a2eec7a2b24da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 8, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page