How farazkhanai/yt_sentiment_analysis works
This is a Chrome extension and Flask service for analyzing YouTube comment sentiment. The user opens a YouTube video and starts analysis from the popup; the extension obtains the video ID, requests a background job, then polls for progress and sentiment counts. The service fetches comments and replies, runs batched DistilBERT/ONNX inference, and reports results. The README also documents CPU-optimized inference and partial-result warnings. The model files are described as separately downloaded and are not present in the supplied tree; the map shows the documented dependency, not inspected model code.
Main entry points: app.py Flask API · popup.js Popup UI and polling · content.js Video ID extraction · background.js API request worker
Components 14
Chrome extension
- Popup UI and polling
extension/popup.js - Video ID extraction
extension/content.js - API request worker
extension/background.js
Analysis service
- Flask API
backend/app.py - Background job worker
backend/app.py - In-memory job state
backend/app.py
Comment analysis
- Video ID parser
backend/utils.py - Comment and reply fetcher
backend/utils.py - Sentiment analyzer
backend/utils.py
External systems
- DistilBERT ONNX files
- YouTube Data API
- Chrome runtime
Other components
- YouTube viewer
- YouTube video page
Connections 19
- YouTube viewer → Popup UI and polling: starts analysis
- Popup UI and polling → Chrome runtime: queries active tab
- Popup UI and polling → Video ID extraction: requests video ID
- Video ID extraction → YouTube video page: reads video URL
- Video ID extraction → Popup UI and polling: returns video ID
- Popup UI and polling → API request worker: sends analysis request
- API request worker → Flask API: POSTs video ID
- Flask API → Video ID parser: parses URL if needed
- Flask API → In-memory job state: creates job record
- Flask API → Background job worker: starts worker
- Background job worker → In-memory job state: updates progress
- Background job worker → Comment and reply fetcher: fetches comments
- Comment and reply fetcher → YouTube Data API: requests comments and replies
- Background job worker → Sentiment analyzer: predicts sentiment batches
- Sentiment analyzer → DistilBERT ONNX files: loads and runs inference
- Background job worker → In-memory job state: stores final counts
- Popup UI and polling → Flask API: polls job status
- Flask API → In-memory job state: reads job status
- Flask API → Popup UI and polling: returns progress or results