An open API service indexing awesome lists of open source software.

https://github.com/maxbeizer/gh-yt2md

YouTube to Markdown - gh CLI extension
https://github.com/maxbeizer/gh-yt2md

cli gh gh-extension youtube

Last synced: 2 months ago
JSON representation

YouTube to Markdown - gh CLI extension

Awesome Lists containing this project

README

          

# gh-yt2md

A `gh` CLI extension that extracts YouTube video transcripts into markdown, optionally processing them with GitHub Models. Single Go binary, zero runtime dependencies.

![demo](demo.gif)

## Installation

```bash
gh extension install maxbeizer/gh-yt2md
```

## Usage

```bash
# Pass a URL or video ID — it just works
gh yt2md "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
gh yt2md "https://youtu.be/dQw4w9WgXcQ"
gh yt2md dQw4w9WgXcQ

# Save to a file
gh yt2md dQw4w9WgXcQ -o transcript.md

# Process with GitHub Models (requires GITHUB_TOKEN)
gh yt2md dQw4w9WgXcQ -p "Summarize in 3 bullet points" -m "openai/gpt-4.1"
```

### Output

By default, output goes to **stdout** — pipe it wherever you like:

```bash
# Pipe to clipboard
gh yt2md dQw4w9WgXcQ | pbcopy

# Pipe to a file
gh yt2md dQw4w9WgXcQ > notes.md
```

Status messages go to stderr, so piping works cleanly.

### Flags

| Flag | Short | Description |
|------|-------|-------------|
| `--output` | `-o` | Output file path (default: stdout) |
| `--prompt` | `-p` | Process transcript with GitHub Models using this prompt |
| `--model` | `-m` | GitHub Models model ID (default: `openai/gpt-4o-mini`) |

### GitHub Models Integration

To use `--prompt`, set the `GITHUB_TOKEN` environment variable:

```bash
export GITHUB_TOKEN=ghp_...
gh yt2md dQw4w9WgXcQ -p "Translate to Spanish" -m "openai/gpt-4.1"
```

## How It Works

1. Calls YouTube's Innertube API to get video metadata and caption track URLs
2. Fetches the caption track XML and parses transcript segments
3. Renders as markdown with video metadata header
4. Optionally sends the transcript text to GitHub Models for AI processing

## Development

```bash
go build -o gh-yt2md .
./gh-yt2md dQw4w9WgXcQ
```

## License

MIT