
StreamGuard is a Python script designed to analyze YouTube live chat streams and estimate the number of real viewers versus potential bot accounts. It collects live chat messages, analyzes chat activity patterns, and provides an estimation of viewer authenticity based on chat behavior.
- Automatically detects active YouTube live streams on a specified channel.
- Collects and analyzes live chat messages over a configurable time window.
- Detects suspicious chat activity indicating potential bots.
- Estimates real viewers and bots based on chat-to-viewer ratios.
- Logs analysis results in a JSON file for further inspection.
- Immediate GUI popup: The graphical interface launches instantly without waiting for data fetching.
- Background data loading: Channel info and stream statistics load asynchronously in separate threads, ensuring a responsive UI.
- Python 3.8 or later
- Google API Client Library for Python (
google-api-python-client
) - YouTube Data API v3 Key
- Additional dependencies:
requests
,Pillow
(PIL fork)
To use this script, you need to obtain a YouTube Data API v3 key. Follow these steps:
- Go to the Google Cloud Console.
- Create a new project or select an existing one.
- Enable the YouTube Data API v3 under "APIs & Services".
- Navigate to "Credentials" and create an API key.
- Use this key in the
API_KEY
configuration of the script.
pip install google-api-python-client requests Pillow
- Clone the repository:
git clone https://github.com/Riotcoke123/StreamGuard-YouTube-Bot-Detection.git
- Set your YouTube Data API key and target channel ID in the script configuration.
- Run the script:
python yt.py
The main configuration parameters can be adjusted at the top of the script:
API_KEY
: Your YouTube Data API v3 key.CHANNEL_ID
: The YouTube channel ID to monitor.CHAT_DURATION
: Duration (seconds) to collect chat messages during each analysis cycle.INTERVAL
: Time interval (seconds) between consecutive bot detection runs.
The updated script now:
- Launches the GUI window immediately on start without delay.
- Loads channel thumbnail and name in a background thread, updating the interface once available.
- Runs the live chat analysis and viewer estimation in a background thread, logging results and updating the GUI asynchronously.
- Uses
threading.Thread
andTkinter's root.after()
to safely update UI from background threads.
This project is licensed under the GNU General Public License v3.0.
Find the project on GitHub: https://github.com/Riotcoke123/StreamGuard-YouTube-Bot-Detection
© 2025 StreamGuard Project. Licensed under GPLv3.