fix and working Clips downloader/uploader

This commit is contained in:
2026-07-17 23:08:26 -04:00
parent 8be00d16d1
commit 483a771575
5 changed files with 101 additions and 21 deletions
+23 -10
View File
@@ -86,10 +86,6 @@ def upload_video(file_path: str, title: str, category: CategoryId, description:
if not credentials:
return False
# Format release time to ISO 8601 UTC format (Required by YouTube)
# Example format generated: "2026-07-20T15:00:00Z"
publish_at_iso = release_time.strftime('%Y-%m-%dT%H:%M:%S.000Z')
# Create YouTube API client
youtube = build('youtube', 'v3', credentials=credentials)
@@ -98,7 +94,10 @@ def upload_video(file_path: str, title: str, category: CategoryId, description:
'selfDeclaredMadeForKids': False
}
if release_time:
if release_time is not None:
if release_time.tzinfo is None:
release_time = release_time.replace(tzinfo=timezone.utc)
# If release_time is passed, YouTube forces privacyStatus to 'private'
status_body['privacyStatus'] = 'private'
status_body['publishAt'] = release_time.strftime('%Y-%m-%dT%H:%M:%S.000Z')
@@ -119,7 +118,6 @@ def upload_video(file_path: str, title: str, category: CategoryId, description:
'status': status_body
}
# Create media file upload
media = MediaFileUpload(
file_path,
@@ -162,12 +160,27 @@ def upload_video(file_path: str, title: str, category: CategoryId, description:
return False
def main():
# FIXED: Reconstructed arguments to provide all required inputs for upload_video
parser = argparse.ArgumentParser(description='Upload a video to YouTube')
parser.add_argument('file', help='Path to the video file')
parser.add_argument('description', help='Video description')
parser.add_argument('--file', required=True, help='Path to the video file')
parser.add_argument('--title', required=True, help='Title of the video')
parser.add_argument('--category', default='PEOPLE_AND_BLOGS', choices=[c.name for c in CategoryId], help='Video category genre')
parser.add_argument('--description', default='', help='Video description text')
parser.add_argument('--privacy', default='private', choices=['public', 'private', 'unlisted'], help='Video privacy settings')
args = parser.parse_args()
upload_video(args.file, args.description)
# Map the text input choice back to your CategoryId Enum object
chosen_category = CategoryId[args.category]
# FIXED: Properly pass all required positional and optional parameters
upload_video(
file_path=args.file,
title=args.title,
category=chosen_category,
description=args.description,
privacyStatus=args.privacy
)
if __name__ == "__main__":
main()
main()