Skip to main content

CLI tool for extracting transcripts from YouTube videos, playlists, and channels

Project description

yt-transcriptss🎼

A Python CLI tool for extracting transcripts from YouTube videos, playlists, and channels.

Installation

pip install -e .

Or install dependencies directly:

pip install youtube-transcript-api yt-dlp

Usage

yt-transcripts [OPTIONS] SOURCE...

Sources

The tool accepts multiple source types:

  • Video URL: https://www.youtube.com/watch?v=VIDEO_ID
  • Video ID: dQw4w9WgXcQ
  • Channel URL: https://www.youtube.com/@ChannelName
  • Playlist URL: https://www.youtube.com/playlist?list=PLAYLIST_ID

Options

Option Description
-f, --format Output format: text, json, srt, vtt (default: text)
-l, --language Preferred language code(s), can be specified multiple times (default: en)
-o, --output Output file or directory (default: stdout)
--max-videos Maximum number of videos to process from channel/playlist
--list-only Only list videos without extracting transcripts
-v, --verbose Verbose output
-h, --help Show help message

Examples

Single Video

# By URL
yt-transcripts "https://www.youtube.com/watch?v=dQw4w9WgXcQ"

# By video ID
yt-transcripts dQw4w9WgXcQ

Multiple Videos

yt-transcripts VIDEO_ID1 VIDEO_ID2 VIDEO_ID3

Output Formats

# Plain text (default)
yt-transcripts VIDEO_ID -f text

# JSON with timestamps and metadata
yt-transcripts VIDEO_ID -f json

# SRT subtitles
yt-transcripts VIDEO_ID -f srt

# WebVTT subtitles
yt-transcripts VIDEO_ID -f vtt

Save to File

# Single file
yt-transcripts VIDEO_ID -o transcript.txt

# Multiple videos to separate files in a directory
yt-transcripts VIDEO_ID1 VIDEO_ID2 -o ./transcripts/

Channels

# List all videos from a channel
yt-transcripts "https://www.youtube.com/@anthropic-ai" --list-only

# Extract transcripts from first 10 videos
yt-transcripts "https://www.youtube.com/@anthropic-ai" --max-videos 10

# Save channel transcripts to directory as JSON
yt-transcripts "https://www.youtube.com/@anthropic-ai" --max-videos 5 -f json -o ./transcripts/

Playlists

# List videos in a playlist
yt-transcripts "https://www.youtube.com/playlist?list=PLrAXtmErZgOeiKm4sgNOknGvNjby9efdf" --list-only

# Extract all transcripts from playlist
yt-transcripts "https://www.youtube.com/playlist?list=PLrAXtmErZgOeiKm4sgNOknGvNjby9efdf"

Language Selection

# Prefer Spanish, fall back to English
yt-transcripts VIDEO_ID -l es -l en

# Prefer French
yt-transcripts VIDEO_ID -l fr

Output Formats

Text

Plain text with all segments joined together:

We're no strangers to love You know the rules and so do I...

JSON

Structured data with metadata and timestamps:

{
  "video_id": "dQw4w9WgXcQ",
  "language": "en",
  "is_generated": false,
  "segments": [
    {
      "text": "We're no strangers to love",
      "start": 18.64,
      "duration": 3.24
    }
  ]
}

SRT

Standard subtitle format:

1
00:00:18,640 --> 00:00:21,880
We're no strangers to love

2
00:00:22,640 --> 00:00:26,960
You know the rules and so do I

VTT

WebVTT subtitle format:

WEBVTT

00:00:18.640 --> 00:00:21.880
We're no strangers to love

00:00:22.640 --> 00:00:26.960
You know the rules and so do I

Error Handling

The tool gracefully handles common errors:

  • Transcripts disabled: Reports when a video has transcripts turned off
  • Video unavailable: Reports when a video is private or deleted
  • No transcript found: Reports when no transcript exists in the requested language

Errors are included in the output rather than stopping execution, so batch processing continues even if some videos fail.

Dependencies

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

yt_transcripts-0.1.0.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

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

yt_transcripts-0.1.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file yt_transcripts-0.1.0.tar.gz.

File metadata

  • Download URL: yt_transcripts-0.1.0.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.15

File hashes

Hashes for yt_transcripts-0.1.0.tar.gz
Algorithm Hash digest
SHA256 35b56ce8a039c76278500dab04fb447f119d15a035fd1673c4984a10ce0bd0f9
MD5 32aacc0e778195c71d20aa11f24b8a17
BLAKE2b-256 b2b0dfec1387128465c1ef18e3cd4dedb8f0b61e998723e7fc80d7df181b83a2

See more details on using hashes here.

File details

Details for the file yt_transcripts-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for yt_transcripts-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 84c35211a9e3d75a7e3c912ba9b533887df5b2b3de50e5dd22bb54896e3da622
MD5 c4d71d8be7e5a1d102066ed14e56ba0b
BLAKE2b-256 fdcbb7b2be1c24eb894271ed699b5c06cf6be3827ad6b8fa750303253e7ae2e9

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