YouTube Transcript Fetcher is a command-line tool written in Go that allows you to download and save transcripts from YouTube videos. It supports multiple languages and provides various options for customizing the output.
- Fetch transcripts from YouTube videos using video ID or URL
- Support for multiple languages
- Customizable output format
- Error handling for various scenarios (video unavailable, transcripts disabled, etc.)
- Go 1.15 or higher
-
Clone the repository:
git clone https://github.com/yourusername/youtube-transcript-fetcher.git -
Navigate to the project directory:
cd youtube-transcript-fetcher -
Build the program:
go build -o youtube-transcript-fetcher
Basic usage:
./youtube-transcript-fetcher -videoId=VIDEO_ID_OR_URL
To see all available options:
./youtube-transcript-fetcher -h
-videoId: YouTube video ID or URL (required)-lang: Language code for the transcript (default: "en")-output: Output file path (default: will use sanitized video title with .txt extension, limited characters )-showText: Show transcript text (default: true)-showDuration: Show transcript duration (default: false)-showOffset: Show transcript offset (default: false)-showLang: Show transcript language (default: false)-disableAll: Disable all transcript output fields (default: false)-noTextPrefix: Disable prefix 'Text: ' in front of transcript text (default: true)
-
Fetch English transcript for a video:
./youtube-transcript-fetcher -videoId=dQw4w9WgXcQ -lang=en -output=transcript.txt -
Fetch Spanish transcript and only show text:
./youtube-transcript-fetcher -videoId=https://www.youtube.com/watch?v=dQw4w9WgXcQ -lang=es -showDuration=false -showOffset=false -showLang=false -
Fetch transcript without 'Text: ' prefix:
./youtube-transcript-fetcher -videoId=dQw4w9WgXcQ -showDuration=false -showOffset=false -showLang=false -noTextPrefix=true
The program handles various error scenarios, including:
- Video unavailable
- Transcripts disabled for the video
- Requested language not available
- Too many requests (captcha required)
In case of an error, an appropriate message will be displayed.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
- This project was inspired by the need for a simple, command-line tool to fetch YouTube transcripts.
- Thanks to the Go community for providing excellent libraries and documentation.