AgentSkillsCN

youtube-subtitle-extractor

根据提供的 YouTube 视频 URL 提取字幕与转录文本。当您需要处理 YouTube 视频内容、生成字幕、提取文本以供 LLM 分析、进行内容再利用,或为视频剪辑创建 SRT 文件时,此技能将助您事半功倍。

SKILL.md
--- frontmatter
name: youtube-subtitle-extractor
description: Extract subtitles and transcripts from YouTube videos given a URL. Use when working with YouTube video content, generating captions, extracting text for LLM analysis, content repurposing, or creating SRT files for video editing.

YouTube Subtitle Extractor

Extract subtitles/transcripts from YouTube videos in multiple formats.

Quick Start

Run the extraction script:

bash
python3 scripts/extract_subtitles.py "<youtube_url>" [options]

Options

FlagDescription
--format, -fOutput format: text, srt, json (default: text)
--lang, -lPreferred language code (e.g., en, vi)
--translate-to, -tTranslate to target language
--output, -oSave to file instead of stdout

Examples

bash
# Plain text (for LLM analysis)
python3 scripts/extract_subtitles.py "https://youtu.be/VIDEO_ID"

# SRT format (for video editors)
python3 scripts/extract_subtitles.py "https://youtu.be/VIDEO_ID" -f srt -o subtitles.srt

# JSON format (for data processing)
python3 scripts/extract_subtitles.py "https://youtu.be/VIDEO_ID" -f json

# Vietnamese transcript
python3 scripts/extract_subtitles.py "https://youtu.be/VIDEO_ID" -l vi

# Translate to Vietnamese
python3 scripts/extract_subtitles.py "https://youtu.be/VIDEO_ID" --translate-to vi

Supported URL Formats

  • https://www.youtube.com/watch?v=VIDEO_ID
  • https://youtu.be/VIDEO_ID
  • https://www.youtube.com/embed/VIDEO_ID
  • Direct video ID

Output Formats

FormatUse Case
textLLM analysis, content repurposing
srtVideo editing, subtitling
jsonData processing, custom applications

Requirements

bash
pip3 install youtube-transcript-api

Limitations

  • Requires video to have captions enabled (manual or auto-generated)
  • Does not work on private or age-restricted videos
  • Bulk extraction may trigger rate limiting