Ben Hoff
Ben Hoff

Reputation: 1108

Get current stream URL out of Youtube Live API

Is there any way currently to get the livestream URL out of the Youtube Live API? I can get the id, but there doesn't appear to be anyway to change that into a URL.

Not that it should matter, but I'm using the Python youtube client.

Upvotes: 1

Views: 5335

Answers (1)

not_a_bot
not_a_bot

Reputation: 2362

[Edited] I believe you got the stream ID instead of the broadcast ID. Check the sample code to see how to get your channel's broadcast ID.

...

print "%s (%s)" % (broadcast["snippet"]["title"], broadcast["id"])

vs

...

print "%s (%s)" % (stream["snippet"]["title"], stream["id"])

Although both get an id value, they are two different objects, therefore they should give you two different IDs. Appending the broadcast ID to the URL I mentioned in the comments will give you the URL for the stream.

Update: If you created a live event via your YouTube channel, you can just use liveBroadcasts list to get the id, which will also be the video ID that you can use to get the URL. If you created a liveStream via insert(), you must also create a liveBroadcast using insert() and bind it to the liveStream with bind() before you can use liveBroadcasts list to get the ID.

Upvotes: 4

Related Questions