A Python tool for automating video uploads to YouTube, with support for .ts
to .mp4
conversion and playlist management.
- Automatic video conversion from
.ts
to.mp4
format using FFmpeg - Batch upload of videos to YouTube
- Automatic playlist management
- Token-based authentication with refresh capabilities
- Progress tracking for uploads
- Error handling and logging
- Python 3.6+
- FFmpeg installed and accessible in system PATH
- Google Cloud Project with YouTube Data API v3 enabled
- OAuth 2.0 Client credentials
- Clone the repository:
git clone https://github.com/yourusername/youtube-uploader.git
cd youtube-uploader
- Create and activate a virtual environment:
python -m venv youtube_env
source youtube_env/bin/activate # On Windows: youtube_env\Scripts\activate
- Install required packages:
pip install -r requirements.txt
-
Set up Google Cloud Project:
- Go to Google Cloud Console
- Create a new project or select existing one
- Enable YouTube Data API v3
- Create OAuth 2.0 credentials (Desktop application)
- Download the credentials and save as
client.json
in project root
-
First run will generate
token.json
for authentication:- Script will open browser window for Google authentication
- Grant necessary permissions
- Token will be saved automatically
- Edit
uploader.py
and set your configuration:
source_dir = "PATH_TO_YOUR_VIDEOS" # Absolute path to video directory
playlist_id = "YOUR_PLAYLIST_ID" # YouTube playlist ID
- Run the script:
python uploader.py
youtube-uploader/
├── __pycache__/
├── youtube_env/
├── .gitignore # Excludes client.json and token.json
├── README.md
├── requirements.txt
└── uploader.py
client.json
: OAuth 2.0 client credentials (not included, must be obtained from Google Cloud Console)token.json
: Authentication token (generated on first run)
Both files are excluded in .gitignore
for security reasons.
The script includes comprehensive error handling for:
- File conversion failures
- Upload interruptions
- Authentication issues
- Token refresh problems
- Playlist management errors
- Ensure sufficient disk space for video conversion
- Check YouTube quota limits before bulk uploads (Activate two-step verification or the upload limit will be incredbly low).
- Keep authentication tokens secure
- Script uses unlisted privacy setting for uploads
- Includes 2-second delay between uploads to prevent API throttling
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a new Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.