yux-video-subtitle
Download subtitles/transcripts from video platforms. Triggers: "download subtitle", "extract subtitle", "video subtitle", "transcript", "字幕下载", "提取字幕", "视频字幕".
When & Why to Use This Skill
This Claude skill automates the extraction and processing of subtitles and transcripts from a wide range of video platforms including YouTube, Bilibili, Twitter/X, and TikTok. By leveraging the powerful yt-dlp engine, it handles complex tasks such as cookie-based authentication for restricted content, automatic language detection, and the conversion of raw subtitle formats (VTT/SRT) into clean, readable plain text. It is an essential tool for users looking to digitize video content for research, translation, or content repurposing.
Use Cases
- Content Repurposing: Quickly extract transcripts from YouTube or TikTok videos to transform video insights into blog posts, newsletters, or social media threads.
- Language Learning & Translation: Download bilingual subtitles from foreign language videos to create study materials or provide source text for translation workflows.
- Research and Archiving: Save text-based records of webinars, interviews, and news reports from various platforms into a searchable local knowledge base.
- Accessibility Improvement: Convert auto-generated video captions into formatted text files for users who prefer reading over watching or require text for screen readers.
- Data Preparation for AI: Extract clean text data from educational videos to feed into LLMs for summarization, analysis, or Q&A tasks.
| name | yux-video-subtitle |
|---|---|
| description | Download subtitles/transcripts from video platforms. Triggers: "download subtitle", "extract subtitle", "video subtitle", "transcript", "字幕下载", "提取字幕", "视频字幕". |
| allowed-tools | Read, Write, Glob, Grep, Bash(yt-dlp:*), Bash(which:*), Bash(ls:*), Bash(cat:*) |
Video Subtitle Download
Extract subtitles/transcripts from video URLs and save them as local text files.
Supported platforms: YouTube, Bilibili, Twitter/X, Vimeo, TikTok, and all other platforms supported by yt-dlp.
Input Video URL: $ARGUMENTS
Configuration
Before generating output, read .claude/yux-config.json:
- If
languageis set, output messages in that language - If file doesn't exist, detect from user input or default to English
Step 1: Verify Tool Availability
Check yt-dlp installation:
which yt-dlp- If
yt-dlpis found, proceed to Step 2. - If
yt-dlpis NOT found, notify user: "yt-dlp is not installed. Please install it first:brew install yt-dlporpip install yt-dlp" Then STOP execution.
- If
Step 2: Get Video Information
Get video title:
yt-dlp --get-title "[VIDEO_URL]"If this fails with authentication error, try with cookies:
yt-dlp --cookies-from-browser chrome --get-title "[VIDEO_URL]"If browser cookie extraction fails, ask user to specify their browser (firefox, safari, edge) and retry.
Store the video title for file naming (sanitize special characters).
Step 3: Download Subtitles
Attempt subtitle download with language priority (Chinese first, then English):
yt-dlp --write-auto-sub --write-sub --sub-lang zh-Hans,zh-Hant,zh,en --skip-download --sub-format vtt --output "<Video Title>.%(ext)s" "[VIDEO_URL]"- For platforms requiring authentication (YouTube, Bilibili, etc.), add cookies:
yt-dlp --cookies-from-browser chrome --write-auto-sub --write-sub --sub-lang zh-Hans,zh-Hant,zh,en --skip-download --sub-format vtt --output "<Video Title>.%(ext)s" "[VIDEO_URL]"
- For platforms requiring authentication (YouTube, Bilibili, etc.), add cookies:
Handle platform-specific cases:
- Bilibili: May require
--cookies-from-browserfor member-only videos - YouTube: Use
--write-auto-subfor auto-generated subtitles - Twitter/X: Subtitles may not be available for all videos
- Bilibili: May require
Verify download:
- Check if
.vttor.srtfile was created - If no subtitle file found, inform user that subtitles are not available for this video
- Check if
Step 4: Convert to Plain Text
Read the downloaded subtitle file (
.vttor.srt)Extract and clean content:
- Remove timing information
- Remove duplicate lines
- Remove formatting tags
- Keep only the actual transcript text
Format output:
- Each line:
[Timestamp] Text content - Or plain text without timestamps if user prefers
- Each line:
Step 5: Detect Language and Save
Detect source language:
- From subtitle filename: Check the downloaded file extension
.zh-Hans.vtt,.zh-Hant.vtt,.zh.vtt→zh.en.vtt,.en-US.vtt,.en-GB.vtt→en.ja.vtt→ja.ko.vtt→ko
- From content analysis (if filename doesn't indicate language):
- Count Chinese characters (Unicode range
\u4e00-\u9fff) - Calculate ratio: Chinese chars / Total chars
- If ratio > 0.3 →
zh - Otherwise →
en
- Count Chinese characters (Unicode range
- From subtitle filename: Check the downloaded file extension
Store the detected language code:
video_language(e.g.,zh,en)Save the transcript to:
<Video Title>.txtReport completion with language info:
- File path
- Language code:
[zh/en/ja/ko] - Language name (e.g., Chinese, English)
- Total number of lines
- File size
Error Handling
- No subtitles available: Inform user and suggest alternative (manual transcription or audio extraction)
- Authentication required: Guide user to set up cookies or login
- Network error: Suggest retry or check URL validity
- Unsupported platform: List supported platforms and suggest alternatives
Output Format
File saved: <Video Title>.txt
Language code: zh
Language: Chinese (auto-generated)
Lines: 245
Size: 12.5 KB
The language code (zh, en, etc.) will be used by the yux-video-summary skill for multi-language output generation.