Loading repository data…
Loading repository data…
vijaykumarpeta / repository
A modern Python GUI application to batch extract YouTube comments and metadata to CSV. Features spam filtering, relevance sorting, and a dark-mode interface.
A powerful desktop application for extracting and filtering YouTube comments with advanced spam detection. Built for content creators, strategists, analysts, and anyone who needs clean, actionable comment data.
YouTube Comment Extractor connects to the YouTube Data API to fetch comments from any public video, then applies sophisticated filtering to separate genuine engagement from spam. The result is clean, organized data ready for analysis, exported as CSV or Excel files with full metadata.
Note: The app extracts top-level comments (with their reply counts). Individual replies are not fetched.
YouTube's comment section is flooded with spam. Studies show AI-generated spam now accounts for over 50% of comments on popular videos. This tool uses intent-based detection (not just keyword matching) to identify promotional spam while protecting legitimate comments, even excited fans using ALL CAPS or viewers sharing genuine testimonials.
The spam filter uses intent-based detection rather than style-based filtering:
| Spam Type | Detection Method |
|---|---|
| Crypto/Financial Scams | Keyword patterns + financial promises |
| Contact Solicitation | WhatsApp, Telegram, phone numbers, emails |
| Self-Promotion | Channel plugs, "check my video" spam |
| Impersonation | Fake verification badges, suspicious usernames |
| Obfuscation Attacks | Cyrillic homoglyphs (сontact → contact), leetspeak |
| Spam Campaigns | Duplicate/near-duplicate comment cluster detection |
| Structural Spam | Spam emoji clusters, excessive caps, repetitive punctuation |
Signal combination boosts: Certain signal pairs (e.g., crypto keywords + contact solicitation) receive a score boost, catching spam that individual signals alone might miss.
Legitimate comments are protected through legitimacy signals:
⚠️ Note on False Positives: While the spam filter is designed to minimize false positives, no automated system is perfect. Some legitimate comments may occasionally be flagged as spam, especially those discussing cryptocurrency, trading, or self-promotion in a genuine context. We recommend reviewing the "Flagged Spam" export to recover any incorrectly filtered comments. You can also use the Whitelist feature to create patterns that protect specific types of comments.
Ctrl+Enter to fetch, Ctrl+S for CSV, Ctrl+E for Excel# Clone the repository
git clone https://github.com/vijaykumarpeta/yt-comments-extractor.git
cd yt-comments-extractor
# Create virtual environment (recommended)
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Run the application
python main.py
For secure credential storage using your system keyring:
pip install keyring
Without keyring, your API key is stored in settings.json. With keyring, it's stored securely in your operating system's credential manager.
python main.pyyoutube.com/watch?v=VIDEO_IDyoutu.be/VIDEO_IDyoutube.com/shorts/VIDEO_IDyoutube.com/embed/VIDEO_IDCtrl+Enter| Filter | Description |
|---|---|
| Filter Spam | Enable/disable spam detection |
| Sensitivity | Adjust spam filter aggressiveness (Light, Moderate, Aggressive) |
| Exclude Creator | Remove the video creator's own comments |
| Min Likes | Only include comments with N+ likes |
| Max Comments | Limit comments per video (leave empty for all) |
| Sort By | Likes, Date (Newest), or Date (Oldest) |
| Date Range | Filter comments by date (YYYY-MM-DD) |
| Filter Words | Comma-separated keywords — only include comments containing these words |
| Blacklist Patterns | Custom patterns to always flag as spam |
| Whitelist Patterns | Custom patterns to always allow through |
| Level | Threshold | Description |
|---|---|---|
| Light | 0.65 | Only catches obvious spam, minimal false positives |
| Moderate | 0.50 | Balanced filtering (default) |
| Aggressive | 0.40 | Catches more spam, slight risk of false positives |
| Strict | 0.30 | Maximum filtering, higher risk of false positives |
The Filter Words feature lets you extract only comments containing specific keywords. This is perfect for:
How it works:
python, tutorial, beginnerClick the Blacklist Patterns or Whitelist Patterns buttons to add your own patterns:
# Blacklist examples (one per line):
competitor-brand
buy my course
discount code
# Whitelist examples (one per line):
official announcement
verified purchase
Patterns are matched case-insensitively against comment text.
Creates three separate files:
filename_metadata.csv: Video details (title, views, likes, comment count)filename_comments.csv: All filtered comments with author, date, likesfilename_spam.csv: Flagged spam with detection reasoningCreates one workbook with three sheets:
All exports use UTF-8 with BOM for Excel compatibility.
| Shortcut | Action |
|---|---|
Ctrl+Enter | Start fetching comments |
Ctrl+S | Export to CSV |
Ctrl+E | Export to Excel |
yt-comments-extractor/
├── main.py # GUI application (CustomTkinter)
├── extractor.py # YouTube API wrapper
├── spam_filter.py # Multi-signal spam detection engine
├── assets/
│ └── logo.ico # Application icon
├── core/
│ ├── __init__.py # Package exports
│ ├── constants.py # App configuration and constants
│ ├── settings.py # Settings management with keyring
│ └── validators.py # Input validation utilities
├── tests/
│ ├── test_spam_filter.py # Spam detection tests
│ └── test_validators.py # Input validation tests
├── requirements.txt # Python dependencies
├── pyproject.toml # Project metadata and build config
├── LICENSE # MIT License
└── README.md # This file
Create a portable .exe that runs without Python installed:
# Install PyInstaller
pip install pyinstaller
# Build the executable
pyinstaller --noconfirm --onefile --windowed \
--name "YouTubeCommentExtractor" \
--collect-all customtkinter \
main.py
The executable will be created in the dist/ folder.
Each video fetch uses approximately:
YouTube's default quota is 10,000 units/day. The app includes automatic rate limiting (2-5 second delays between videos) to stay within limits.
Tip: The Max Comments limit counts comments that pass your filters. With aggressive filters (high min likes, narrow date range, filter words), the app may page through many more comments than the limit to find enough matches — which uses more quota.
The spam filter uses a multi-signal scoring system:
Default threshold: 0.5 (balanced). Lower = stricter, higher = more permissive.
All YouTube API calls run in background threads. UI updates use Tkinter's after() method for thread-safe communication. Cancellation is handled via threading.Event().
YouTube limits API usage to 10,000 units per day. Wait 24 hours for quota reset, or create a new API key in a different project.
The video owner has disabled comments. The app handles this gracefully and moves to the next video.
Make sure your URL matches one of the supported formats. The app validates URLs in real-time and shows a status indicator.
If keyring storage fails, the ap