This project aims to analyze the content of YouTube channels to gain insights into various aspects such as video engagement, trends, audience demographics, and content performance. The project will leverage Python and various libraries to interact with the YouTube API, scrape video data, and provide meaningful analytics for YouTube content creators or marketers.
This project analyzes YouTube channels to extract data about video performance, audience engagement, and growth metrics.
- Fetches channel and video metrics.
- Provides insights into audience engagement and video performance.
- Tracks YouTube channel growth over time.
- Video Metrics Analysis: Extract key metrics such as views, likes, dislikes, comments, and more.
- Trend Analysis: Identify trends in video titles, tags, and descriptions over time.
- Channel Growth Insights: Track the growth of subscribers and video views across multiple periods.
- Audience Demographics: Analyze the audience's location, gender, and interests (via available API data).
- Content Classification: Classify videos into different genres based on keywords and metadata.
- Python: The core language for this project.
- Google API Client: For interacting with the YouTube Data API.
- Pandas & Numpy: For data manipulation and analysis.
- Matplotlib & Seaborn: For visualizing the analytics.
- Requests: For handling HTTP requests.
- BeautifulSoup (Optional): For scraping additional data if necessary.
To run this project locally, you will need:
- Python 3.x
- A Google Cloud project with YouTube Data API v3 enabled.
- An API key from Google Cloud.
-
Clone this repository:
git clone https://github.com/jmrashed/YouTube-Channel-Analysis.git
-
Navigate into the project directory:
cd YouTube-Channel-Analysis
-
Install the required Python libraries:
pip install -r requirements.txt
-
Set up the YouTube API credentials:
- Go to Google Developers Console.
- Create a new project and enable the YouTube Data API v3.
- Create credentials for an API key and replace it in the
config.py
file.
In the config.py
file, you'll need to define the following settings:
-
API_KEY: This is the key you obtain from the Google Developers Console when you enable the YouTube Data API v3. Replace
'YOUR_API_KEY'
in theconfig.py
file with your actual API key.API_KEY = 'YOUR_API_KEY'
-
MAX_RESULTS: This parameter controls how many results (videos) are fetched from the YouTube API. You can set it to any integer value based on your needs, but the default maximum allowed by YouTube API is 50 per request.
MAX_RESULTS = 50
-
YOUTUBE_API_URL: This is the base URL for the YouTube Data API. It should be defined as follows:
YOUTUBE_API_URL = 'https://www.googleapis.com/youtube/v3/'
Here's an example of how your config.py
should look after you replace the placeholders:
API_KEY = 'AIzaSyAYourAPIKeyExample' # Replace with your actual API key
MAX_RESULTS = 50 # Adjust based on how many results you need
YOUTUBE_API_URL = 'https://www.googleapis.com/youtube/v3/'
- Run the analysis script:
python analyze.py --channel_id UCbCmjCuTUZos6Inko4u57UQ
-
After setting up the environment, you can start analyzing a YouTube channel by passing the channel ID or username to the script.
-
Example usage to analyze a channel by ID:
python analyze.py --channel_id UCbCmjCuTUZos6Inko4u57UQ
-
The script will output detailed metrics, such as:
- Total views and subscribers.
- Average video performance (likes, views, comments).
- Top trending tags or keywords.
If you'd like to contribute to the project, feel free to fork the repository and create a pull request. Here's how you can contribute:
- Fork the repository.
- Create a new branch (
git checkout -b feature/your-feature-name
). - Make your changes and commit them (
git commit -am 'Add new feature'
). - Push to the branch (
git push origin feature/your-feature-name
). - Open a pull request to merge your changes into the
main
branch.
This project is licensed under the MIT License - see the LICENSE file for details.