- Python 100%
| .github/workflows | ||
| lib | ||
| .gitignore | ||
| auto.json | ||
| LICENSE | ||
| main.py | ||
| metadata.json | ||
| README.md | ||
| requirements.txt | ||
| setup.py | ||
| used_content.json | ||
YouTube Automation Bot
This Python-based bot automates the creation and upload of YouTube videos by sourcing content from Pixabay and Freesound. It uses GitHub Actions to run daily, creating and uploading fresh videos automatically without manual input. Check out the automated Youtube channel.
Features
- Automated Video Search & Download: Fetches relevant video clips from Pixabay based on user-defined search queries.
- Music Search & Download: Downloads music from Freesound with proper attribution for Creative Commons-licensed content.
- Video Creation: Combines video and audio into a final video, customizable for durations like 30, 60, or 90 minutes.
- Automated YouTube Upload: Uses the YouTube Data API to upload the final video directly to a YouTube channel.
- Daily Automation: Can be configured to run automatically with GitHub Actions, generating and uploading a new video every day.
Prerequisites
- Python 3.9+
- API keys for Pixabay and Freesound
- YouTube Data API access (YouTube API Setup Guide)
Setup
Setup (Manual Use)
Clone the repository to your machine:
git clone https://github.com/PrintN/Youtube-Automation-Bot
cd Youtube-Automation-Bot
Run the setup.
python3 setup.py
This will:
- Install required packages
- Ask for Pixabay, Freesound, Google Client ID, and Secret
- Open a window for YouTube channel authorization
- Reset auto.json and used_content.json
Usage
Run main.py manually to generate videos interactively:
python main.py
Setup (Automated with Github Actions)
Start by forking this repo.
Clone the repository to your machine:
git clone https://github.com/YOUR-FORKED-REPO
cd Youtube-Automation-Bot
python3 setup.py
This will:
- Install required packages
- Ask for Pixabay, Freesound, Google Client ID, and Secret
- Open a window for YouTube channel authorization
- Reset auto.json and used_content.json
Configuring API Keys
To enable the bot to run daily using GitHub Actions, you'll need to add the following secrets to your GitHub repository:
-
Go to:
Settings > Secrets and variables > Actionsin your forked repo. -
Click "New repository secret" and add the following secrets:
- FREESOUND_API_KEY: Your Freesound API key.
- PIXABAY_API_KEY: Your Pixabay API key.
- CLIENT_SECRETS_JSON: Base64-encoded
client_secrets.jsonfile. - TOKEN_JSON: Base64-encoded
token.jsonfile.
How to Base64 Encode Files:
- Linux/macOS:
base64 client_secrets.json > encoded_client_secrets.txt base64 token.json > encoded_token.txt - Windows (Powershell)
[Convert]::ToBase64String([IO.File]::ReadAllBytes("C:\FULL\PATH\TO\client_secrets.json")) > encoded_client_secrets.txt [Convert]::ToBase64String([IO.File]::ReadAllBytes("C:\FULL\PATH\TO\token.json")) > encoded_token.txt
Copy the contents of encoded_client_secrets.txt and encoded_token.txt into the value fields for CLIENT_SECRETS_JSON and TOKEN_JSON.
Configuring auto.json
This file contains video configurations for the bot to run in auto mode. You can create as many videos configuration as you want. Example structure:
{
"videos": [
{
"duration_minutes": 30,
"video_query": "forest landscapes",
"audio_query": "forest ambiance",
"upload_to_youtube": false,
"video_type": "video"
},
{
"duration_minutes": 0.55,
"video_query": "mountain sunrise",
"audio_query": "gentle wind",
"upload_to_youtube": true,
"video_type": "short"
},
]
}
Adjusting the Schedule
To change the bot’s schedule, edit .github/workflows/daily-video.yaml:
on:
schedule:
- cron: 0 5 * * * # 05:00 AM UTC
Limitations of the Youtube API
-
Video Duration Limit: By default, users are allowed to upload videos with a maximum duration of 15 minutes. If you wish to upload videos that exceed this limit, you will need to verify your account. For more details click here.
-
OAuth Consent Screen Configuration: When setting up your Google Cloud Console project, it is important to configure the OAuth consent screen correctly. You must set it to production and not testing. If the consent screen is in testing mode, the refresh token will only be valid for 7 days, which means your YouTube bot will not function as a fully automated system after that period. Ensure you complete this configuration to maintain a fully automated Youtube channel.
⭐ Support the Project
If you find this project helpful, please consider giving it a ⭐! Starring the repository helps others discover the project and motivates further development. Thank you for your support!
Ideas for Your Channel
Here are some content ideas for an automated YouTube channel you could do by modifying the bot:
- Relaxing Sleep/Meditation Videos (Current)
- Motivational Quotes
- Meme Compilations
- Music Lyrics Videos
- Reddit Post Discussions
License
This project is licensed under the MIT License.