Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- What I think is happening here is that you're mixing up the signal and the event.
- Your code seems fine, it creates a broadcast, but nowhere in the code do you link it to the signal that the camera sends. So, you end up with a camera signal that goes to ingestion endpoint A, and then you've got the event (public-facing title, description, etc) which doesn't connect in any way to ingestion endpoint A (hope this makes sense).
- I haven't used their API in ages, but there appears to be a bind you can use: https://developers.google.com/youtube/v3/live/docs/liveBroadcasts/bind
- This is their example python code:
- # -*- coding: utf-8 -*-
- # Sample Python code for youtube.liveBroadcasts.bind
- # See instructions for running these code samples locally:
- # https://developers.google.com/explorer-help/code-samples#python
- import os
- import google_auth_oauthlib.flow
- import googleapiclient.discovery
- import googleapiclient.errors
- scopes = ["https://www.googleapis.com/auth/youtube.force-ssl"]
- def main():
- # 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 = "YOUR_CLIENT_SECRET_FILE.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().bind(
- id="YOUR_BROADCAST_ID",
- part="snippet",
- streamId="YOUR_STREAM_ID"
- )
- response = request.execute()
- print(response)
- if __name__ == "__main__":
- main()
- So, you'll have to add this as a new function, something like:
- def bind_broadcast_to_stream(youtube, broadcast_id, stream_id):
- request = youtube.liveBroadcasts().bind(
- part="id,snippet,contentDetails,status",
- id=broadcast_id,
- streamId=stream_id
- )
- response = request.execute()
- print(f"Broadcast {broadcast_id} has been bound to stream {stream_id}.")
- return responsedef bind_broadcast_to_stream(youtube, broadcast_id, stream_id):
- request = youtube.liveBroadcasts().bind(
- part="id,snippet,contentDetails,status",
- id=broadcast_id,
- streamId=stream_id
- )
- response = request.execute()
- print(f"Broadcast {broadcast_id} has been bound to stream {stream_id}.")
- return response
Advertisement
Add Comment
Please, Sign In to add comment