# ytx
Extract YouTube transcripts from the terminal. Pipe-friendly, no API key needed.
## Why ytx?
- **Stdout by default** -- transcripts go straight to your terminal, ready to pipe anywhere
- **No API key, no setup** -- scrapes what it needs from the video page automatically
- **Built for LLM workflows** -- feed any YouTube video into `llm`, `fabric`, `mods`, or your own tools in one command
## Install
```bash
cargo install ytx-cli
```
Or build from source:
```bash
git clone https://github.com/koguchic/ytx.git
cd ytx && cargo install --path .
```
## Quick Start
```bash
ytx dQw4w9WgXcQ # bare video ID
ytx https://youtu.be/dQw4w9WgXcQ # short URL
ytx https://youtube.com/watch?v=... # full URL
ytx dQw4w9WgXcQ -t # with timestamps
ytx dQw4w9WgXcQ -l ja # Japanese captions
```
## Pipe It Anywhere
This is where `ytx` shines. It's a Unix building block -- grab a transcript and send it wherever you want.
```bash
# Search a lecture for a specific concept
# Summarize a video with an LLM
# Extract action items with fabric
# Get a word count
# Save to a file
ytx https://youtube.com/watch?v=... > transcript.txt
# Copy to clipboard (macOS)
# Translate via LLM
# Timestamped transcript to file
ytx https://youtube.com/watch?v=... -t -o notes.txt
```
## Options
| `-t, --timestamps` | Prepend `[MM:SS]` or `[HH:MM:SS]` timestamps | off |
| `-l, --lang <CODE>` | Caption language code | `en` |
| `-o, --output <FILE>` | Write to file instead of stdout | stdout |
## How It Works
1. Fetches the YouTube video page and extracts the InnerTube API key
2. Calls the InnerTube player API (ANDROID client) to get caption URLs -- no PoToken needed
3. Fetches and parses the caption XML (supports both srv3 and legacy formats)
No API key required. No browser automation. Just HTTP requests.
## Supported URL Formats
- `https://www.youtube.com/watch?v=VIDEO_ID`
- `https://youtu.be/VIDEO_ID`
- `https://www.youtube.com/shorts/VIDEO_ID`
- Bare 11-character video IDs
## License
MIT