'Python script end Youtube live stream

i have an AJA HELO media streaming device and from time to time it stops streaming. What i want to do it automate some kind of streaming reset. I am able to issue command to the AJA to stop and start streaming, but i need help figuring out how to "End Stream" on my current Youtube Live stream. Just doing so on the AJA does nothing since Youtube still thinks the stream will be back shortly.

Does anyone know of a way to achieve this?

P.S. i am able to retrieve the exact stream identifier via a Python script, as i am monitoring the state in an NMS.

Thanks



Solution 1:[1]

I'm not sure if this is directly related, but to end a livestream using the Python google-api-python-client library:

        youtube = build("youtube", "v3", credentials = [YOUR CREDENTIALS])
        
        request = youtube.liveBroadcasts().transition(
            part = 'snippet',
            id = [VIDEO ID OF THE LIVESTREAM],
            broadcastStatus = 'complete'
            #Setting the 'broadcastStatus' to 'complete' ends the stream

        )
        response = request.execute()

You can find more details about this in the docs here (including POST): https://developers.google.com/youtube/v3/live/docs/liveBroadcasts/transition

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sludge