Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3831

Is there a way to use the API to schedule a Live Stream Broadcast and add it to an existing playlist and specify the stream key?

$
0
0

I played around with the YouTube Data API and I was able to get a working poc of creating a scheduled live broadcast for my channel. However, in looking through the rest of the documentation I couldn't see that it was possible to add the stream to an existing playlist or specify the stream key. This is my poc code so far

# -*- coding: utf-8 -*-import osfrom datetime import datetime, timedeltaimport google_auth_oauthlib.flowimport googleapiclient.discoveryimport googleapiclient.errorsscopes = ["https://www.googleapis.com/auth/youtube.force-ssl"]def main():    date = datetime.today()    while date.weekday() != 6:      date+=timedelta(1)    date = date.isoformat() +"Z"    # Disable OAuthlib's HTTPS verification when running locally.    # *DO NOT* leave this option enabled in production.    os.environ["OAUTHLIB_INSECURE_TRANSPORT"] = "1"    api_service_name = "youtube"    api_version = "v3"    client_secrets_file = "client_secret.json"    # Get credentials and create an API client    flow = google_auth_oauthlib.flow.InstalledAppFlow.from_client_secrets_file(        client_secrets_file, scopes)    credentials = flow.run_console()    youtube = googleapiclient.discovery.build(        api_service_name, api_version, credentials=credentials)    request = youtube.liveBroadcasts().insert(        part="snippet,contentDetails,status",        access_token="REDACTED",        body={"contentDetails": {"enableAutoStart": True,"enableAutoStop": True          },"snippet": {"title": "Meeting","scheduledStartTime": date,"thumbnails": {"default": {"url": "https://50801759971_0dbb60afdf.jpg"                }             }          },"status": {"privacyStatus": "unlisted","selfDeclaredMadeForKids": False          }        }    )    response = request.execute()

Viewing all articles
Browse latest Browse all 3831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>