Skip to content

Python script that allows you to upload videos to YouTube using the YouTube Data API

Notifications You must be signed in to change notification settings

Yoguti/youtube-uploader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YouTube Video Uploader

A Python tool for automating video uploads to YouTube, with support for .ts to .mp4 conversion and playlist management.

Features

  • 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

Prerequisites

  • Python 3.6+
  • FFmpeg installed and accessible in system PATH
  • Google Cloud Project with YouTube Data API v3 enabled
  • OAuth 2.0 Client credentials

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/youtube-uploader.git
cd youtube-uploader
  1. Create and activate a virtual environment:
python -m venv youtube_env
source youtube_env/bin/activate  # On Windows: youtube_env\Scripts\activate
  1. Install required packages:
pip install -r requirements.txt

Configuration

  1. 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
  2. First run will generate token.json for authentication:

    • Script will open browser window for Google authentication
    • Grant necessary permissions
    • Token will be saved automatically

Usage

  1. 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
  1. Run the script:
python uploader.py

File Structure

youtube-uploader/
├── __pycache__/
├── youtube_env/
├── .gitignore        # Excludes client.json and token.json
├── README.md
├── requirements.txt
└── uploader.py

Authentication Files

  • 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.

Error Handling

The script includes comprehensive error handling for:

  • File conversion failures
  • Upload interruptions
  • Authentication issues
  • Token refresh problems
  • Playlist management errors

Notes

  • 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

Contributing

  1. Fork the repository
  2. Create your feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a new Pull Request

License

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

About

Python script that allows you to upload videos to YouTube using the YouTube Data API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages