This bot automatically generates videos with AI and uploads them using the YouTube API.
This project uses the Hugging Face Inference API for image generation and the official YouTube Data API v3 for uploading. It is designed to be modular, configurable, and easy to set up for your own automated content channels.
- Fully Automated Workflow: From a simple text prompt to a video on YouTube, the entire process is 100% automated.
- Centralized Configuration: No need to edit the source code. All settings, including API keys, model endpoints, and scheduler timing, are managed in a simple
config.jsonfile. - Intelligent Scheduler:
- Run the bot in two modes: a single run for testing, or continuous mode for autonomous, 24/7 operation.
- In continuous mode, it uploads videos at random intervals between a configurable minimum and maximum time, creating a more natural upload pattern.
- Set
min_minutesandmax_minutesto the same value for fixed-interval scheduling (e.g., exactly every 24 hours).
- Externalized Prompts: Easily manage and expand your list of content ideas by adding them to the
prompts.jsonfile without ever touching the core logic. - Dynamic Video Details: Use templates in the configuration file to automatically generate unique YouTube titles and descriptions for each video, incorporating the original prompt with placeholders like
${prompt}. - Modular and Extensible Codebase: The project is broken down into logical modules (
image_generator,video_creator,youtube_handler), making it easy to understand, maintain, and extend with new features in the future.
The workflow is simple and robust:
- Get Prompt: Selects a random text prompt.
- Generate Image: Sends the prompt to the Stability AI model via the Hugging Face API to generate an image.
- Create Video: Converts the generated image into a static MP4 video of a specified duration using MoviePy.
- Upload to YouTube: Uploads the video to your YouTube channel using the YouTube Data API, with a title and description generated from a template.
To get this project running on your own machine, follow these steps.
- Python 3.8 or higher
- A Google Account with a YouTube channel
- A Hugging Face Account
git clone https://github.com/wd006/youtuber-bot.git
cd youtuber-bot# Create a virtual environment
python3 -m venv venvAnd activate it
On Windows:
.\venv\Scripts\activateOn macOS/Linux:
source venv/bin/activate
Install all the required Python libraries using the requirements.txt file.
pip install -r requirements.txtThis project requires two sets of credentials:
-
Google API (YouTube):
-
Go to the Google Cloud Console.
-
Create a new project.
-
Enable the "YouTube Data API v3".
-
Create credentials for an "OAuth 2.0 Client ID" with the application type set to "Desktop app".
-
Download the JSON file, rename it to
client_secrets.json, and place it in the project's root directory.
-
-
Hugging Face API:
- Go to your Hugging Face profile settings.
- Create a new Access Token with "write" permissions.
- Copy this token.
All of the bot's behavior is controlled from the config.json file. This is your main control panel. Below is a detailed breakdown of each setting.
| Setting | Description | Usage & Accepted Values |
|---|---|---|
huggingface_api_key |
Required. Your personal API key for the Hugging Face service. | Replace the placeholder with the Access Token from your Hugging Face profile. |
image_model_api |
The API endpoint of the text-to-image model. | It's best to leave the default (stabilityai/stable-diffusion-xl-base-1.0) unless you are an advanced user experimenting with other models. |
This section controls the timing and execution mode of the bot.
| Setting | Description | Usage & Accepted Values |
|---|---|---|
enabled |
Controls the bot's operating mode. | true: Continuous Mode. Runs in an endless loop with waits.false: Single-Run Mode. Runs only once and then stops. |
min_minutes |
The minimum time (in minutes) to wait between upload cycles. | An integer. For a fixed interval, set this to the same value as max_minutes. |
max_minutes |
The maximum time (in minutes) to wait between upload cycles. | An integer. Must be greater than or equal to min_minutes. |
Controls the properties of the final video file.
| Setting | Description | Usage & Accepted Values |
|---|---|---|
duration_seconds |
The total length of the generated static video. | An integer representing seconds (e.g., 10). |
fps |
Frames Per Second for the output video. | 24 is a standard value. No need to change this for a static image video. |
Controls everything related to the YouTube upload.
| Setting | Description | Usage & Accepted Values |
|---|---|---|
client_secrets_file |
The path to your Google API credentials. | Do not change. Should always be "client_secrets.json". |
scopes |
Defines the permissions the script requests from Google. | Do not change. |
title_template |
A template for the video's title. The ${prompt} placeholder will be replaced. |
Customize the text around the ${prompt}. Example: "AI Art Showcase: ${prompt}" |
description_template |
A template for the video's description. Also supports ${prompt}. |
Customize the text to fit your channel's style. You can add links, hashtags, etc. |
tags |
A list of tags that will be added to every uploaded video. | Add or remove strings inside the [ ... ] list to improve discoverability. |
category_id |
A number representing the YouTube video category. | A string containing a number. Common IDs: "28" (Science & Tech), "24" (Entertainment), "10" (Music). Full list here. |
privacy_status |
Sets the visibility of the video upon upload. | Must be one of these three strings: "public", "private", or "unlisted". |
Once everything is set up, running the script is straightforward.
-
Make sure your virtual environment is activated.
-
Run the main script from the terminal:
python main.py
On the very first run, you will be prompted to authenticate with Google. A URL will be displayed in the terminal. Copy this URL into your browser, log in with the Google account that owns your YouTube channel, and grant the requested permissions. You will then be given an authorization code to paste back into the terminal.
After the first successful run, a token.pickle file will be created, and you won't need to authenticate again.
This project is licensed under the MIT License. See the LICENSE file for full details.
Contributions are welcome!
Please feel free to fork the repository, make your changes, and submit a pull request.
For questions or support:
or open an issue on GitHub.
