-
Notifications
You must be signed in to change notification settings - Fork 288
/
upload_ytvid.py
45 lines (37 loc) · 1.21 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
import datetime
from googleapiclient.http import MediaFileUpload
def uploadYtvid(VIDEO_FILE_NAME='',
title='Intro Video!',
description=':) ',
tags=[],
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()
"""
googleAPI.thumbnails().set(
videoId=response_upload.get('id'),
media_body=MediaFileUpload('thumbnail.png')
).execute()
"""
print("Upload Successful!")
if __name__ == "__main__":
uploadYtvid(VIDEO_FILE_NAME='./intro_vid.mp4')