SuperAPI AI Directory

youtube-transcript-cn

General & other

View repository

Updated 10-16 01:34

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 into 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 (convenient 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 handling

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 division

Error handling

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

Output format example

Markdown format

# 视频标题

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

---

## 文字稿

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

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