Tuesday, March 31, 2026

Download Video from Google Drive & Upload to YouTube using Python

Download Video from Google Drive & Upload to YouTube using Python

🚀 How to Download Video from Google Drive & Upload to YouTube using Python

This guide will help you automate the process of downloading videos from Google Drive and uploading them directly to YouTube using Python.


🔧 Step 1: Install Required Libraries

pip install gdown google-api-python-client google-auth-httplib2 google-auth-oauthlib

📥 Step 2: Download Video from Google Drive

Use the following Python script to download a video using the file ID:

import gdown

def download_from_drive(file_id, output_name):
    url = f"https://drive.google.com/uc?id={file_id}"
    gdown.download(url, output_name, quiet=False)

# Example
file_id = "YOUR_FILE_ID"
file_name = "video.mp4"

download_from_drive(file_id, file_name)

📌 How to Get File ID

Example link:

https://drive.google.com/file/d/1ABCxyz123/view?usp=sharing

File ID: 1ABCxyz123


📤 Step 3: Upload Video to YouTube

Before using this script:

  • Create a project in Google Cloud Console
  • Enable YouTube Data API
  • Download client_secret.json
import google_auth_oauthlib.flow
import googleapiclient.discovery
import googleapiclient.http

def upload_to_youtube(video_file):
    scopes = ["https://www.googleapis.com/auth/youtube.upload"]

    flow = google_auth_oauthlib.flow.InstalledAppFlow.from_client_secrets_file(
        "client_secret.json", scopes)
    credentials = flow.run_console()

    youtube = googleapiclient.discovery.build("youtube", "v3", credentials=credentials)

    request = youtube.videos().insert(
        part="snippet,status",
        body={
            "snippet": {
                "title": "My Uploaded Video",
                "description": "Uploaded using Python script",
                "tags": ["automation", "python"],
                "categoryId": "22"
            },
            "status": {
                "privacyStatus": "private"
            }
        },
        media_body=googleapiclient.http.MediaFileUpload(video_file)
    )

    response = request.execute()
    print("Upload Successful:", response)

upload_to_youtube("video.mp4")

⚡ Final Combined Script

file_id = "YOUR_FILE_ID"
file_name = "video.mp4"

download_from_drive(file_id, file_name)
upload_to_youtube(file_name)

⚠️ Important Notes

  • Use only your own or permitted files
  • Do not bypass Google Drive limits
  • First run will require YouTube login permission

💡 Pro Tips

  • Use high-speed internet for faster uploads
  • Optimize video title, tags, and description for SEO
  • Keep videos under YouTube size limits

🔥 Conclusion

This automation script saves time by handling both downloading and uploading processes efficiently. Perfect for content creators and developers!