This commit is contained in:
2026-07-16 14:56:28 -04:00
parent efba28a7b5
commit 26bb38c2aa
+45 -4
View File
@@ -2,6 +2,7 @@
import os
import json
import argparse
from enum import Enum, auto, unique
from google.oauth2.credentials import Credentials
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
@@ -9,6 +10,41 @@ from googleapiclient.discovery import build
from googleapiclient.http import MediaFileUpload
from googleapiclient.errors import HttpError
@unique
class CategoryId(Enum):
FILM_ANIMATION = 1
AUTOS_VEHICLES = 2
MUSIC = 10
PETS_ANIMALS = 15
SPORTS = 17
SHORT_MOVIES = 18
TRAVEL_EVENTS = 19
GAMING = 20
VIDEOBLOGGING = 21
PEOPLE_BLOGS = 22
COMEDY = 23
ENTERTAINMENT = 24
NEWS_POLITICS = 25
HOWTO_STYLE = 26
EDUCATION = 27
SCIENCE_TECHNOLOGY = 28
NONPROFITS_ACTIVISM = 29
MOVIES = 30
ANIME_ANIMATION = 31
ACTION_ADVENTURE = 32
CLASSICS = 33
COMEDY_MOVIE = 34 # Renamed to avoid name collision
DOCUMENTARY = 35
DRAMA = 36
FAMILY = 37
FOREIGN = 38
HORROR = 39
SCI_FI_FANTASY = 40
THRILLER = 41
SHORTS = 42
SHOWS = 43
TRAILERS = 44
def load_credentials():
"""Load credentials from secrets.json"""
try:
@@ -36,13 +72,17 @@ def load_credentials():
print(f"Error loading credentials: {str(e)}")
return None
def upload_video(file_path, description):
def upload_video(file_path: str, title: str, description: str, category: CategoryId, privacyStatus: str = 'private', tags: list = []):
"""
Upload a video to YouTube
Args:
file_path (str): Path to the video file
title (str): Title of the Video
description (str): Video description
categoryId (str): categoryId of the video
privacyStatus (str): privacyStatus of the video
tags (str): tags to be use on the video
"""
try:
# Check if file exists
@@ -66,15 +106,16 @@ def upload_video(file_path, description):
'snippet': {
'title': title,
'description': description,
'tags': [],
'categoryId': '22' # Default to 'People & Blogs' category
'tags': tags,
'categoryId': str(category.value) # Default to 'People & Blogs' category
},
'status': {
'privacyStatus': 'private', # Default to private
'privacyStatus': privacyStatus, # Default to private
'selfDeclaredMadeForKids': False
}
}
# Create media file upload
media = MediaFileUpload(
file_path,