viniciusenari / twitch-highlights-bot

Python bot that creates video compilations of the most watched Twitch clips of the week and uploads it to Youtube
GNU General Public License v3.0
31 stars 7 forks source link
bot google-api moviepy moviepy-library python twitch twitch-api twitchtv twitchtv-api youtube youtube-api

Twitch Highlights Bot

Python Twitch YouTube Google Cloud

Welcome to the Twitch Highlights Bot!

This Python bot utilizes the Twitch API to retrieve the most viewed clips from a selected game of the week, creates a video compilation of these clips using MoviePy, and then uploads the compilation to YouTube with an automatically generated title, description, and thumbnail. With this bot, you can easily keep up with the most popular clips on Twitch and share them with others on YouTube.
Here is the Youtube channel that I set up to test this bot. Youtube Channel

🎥 Features

📋 Prerequisites

Before you begin, ensure you have met the following requirements:

If you need help getting credentials from Twitch or Google, you may check the following guides:

💾 Setting up

Clone this repository:

git clone https://github.com/viniciusenari/automated-twitch-clips-youtube-channel

Create a virtual environment and install the requirements:

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

Create a .env file and add the following variables:

CLIENT_SECRET = "your_twitch_client_secret"
CLIENT_ID = "your_twitch_client_id"

Create a client_secret.json file and add the credentials from Google Cloud. You can download this from the Google Cloud Console under the credentials tab. Make sure to rename the file to client_secret.json.

🔧 Configuration

The configuration file, config.py, is located in the project folder. In this file, you can change the fonts by specifying their file path. You can also change the rendering settings for the video compilation. You can check what each parameter does in the MoviePy documentation.

📺 How to Use

To run the bot, open the terminal and navigate to the main.py file's directory. Then type the following command:

python main.py --game <game_name> --amount <amount> --languages <languages>

Replace <game_name> with the name of the game you want to use the bot for, <amount> with the number of clips you want to generate, and <languages> with a list of languages separated by spaces (e.g., "en fr de" for English, French, and German). For example, if you want to generate ten clips for the game "League of Legends" in English and Brazilian Portuguese, you would use the following command:

python main.py --game "League of Legends" --amount 10 --languages en pt-br

You may also use the short versions of the arguments:

python main.py -g "League of Legends" -a 10 -l en pt-br

You'll see logs in the terminal as the bot runs. A progress bar will also show how much of the video has been rendered.

Logs

To upload your rendered video to YouTube, follow these steps:

  1. Click on the link provided in the terminal to log in to your Google account.
  2. Select the YouTube channel you want to use to upload the video.
  3. After authenticating, you will be redirected to a page with a code. Copy this code.
  4. Paste the code into the terminal, and it will upload the video to Youtube YouTube.
  5. Follow the link provided in the terminal to access and view the uploaded video.

Note that the downloaded and created files will be in the folder files. The folder structure is as follows:

files  
  ├── clips  
  ├── overlays  
  ├── thumbnails
  └── youtube 

The clips folder holds the downloaded Twitch clips, the overlays folder has the text overlays for each clip, the thumbnails folder has the thumbnails for each clip, and the youtube folder contains the video compilation and its thumbnail

🤝 Contributing

💡 How to contribute

If you want to contribute to this project, follow these steps:

  1. Fork this repository.
  2. Create a branch: git checkout -b <branch_name>.
  3. Make your changes and commit them: git commit -m '<commit_message>'
  4. Push to the original branch: git push origin <project_name>/<location>
  5. Create the pull request.

Alternatively, see the GitHub documentation on creating a pull request.

✋ How to propose changes

If you want to propose changes to this project, follow these steps:

  1. Open an issue with the tag "enhancement".
  2. Describe the changes you want to make.
  3. Wait for feedback from the project maintainers.

Alternatively, see the GitHub documentation on creating an issue.

🐛 How to report a bug

If you want to report a bug to this project, follow these steps:

  1. Open an issue with the tag "bug".
  2. Describe the bug.
  3. Wait for feedback from the project maintainers.

Alternatively, see the GitHub documentation on creating an issue.

🤔 Ideas to Consider

Here are some ideas for contributions:

📜 License

The code for this bot is licensed under the GPL-3.0 License.