Skip to content

iChris/YouTube-Transcript-Search

Repository files navigation

YouTube Transcript Keyword Search Tool

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.

Note: Coded almost entirely by Claude and Warp AI. Use at your own risk.

✨ Features

  • 🔍 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

🚀 Quick Start

Prerequisites

  • Python 3.7 or higher
  • Internet connection (for downloading transcripts)

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/youtube-transcript-search.git
    cd youtube-transcript-search
  2. Install dependencies:

    pip install -r requirements.txt

    Or install manually:

    pip install youtube-transcript-api
  3. Run the tool:

    python youtube_transcript_search.py

📖 Usage

Interactive Mode

Run the script without arguments for the full interactive experience:

python youtube_transcript_search.py

Single Video Mode:

  1. Choose s for single video
  2. Enter YouTube URL
  3. Enter keywords (comma-separated)
  4. Choose case sensitivity
  5. View and save results

Batch Mode:

  1. Choose b for batch processing
  2. Choose manual entry (m) or file input (f)
  3. Enter URLs or provide file path
  4. Enter keywords and options
  5. Process all videos and view combined results

Command Line Interface

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-save

CLI 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

File Input Format

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

📊 Output Examples

Single Video Results

🔑 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 Results

📊 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

🎯 Use Cases

  • 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

⚙️ Technical Details

Supported URL Formats

  • https://www.youtube.com/watch?v=VIDEO_ID
  • https://youtu.be/VIDEO_ID
  • https://www.youtube.com/embed/VIDEO_ID
  • Raw video IDs (11-character strings)

Transcript Sources

The tool automatically attempts to retrieve transcripts in this order:

  1. Manual/human-created transcripts (preferred)
  2. Auto-generated transcripts
  3. Any available language transcript

Output Files

  • Single video: transcript_search_results_{VIDEO_ID}.txt
  • Batch processing: transcript_search_batch_results_{TIMESTAMP}.txt
  • Custom: Use -o filename.txt

🔧 Troubleshooting

Common Issues

"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

Error Handling

  • Failed videos in batch mode don't stop processing
  • Detailed error messages for troubleshooting
  • Graceful handling of network issues

🤝 Contributing

Contributions are welcome! I have no idea what I'm doing though.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

  • youtube-transcript-api - The core library that makes this tool possible
  • YouTube for providing transcript data

📞 Support

If you encounter any issues or have questions:

  1. Check the troubleshooting section above
  2. Search existing GitHub Issues
  3. Create a new issue with detailed information about your problem

⭐ If this tool helps you, please give it a star on GitHub!

About

A tool to search a single or batch of YouTube videos for specific keywords or phrases.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages