YouTube 字幕提取器
STDIO从YouTube视频提取字幕的命令行工具
从YouTube视频提取字幕的命令行工具
A command-line tool that extracts transcripts from YouTube videos, supporting various URL formats and outputting transcripts with optional timestamps. Built with Python and using script dependencies management.
This tool uses the script dependencies specification format:
git clone https://github.com/tlofreso/mcp-youtube-transcripts.git cd mcp-youtube-transcripts
The script's dependencies are automatically managed through the script header:
# /// script # requires-python = ">=3.12" # dependencies = [ # "click", # "youtube_transcript_api", # ] # ///
Basic command format:
python youtube_transcript.py <youtube-url> [options]
-o, --output
: Specify output file path (default: stdout)--timestamps/--no-timestamps
: Include/exclude timestamps (default: include)python youtube_transcript.py "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
python youtube_transcript.py "https://youtu.be/dQw4w9WgXcQ" -o transcript.txt --no-timestamps
python youtube_transcript.py "https://www.youtube.com/embed/dQw4w9WgXcQ"
With timestamps (default):
[00:00:00] First line of the transcript
[00:00:03] Second line of the transcript
[00:00:07] Third line of the transcript
Without timestamps:
First line of the transcript
Second line of the transcript
Third line of the transcript
The tool provides clear error messages for common scenarios:
Contributions are welcome! Please feel free to submit issues and pull requests.
This project is open source and available under the MIT License.