mirror of
https://git.lecygnenoir.info/LecygneNoir/prismedia.git
synced 2025-10-03 09:29:16 +02:00
Add the publishAt option to allow planned publication for your videos. See README for prerequisites
This commit is contained in:
parent
8968438af2
commit
d2c6154738
5 changed files with 95 additions and 4 deletions
|
@ -10,6 +10,9 @@ import copy
|
|||
import json
|
||||
from os.path import splitext, basename, exists
|
||||
import google.oauth2.credentials
|
||||
import datetime
|
||||
import pytz
|
||||
from tzlocal import get_localzone
|
||||
|
||||
from googleapiclient.discovery import build
|
||||
from googleapiclient.errors import HttpError
|
||||
|
@ -100,10 +103,19 @@ def initialize_upload(youtube, options):
|
|||
},
|
||||
"status": {
|
||||
"privacyStatus": str(options.get('--privacy') or "private"),
|
||||
"license": str(license or "youtube")
|
||||
"license": str(license or "youtube"),
|
||||
}
|
||||
}
|
||||
|
||||
if options.get('--publishAt'):
|
||||
# Youtube needs microsecond and the local timezone from ISO 8601
|
||||
publishAt = options.get('--publishAt') + ".000001"
|
||||
publishAt = datetime.datetime.strptime(publishAt, '%Y-%m-%dT%H:%M:%S.%f')
|
||||
tz = get_localzone()
|
||||
tz = pytz.timezone(str(tz))
|
||||
publishAt = tz.localize(publishAt).isoformat()
|
||||
body['status']['publishAt'] = str(publishAt)
|
||||
|
||||
# Call the API's videos.insert method to create and upload the video.
|
||||
insert_request = youtube.videos().insert(
|
||||
part=','.join(body.keys()),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue