SuperAPI AI Directory

read-youtube-transcript

Writing & research

View repository

Updated 10-16 08:43

About this skill

YouTube Subtitle Extraction Skill

Extract subtitles from a YouTube video and output a Chinese transcript.

Quick Start

python3 scripts/get_transcript.py "https://www.youtube.com/watch?v=VIDEO_ID"

Workflow

  1. Get the video link: Extract the YouTube URL from the user message
  2. Run the script: Execute scripts/get_transcript.py to extract subtitles
  3. Process the output:
    • If the subtitles are in Chinese: output directly
    • If the subtitles are in English: translate to Chinese before outputting
  4. Save the result: Save as a Markdown file according to the user's needs

Script parameters

Parameter Description Default value
url YouTube video link or ID Required
-f, --format Output format: text, markdown, json markdown
-t, --timestamps Include timestamps No
-l, --lang Preferred languages (comma-separated) zh,en
-o, --output Output file path stdout

Usage examples

Basic usage

python3 scripts/get_transcript.py "https://www.youtube.com/watch?v=dQw4w9WgXcQ"

Output with timestamps

python3 scripts/get_transcript.py -t "https://youtu.be/VIDEO_ID"

Save to file

python3 scripts/get_transcript.py -o output.md "https://www.youtube.com/watch?v=VIDEO_ID"

JSON format (for post-processing)

python3 scripts/get_transcript.py -f json "VIDEO_ID"

Supported URL formats

  • https://www.youtube.com/watch?v=VIDEO_ID
  • https://youtu.be/VIDEO_ID
  • https://www.youtube.com/embed/VIDEO_ID
  • Use the Video ID directly

Language priority

The script looks for subtitles in the following order:

  1. Simplified Chinese (zh-Hans)
  2. Traditional Chinese (zh-Hant)
  3. Chinese (zh)
  4. English (en)
  5. Auto-generated subtitles

Translation processing

If English subtitles are obtained, they need to be translated into Chinese:

  1. Run the script to obtain English subtitles
  2. Use Claude's built-in capabilities to translate into fluent Chinese
  3. Preserve the original structure and paragraph divisions

Error handling

Error Cause Solution
No captions available The video has no subtitles Inform the user that the video has no available subtitles
Cannot extract video ID Incorrect URL format Ask the user to provide a correct YouTube link
Network timeout Network issue Retry or check the network connection

Output format examples

Markdown format

# 视频标题

- **Video ID**: abc123
- **语言**: 中文(自动生成)
- **链接**: https://www.youtube.com/watch?v=abc123

---

## 文字稿

这是视频的第一段内容...

这是视频的第二段内容...