This skill extracts and processes subtitles from YouTube videos.
Priority Order
1. yt-dlp 설치 확인
2. 사용 가능한 자막 목록 확인
3. 수동 자막 우선 시도
4. 자동 생성 자막 폴백
5. 최후 수단: Whisper 변환
Requirements
# macOS
brew install yt-dlp
Linux
sudo apt install yt-dlp
Universalpip install yt-dlp
## Workflow
### Step 1: 자막 목록 확인
```bash
yt-dlp --list-subs "VIDEO_URL"
Step 2: Download manual subtitles (recommended)
# 한국어 자막
yt-dlp --write-sub --sub-lang ko --skip-download "VIDEO_URL"
# 영어 자막
yt-dlp --write-sub --sub-lang en --skip-download "VIDEO_URL"
Step 3: Auto-generated subtitles (fallback)
yt-dlp --write-auto-sub --sub-lang ko --skip-download "VIDEO_URL"
Step 4: VTT → Text conversion
# VTT 파일에서 타임스탬프 제거
sed '/^[0-9]/d; /^$/d; /-->/d' subtitle.ko.vtt > transcript.txt
Output Processing
Remove duplicates
Auto-generated subtitles have many duplicates due to progressive captions:
# 중복 라인 제거
seen = set()
unique_lines = []
for line in lines:
if line not in seen:
seen.add(line)
unique_lines.append(line)
Generate summary
With the extracted subtitles:
- Summarize key content
- Generate chapters by timestamp
- Extract key keywords
Examples
Example 1: Lecture video summary
User: 이 유튜브 강의 요약해줘 - https://youtube.com/watch?v=xxx
Claude:
1. yt-dlp로 자막 다운로드
2. VTT → 텍스트 변환
3. 핵심 내용 요약 생성
4. 타임스탬프별 목차 제공
Example 2: Multilingual subtitle extraction
User: 이 영상의 영어/한국어 자막 둘 다 추출해줘
Claude:
1. --list-subs로 가용 언어 확인
2. 각 언어별 자막 다운로드
3. 정리된 텍스트 파일 제공
Error Handling
| Error | Cause | Solution |
|---|---|---|
yt-dlp not found |
Not installed | Install via brew/apt/pip |
No subtitles available |
No subtitles | Suggest using Whisper |
Invalid URL |
URL error | Check URL format |
Video unavailable |
Private/deleted | Notify the user |
Whisper Fallback
If there are no subtitles at all (user confirmation required):
# 파일 크기 확인
yt-dlp --print filesize "VIDEO_URL"
# 사용자 승인 후 오디오 다운로드
yt-dlp -x --audio-format mp3 "VIDEO_URL"
# Whisper로 변환
whisper audio.mp3 --language ko --model base
Caution: User confirmation is required due to bandwidth/processing time