A CLI tool to extract and save YouTube video transcriptions with metadata
Project description
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, orall. - Optional timestamped transcript output.
- Language preference fallback via repeated
--languageoptions. - 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) orpip
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
-lvalues as fallback. - If
yt-transcriptis not found, ensure your virtual environment is activated.
License
This project is licensed under the MIT License. See LICENSE.
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_extractor-0.1.0.tar.gz.
File metadata
- Download URL: yt_transcript_extractor-0.1.0.tar.gz
- Upload date:
- Size: 11.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a64fc152b7b8d6cf119e90b20cba7ad9fa9a6581ece777ba02fe563f76837fc0
|
|
| MD5 |
904c6d6fa80dfba6ac6a7e05eca07247
|
|
| BLAKE2b-256 |
cb654c0e2e8dad4f4b23acb133a80491193c5795e457d24faa34102c594b4e1e
|
Provenance
The following attestation bundles were made for yt_transcript_extractor-0.1.0.tar.gz:
Publisher:
publish.yml on alikhalajii/yt-transcript-extractor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
yt_transcript_extractor-0.1.0.tar.gz -
Subject digest:
a64fc152b7b8d6cf119e90b20cba7ad9fa9a6581ece777ba02fe563f76837fc0 - Sigstore transparency entry: 1059810887
- Sigstore integration time:
-
Permalink:
alikhalajii/yt-transcript-extractor@b1d44a2706152186ab44ed64dbdd4dad654dd17f -
Branch / Tag:
refs/heads/master - Owner: https://github.com/alikhalajii
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b1d44a2706152186ab44ed64dbdd4dad654dd17f -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file yt_transcript_extractor-0.1.0-py3-none-any.whl.
File metadata
- Download URL: yt_transcript_extractor-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a6d1b817519af785c2751d04d8b6e652e125e415a0718dee95180f01638a1823
|
|
| MD5 |
c4cab5e80b813e6a8ac4b1a312574182
|
|
| BLAKE2b-256 |
ae072e4fbb56bf555af47a74a9bdd1cb7d6bb35fae23d448fb4a2eec7a2b24da
|
Provenance
The following attestation bundles were made for yt_transcript_extractor-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on alikhalajii/yt-transcript-extractor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
yt_transcript_extractor-0.1.0-py3-none-any.whl -
Subject digest:
a6d1b817519af785c2751d04d8b6e652e125e415a0718dee95180f01638a1823 - Sigstore transparency entry: 1059810893
- Sigstore integration time:
-
Permalink:
alikhalajii/yt-transcript-extractor@b1d44a2706152186ab44ed64dbdd4dad654dd17f -
Branch / Tag:
refs/heads/master - Owner: https://github.com/alikhalajii
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b1d44a2706152186ab44ed64dbdd4dad654dd17f -
Trigger Event:
workflow_dispatch
-
Statement type: