This project is a YouTube sentiment analysis tool that fetches comments from a specified YouTube video and performs sentiment analysis on the fetched comments. The goal of this project is to provide insights into viewer sentiments, which can be useful for content creators, marketers, and analysts.
- Fetch comments from any YouTube video using the YouTube Data API v3.
- Perform sentiment analysis on the comments using the TextBlob library.
- Display the results of the sentiment analysis, showing the distribution of positive, neutral, and negative comments.
- Python 3.6 or higher
- Virtual Environment (venv)
- Google API Key (YouTube Data API v3)
All required libraries are listed in the requirements.txt
file. They include:
google-api-python-client
python-dotenv
textblob
To use the YouTube Data API, you need to apply for an API key:
- Go to the Google Cloud Console.
- Create a new project.
- Enable the YouTube Data API v3.
- Create credentials for an API key.
- Save your API key securely.
Clone this repository to your local machine:
git clone https://github.com/
cd youtube-sentiment-analysis
Create and activate a virtual environment:
python3 -m venv venv
source venv/bin/activate
Install the required Python packages:
pip install -r requirements.txt
Create a .env file in the root directory of your project and add your YouTube API key:
source .env
YOUTUBE_API_KEY=your_api_key_here
Replace the video_id in the script with the ID of the YouTube video you want to analyze. Then run the script:
python youtube_sentiment_analysis.py