| name | youtube-transcript |
| description | Download and process YouTube video transcripts using yt-dlp. Use this when extracting subtitles, creating summaries from videos, or processing video content. |
| allowed-tools | Read, Glob, Grep, Bash, Write |
| license | MIT |
| metadata | {"author":"michalparkola","version":"1.0"} |
YouTube Transcript Downloader
์ ํ๋ธ ์์์์ ์๋ง์ ์ถ์ถํ๊ณ ์ฒ๋ฆฌํ๋ ์คํฌ์
๋๋ค.
Priority Order
1. yt-dlp ์ค์น ํ์ธ
2. ์ฌ์ฉ ๊ฐ๋ฅํ ์๋ง ๋ชฉ๋ก ํ์ธ
3. ์๋ ์๋ง ์ฐ์ ์๋
4. ์๋ ์์ฑ ์๋ง ํด๋ฐฑ
5. ์ตํ ์๋จ: Whisper ๋ณํ
Requirements
brew install yt-dlp
sudo apt install yt-dlp
pip install yt-dlp
Workflow
Step 1: ์๋ง ๋ชฉ๋ก ํ์ธ
yt-dlp --list-subs "VIDEO_URL"
Step 2: ์๋ ์๋ง ๋ค์ด๋ก๋ (๊ถ์ฅ)
yt-dlp --write-sub --sub-lang ko --skip-download "VIDEO_URL"
yt-dlp --write-sub --sub-lang en --skip-download "VIDEO_URL"
Step 3: ์๋ ์์ฑ ์๋ง (ํด๋ฐฑ)
yt-dlp --write-auto-sub --sub-lang ko --skip-download "VIDEO_URL"
Step 4: VTT โ ํ
์คํธ ๋ณํ
sed '/^[0-9]/d; /^$/d; /-->/d' subtitle.ko.vtt > transcript.txt
Output Processing
์ค๋ณต ์ ๊ฑฐ
์๋ ์์ฑ ์๋ง์ progressive ์บก์
์ผ๋ก ์ธํด ์ค๋ณต์ด ๋ง์:
seen = set()
unique_lines = []
for line in lines:
if line not in seen:
seen.add(line)
unique_lines.append(line)
์์ฝ ์์ฑ
์ถ์ถ๋ ์๋ง์ผ๋ก:
- ํต์ฌ ๋ด์ฉ ์์ฝ
- ํ์์คํฌํ๋ณ ์ฑํฐ ์์ฑ
- ์ฃผ์ ํค์๋ ์ถ์ถ
Examples
Example 1: ๊ฐ์ ์์ ์์ฝ
User: ์ด ์ ํ๋ธ ๊ฐ์ ์์ฝํด์ค - https://youtube.com/watch?v=xxx
Claude:
1. yt-dlp๋ก ์๋ง ๋ค์ด๋ก๋
2. VTT โ ํ
์คํธ ๋ณํ
3. ํต์ฌ ๋ด์ฉ ์์ฝ ์์ฑ
4. ํ์์คํฌํ๋ณ ๋ชฉ์ฐจ ์ ๊ณต
Example 2: ๋ค๊ตญ์ด ์๋ง ์ถ์ถ
User: ์ด ์์์ ์์ด/ํ๊ตญ์ด ์๋ง ๋ ๋ค ์ถ์ถํด์ค
Claude:
1. --list-subs๋ก ๊ฐ์ฉ ์ธ์ด ํ์ธ
2. ๊ฐ ์ธ์ด๋ณ ์๋ง ๋ค์ด๋ก๋
3. ์ ๋ฆฌ๋ ํ
์คํธ ํ์ผ ์ ๊ณต
Error Handling
| ์๋ฌ | ์์ธ | ํด๊ฒฐ์ฑ
|
|---|
yt-dlp not found | ๋ฏธ์ค์น | brew/apt/pip ์ค์น |
No subtitles available | ์๋ง ์์ | Whisper ์ฌ์ฉ ์ ์ |
Invalid URL | URL ์ค๋ฅ | URL ํ์ ํ์ธ |
Video unavailable | ๋น๊ณต๊ฐ/์ญ์ | ์ฌ์ฉ์์๊ฒ ์๋ฆผ |
Whisper Fallback
์๋ง์ด ์ ํ ์๋ ๊ฒฝ์ฐ (์ฌ์ฉ์ ํ์ธ ํ์):
yt-dlp --print filesize "VIDEO_URL"
yt-dlp -x --audio-format mp3 "VIDEO_URL"
whisper audio.mp3 --language ko --model base
์ฃผ์: ๋์ญํญ/์ฒ๋ฆฌ ์๊ฐ ์์๋ก ์ฌ์ฉ์ ํ์ธ ํ์