Nagaraj
Nagaraj

Reputation: 374

How to get live video id from YouTube channel

YouTube API eventType=live not working, does anyone have an idea why?

 https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=UCmyKnNRH0wH-r8I-ceP-dsg&eventType=live&type=video&key=   

Without eventType was working fine (but not now):

https://www.youtube.com/embed/live_stream?channel=UCmyKnNRH0wH-r8I-ceP-dsg&autoplay=1

Upvotes: 2

Views: 3011

Answers (2)

terryoboy
terryoboy

Reputation: 154

Right now the YouTube API is not working, specifically for retrieving live streams of a specific channelId. In other words if you are setting channelId in the API call, you will get 0 results.

If you're using an API key rather than OAuth (not sure if OAuth works) the only work around at the moment is to use the API to search for a specific title. Here is my query URL below.

https://www.googleapis.com/youtube/v3/search?part=id%2Csnippet&type=video&maxResults=20&order=date&q=My+Uniquely+Titled+Livestream&key=[apiKey]

The results returned by the API will be from all of YouTube. (Note: the rest is done serverside) Put the results into an array and discard any that don't match your channelId. Then check the titles in an array and only get the video ID of the one that matches your desired title. That is the basic logic and it is sort of a rigid work around that won't work for most. But at least it will get you what you need until Google fixes the API.

Upvotes: 0

iserb
iserb

Reputation: 46

Looks like YouTube changed something in API, search.list really not returning live broadcast since end of last week.

If you have user's access token you can use https://www.googleapis.com/youtube/v3/liveBroadcasts?part=snippet&broadcastStatus=active&broadcastType=all endpoint to retrieve if any broadcast is live.

If you do not have user's access token, you can try this answer but i didn't check it if it is working

Anyway this question looks like to be a duplicate of this question

Upvotes: 3

Related Questions