Giter Club home page Giter Club logo

youtube-comments-sentiment-analyses's Introduction

Real-Time Sentiment Analysis Pipeline for YouTube Comments

realtime-streaming-telegram.mp4

youtube_comments_realtime_processing_diagram

This project is a real-time sentiment analysis pipeline for YouTube comments. It collects comments from YouTube videos, performs sentiment analysis using the Gemini API, and shares negative results on a Telegram channel.

Table of Contents

Introduction

This project aims to create a real-time pipeline that collects comments from YouTube videos, performs sentiment analysis on these comments using the Gemini API, and shares the negative results on a Telegram channel. The pipeline consists of three main components:

  1. Comment collection and transfer to Kafka.
  2. Sentiment analysis using the Gemini API.
  3. Telegram bot for sharing negative comments.

Features

  • Real-time collection of YouTube comments.
  • Sentiment analysis using the Gemini API to classify comments as positive, negative, or neutral.
  • Automatic sharing of negative comments on a specified Telegram channel.

Getting Started

Prerequisites

  • Python 3.6 or higher
  • Kafka
  • KSQL
  • YouTube Data API key
  • Gemini API key
  • Telegram Bot API key

Installation

  1. Clone the repository:

    git clone https://github.com/bunyaminonum/youtube-comments-sentiment-analyses.git
    cd youtube-comments-sentiment-analyses
  2. Install the required Python packages:

    pip install -r requirements.txt

Configuration

  1. Fill in the configuration files with your credentials and settings:

    • producer_config.json
    • sentiment_analysis_config.json
    • telegram_bot_config.json

    Example producer_config.json:

    {
      "youtube_api_key": "YOUR_YOUTUBE_API_KEY",
      "playlist_id": "YOUR_PLAYLIST_ID",
      "kafka_bootstrap_servers": "YOUR_KAFKA_BOOTSTRAP_SERVERS",
      "kafka_topic": "youtube_comments"
    }

    Example sentiment_analysis_config.json:

    {
      "kafka_bootstrap_servers": "YOUR_KAFKA_BOOTSTRAP_SERVERS",
      "gemini_api_key": "YOUR_GEMINI_API_KEY",
      "input_topic": "youtube_comments",
      "output_topic": "youtube_sentiments"
    }

    Example telegram_bot_config.json:

    {
      "telegram_bot_token": "YOUR_TELEGRAM_BOT_TOKEN",
      "kafka_bootstrap_servers": "YOUR_KAFKA_BOOTSTRAP_SERVERS",
      "kafka_topic": "negative_youtube_sentiments",
      "telegram_channel_id": "YOUR_TELEGRAM_CHANNEL_ID"
    }

Running the Project

  1. Start the Kafka server and create the necessary topics.

  2. Run the following KSQL queries to create streams:

    CREATE STREAM YOUTUBE_SENTIMENTS_STREAM (
        ID VARCHAR,
        TEXT VARCHAR,
        STATUS VARCHAR,
        AUTHOR VARCHAR,
        PUBLISHEDAT VARCHAR,
        UPDATEDAT VARCHAR,
        VIDEOTITLE VARCHAR,
        SENTIMENT VARCHAR
    ) WITH (
        KAFKA_TOPIC='youtube_sentiments', 
        VALUE_FORMAT='JSON'
    );
    
    CREATE STREAM NEGATIVE_YOUTUBE_SENTIMENTS_STREAM AS 
    SELECT * 
    FROM YOUTUBE_SENTIMENTS_STREAM 
    WHERE SENTIMENT='negative';
  3. Run each Python file separately:

    python producer.py
    python sentiment-analyses.py
    python telegram_bot.py

Project Structure

The project consists of the following files:

  • LICENSE: Contains the project's license information.
  • README.md: Provides an overview of the project, its purpose, and usage instructions.
  • producer.py: Script for collecting YouTube comments and sending them to Kafka.
  • producer_config.json: Configuration file for producer.py.
  • sentiment-analyses.py: Script for performing sentiment analysis on YouTube comments using the Gemini API.
  • sentiment_analysis_config.json: Configuration file for sentiment-analyses.py.
  • telegram_bot.py: Script for sending negative comments to a Telegram channel.
  • telegram_bot_config.json: Configuration file for telegram_bot.py.

License

This project is licensed under the MIT License. See the LICENSE file for details.

youtube-comments-sentiment-analyses's People

Contributors

bunyaminonum avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.