This repository has been archived by the owner on Jun 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 80
/
upload_ytvid.py
54 lines (45 loc) · 1.57 KB
/
upload_ytvid.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import datetime
from googleapiclient.http import MediaFileUpload
def uploadYtvid(VIDEO_FILE_NAME='',
title='Intro Video!',
description=':) ',
tags=[],
modeAM = "A",
googleAPI=None):
now = datetime.datetime.now()
upload_date_time = datetime.datetime(now.year, now.month, now.day, now.hour, now.minute, int(now.second)).isoformat() + '.000Z'
request_body = {
'snippet': {
'categoryId': 23,
'title': title,
'description': description,
'tags': tags
},
'status': {
'privacyStatus': 'public',
'selfDeclaredMadeForKids': False,
},
'notifySubscribers': False
}
mediaFile = MediaFileUpload(VIDEO_FILE_NAME, chunksize=-1, resumable=True)
response_upload = googleAPI.videos().insert(
part='snippet,status',
body=request_body,
media_body=mediaFile
).execute()
def thumbnail_upload():
googleAPI.thumbnails().set(
videoId=response_upload.get('id'),
media_body=MediaFileUpload('thumbnail.png')
).execute()
if modeAM == "A":
thumbnail_upload()
elif modeAM == "M":
wanna_thum = input("[Q] Do you wanna upload thumbnail.png?(y/N):").strip()
if wanna_thum.lower() == "y":
thumbnail_upload()
else:
print("[i] No Custom thumbnail uploaded.")
print("Upload Successful!")
if __name__ == "__main__":
uploadYtvid(VIDEO_FILE_NAME='./intro_vid.mp4')