A Python tool for searching keywords across YouTube video transcripts with support for both single video analysis and batch processing of multiple videos via the YouTube Transcription API.
- 🔍 Keyword Search: Search for multiple keywords in YouTube video transcripts
- 📹 Single & Batch Mode: Process one video or hundreds at once
- 📁 File Input: Load video URLs from text files for batch processing
- 🎯 Case Sensitivity: Optional case-sensitive search
- 📊 Detailed Results: Organized results with timestamps and clickable URLs
- 💾 Export Results: Save search results to formatted text files
- 🖥️ CLI Support: Full command-line interface for automation
- 🔗 Multiple URL Formats: Supports various YouTube URL formats
- Python 3.7 or higher
- Internet connection (for downloading transcripts)
-
Clone the repository:
git clone https://github.com/yourusername/youtube-transcript-search.git cd youtube-transcript-search -
Install dependencies:
pip install -r requirements.txt
Or install manually:
pip install youtube-transcript-api
-
Run the tool:
python youtube_transcript_search.py
Run the script without arguments for the full interactive experience:
python youtube_transcript_search.pySingle Video Mode:
- Choose
sfor single video - Enter YouTube URL
- Enter keywords (comma-separated)
- Choose case sensitivity
- View and save results
Batch Mode:
- Choose
bfor batch processing - Choose manual entry (
m) or file input (f) - Enter URLs or provide file path
- Enter keywords and options
- Process all videos and view combined results
For automation and scripting:
# Single video search
python youtube_transcript_search.py -u "https://www.youtube.com/watch?v=VIDEO_ID" -k "keyword1,keyword2"
# Batch search from file
python youtube_transcript_search.py -f urls.txt -k "keyword1,keyword2" -o results.txt
# Case-sensitive search
python youtube_transcript_search.py -u "URL" -k "Keyword" --case-sensitive
# Process without saving
python youtube_transcript_search.py -f urls.txt -k "keywords" --no-saveCLI Options:
-u, --url: Single YouTube video URL-f, --file: File containing YouTube URLs (one per line)-k, --keywords: Comma-separated keywords to search for-c, --case-sensitive: Enable case-sensitive search-o, --output: Custom output file path--no-save: Don't save results to file-h, --help: Show help message
Create a text file with YouTube URLs (one per line):
# Video URLs for batch processing
# Lines starting with # are ignored
https://www.youtube.com/watch?v=VIDEO_ID1
https://youtu.be/VIDEO_ID2
https://www.youtube.com/watch?v=VIDEO_ID3🔑 Keyword: 'example' (5 matches)
--------------------------------------------------
1. [02:15] This is an example of the concept
🔗 https://youtube.com/watch?v=VIDEO_ID&t=135s
2. [05:32] Another example can be found here
🔗 https://youtube.com/watch?v=VIDEO_ID&t=332s
📊 BATCH PROCESSING SUMMARY
================================================================================
✅ Successfully processed: 3/3 videos
🔍 Total matches across all videos: 47
🔑 Keyword: 'example' (12 matches across 2 videos)
📹 Video: VIDEO_ID1 (8 matches)
🔗 https://youtube.com/watch?v=VIDEO_ID1
1. [02:15] This is an example...
🔗 https://youtube.com/watch?v=VIDEO_ID1&t=135s
📹 Video: VIDEO_ID2 (4 matches)
🔗 https://youtube.com/watch?v=VIDEO_ID2
1. [01:23] Here's another example...
🔗 https://youtube.com/watch?v=VIDEO_ID2&t=83s
- Content Research: Analyze multiple videos for specific topics
- Academic Research: Search across lectures and presentations
- Content Moderation: Find specific terms across video collections
- Market Research: Analyze competitor content for keywords
- SEO Analysis: Identify keyword usage patterns
- Accessibility: Create searchable transcripts for large video libraries
https://www.youtube.com/watch?v=VIDEO_IDhttps://youtu.be/VIDEO_IDhttps://www.youtube.com/embed/VIDEO_ID- Raw video IDs (11-character strings)
The tool automatically attempts to retrieve transcripts in this order:
- Manual/human-created transcripts (preferred)
- Auto-generated transcripts
- Any available language transcript
- Single video:
transcript_search_results_{VIDEO_ID}.txt - Batch processing:
transcript_search_batch_results_{TIMESTAMP}.txt - Custom: Use
-o filename.txt
"No transcript found"
- Video may not have transcripts enabled
- Video might be private or restricted
- Try with a different video to test the tool
"Invalid YouTube URL"
- Check the URL format is correct
- Ensure the video ID is valid
- Try copying the URL directly from YouTube
Installation Issues
- Ensure Python 3.7+ is installed:
python --version - Try upgrading pip:
pip install --upgrade pip - Use virtual environment if having conflicts
- Failed videos in batch mode don't stop processing
- Detailed error messages for troubleshooting
- Graceful handling of network issues
Contributions are welcome! I have no idea what I'm doing though.
This project is licensed under the MIT License - see the LICENSE file for details.
- youtube-transcript-api - The core library that makes this tool possible
- YouTube for providing transcript data
If you encounter any issues or have questions:
- Check the troubleshooting section above
- Search existing GitHub Issues
- Create a new issue with detailed information about your problem
⭐ If this tool helps you, please give it a star on GitHub!