YouTube Streaming API returns no results - youtube-api

I'm using Google's YouTube API Explorer (alternate) to look up information on streaming broadcasts.
No matter what I put into the various "Filter" fields (id, broadcastStatus, mine), I always get back something like
{
"kind": "youtube#liveBroadcastListResponse",
"etag": "\"sGDdEsjSJ_SnACpEvVQ6MtTzkrI/1a_a-Wfcf01HR1raH5I2Na5kI1o\"",
"pageInfo": {
"totalResults": 0,
"resultsPerPage": 5
},
"items": [
]
} // (The etag changes each time)
This seems ridiculous, considering that someone somewhere is demonstrably streaming.
It makes sense that mine=true doesn't return any results because I've never broadcasted anything, but broadcastStatus=all should give me something.
What is going wrong?

I know this is an old question but I've encountered the same issue yesterday and it seems that I'm missing the broadcastType parameter.
Acceptable values are:
all – Return all broadcasts.
event – Return only scheduled event broadcasts.
persistent – Return only persistent broadcasts.
https://developers.google.com/youtube/v3/live/docs/liveBroadcasts/list
So my final request looks like:
https://www.googleapis.com/youtube/v3/liveBroadcasts?part=id&mine=true&broadcastType=all

In response to a bug report issued by DaImTo, Google has responded by telling us that we are not permitted to see live broadcasts by other users.
ma…#google.com <ma…#google.com> #3 Jun 25, 2018 07:11 PM
Status: Won't Fix (Intended Behavior)
The Live Streaming API only permits you to list the live broadcasts of the authenticated user.
However, an answer to a similar question can retrieve currently streaming events by parsing the href attribute of <link rel="canonical" /> on the channel page.

Related

Youtube Data API search.list malfunctioning for live streams

We are finding that the YouTube API is intermittently misreporting zero live streams within channel searches when specifically asking for eventType=live. It seems the timing for this issue is random but, for example, the following API call will either return everything or nothing, without changing any parameters. Our quota is fine. The channel (and many others we have tried) have multiple live webcam streams on 24/7 so they are not all going on and offline from one second to the next.
This is the API call (with API key removed):
https://youtube.googleapis.com/youtube/v3/search?part=snippet&eventType=live&type=video&channelId=UCY6XpD-K4mNk_C97pMiMJ8A&maxResults=50&key=(removed).
It’ll work sometimes, and not other times. At any attempt there are many live streams in that channel.
The “nothing” response is as follows:
{
"kind": "youtube#searchListResponse",
"etag": "LgldeqxlASUfgtUiqLulF4E6Tcw",
"regionCode": "GB",
"pageInfo": {
"totalResults": 0,
"resultsPerPage": 0
},
"items": []
}
Which is wrong at the time of the request.
If we remove eventType=live then when this issue is occurring we notice the live streams‘s liveBroadcastContent parameter are all marked with none instead of live.
This appears to be an API bug and it’s hindering development of our tool. Please help!
Pat

YouTube Data API - channel IDs changed overnight at 28 of February

We are handling several YT channels for our customers via the Data API. Since 28 of February, we are getting strange responses on https://developers.google.com/youtube/v3/docs/channels/list#part and https://developers.google.com/youtube/v3/docs/search/list endpoints. In most cases, the response contains an empty items list but returns with 200. It looks like the access token is fine (otherwise it would return with 403 or something similar) but it's not connected to any channel.
E.g.:
https://www.googleapis.com/youtube/v3/channels?id=&part=snippet%2CcontentDetails%2Cstatistics
returns with:
{
"items": [],
"kind": "youtube#channelListResponse",
"etag": <etag>,
"pageInfo": {
"resultsPerPage": 0,
"totalResults": 0
}
}
We have noticed a strange behavior in some cases when calling the same endpoint with "mine=true". It gave back channel details in the items list but the ID of the channel in the response is different than the ID we store for the same channel. We tried to call the endpoint with the ID from the response and the access token we store and it worked fine. The "publishedAt" section of the response shows that this channel has been created at "2017-05-19T18:59:45.000Z" so it's not a new one and according to our logs before 2020-02-28 it worked fine with our ID.
These circumstances make me think the ID of several channels has just changed and that's why we are getting these strange or empty responses.
Has anybody else experienced the same issues?
Please note that I'm not talking about items[] in invideoPromotion, I know that part is deprecated.

How to create persistent livebroadcast?

I develop the mobile app with livestream feature and I need to get default livebroadcast with default livestream data.
When user didn't enable livestreams in his youtube account I show him message with link to https://www.youtube.com/live_streaming_signup .
After if user enabled livestreams in his youtube account I can't get default livebroadcast with broadcast type persistent.
My request url is: https://www.googleapis.com/youtube/v3/liveBroadcasts?part=contentDetails&mine=true&broadcastType=persistent&access_token=
My response is:
{
"kind": "youtube#liveBroadcastListResponse",
"etag": "\"I_8xdZu766_FSaexEaDXTIfEWc0/5WQLBG6RLCbLPgwsAs3o13sBM98\"",
"pageInfo": {
"totalResults": 0,
"resultsPerPage": 5
},
"items": [
{
"kind": "youtube#liveBroadcast",
"etag": "\"I_8xdZu766_FSaexEaDXTIfEWc0/vyGp6PvFo4RvsFtPoIWeCReyIC8\""
}
]
}
Only after go to live dashboard page stream now I can got default livebroadcast with broadcast type persistent and then got livestream by default livebroadcast boundStremId
Why? How I can get default livebroadcast and default livestream without go to livestream dashboard?
I tried your query, and just like you, I can get 200 response, but I can only get 1 result. So the alternative way that I used to get the live broadcast is by using the Search: list under the DATA API. Here, you can use the eventType=live to get the live broadcast video.
GET https://www.googleapis.com/youtube/v3/search?part=snippet&eventType=live&type=video&key={YOUR_API_KEY}
For the persistent broadcast, try to check this SO question if it can help you.
For more information check these related SO questions:
YouTube API live broadcast
How to get list of live video broadcasts using youtube api v3

How can I figure the youtube video out whether it is private or not existed?

When I use video.list with API_KEY (not authenticated with OAuth) for a private or not existed (maybe deleted or invalid video id) video, I can't know status of the video at all. It just only gives empty items.
GET https://www.googleapis.com/youtube/v3/videos?part=snippet&id=foo&key={API_KEY}
{
"kind": "youtube#videoListResponse",
"etag": "\"q5k97EMVGxODeKcDgp8gnMu79wM/Rk41fm-2TD0VG1yv0-bkUvcBi9s\"",
"pageInfo": {
"totalResults": 0,
"resultsPerPage": 0
},
"items": [
]
}
The document is telling me if I can't find video resource, you will get an error. But, it doesn't happen to me whatever id is. I've found out the solution in similar situation for Playlist case before, it was possible to catch the information to use playlistItem.list indirectly. However, in this situation, how can I find out the status?
Tried it out myself. Returned with a response status of 200, message null and an empty JSON item object too. It's weird that this is handled for playlistitems.list but not for video.list. Google Developers might have missed out on handling these kinds of scenarios for video.list. Guess there's really no way of telling if a video is private or if it even did exist at all using the Youtube Data API.
What I thought of is to try to make requests directly to the Youtube URL using the url
https://www.youtube.com/watch?v=<id>
then just check at the contents of <div class =”content”>
You can try to do this by using XPath or any similar XML traversing tools.

YouTube API - No channel branding settings returned for queries by username

When using the YouTube API v3 to query a channel's branding settings, why are they returned for queries by channel ID, but not for queries by username? The API doesn't return branding settings for channel list queries by username.
If you query for a channel's branding settings by channel ID (e.g., id=UC8-Th83bH_thdKZDJCrn88g), you are returned a complete set of branding settings:
Google API Explorer: https://developers.google.com/youtube/v3/docs/channels/list
Request
GET https://www.googleapis.com/youtube/v3/channels?part=brandingSettings&id=UC8-Th83bH_thdKZDJCrn88g&key={YOUR_API_KEY}
Response
{
// ... snip ...
"items": [
{
"kind": "youtube#channel",
"etag": "\"...\"",
"id": "UC8-Th83bH_thdKZDJCrn88g",
"brandingSettings": {
"channel": {
"title": "The Tonight Show Starring Jimmy Fallon",
"description": "Watch The Tonight Show Starring Jimmy Fallon Weeknights 11:35/10:35c\n\nThe Tonight Show Starring Jimmy Fallon features hilarious highlights from the show including: comedy sketches, music parodies, celebrity interviews, ridiculous games, and, of course, Jimmy's Thank You Notes and hashtags! You'll also find behind the scenes videos and other great web exclusives.",
// all the branding settings are here
}
}
}]
}
If, on the other hand, you send a channel list query for a username (e.g., forUsername=latenight), you get no branding settings at all. The branding settings aren't returned or populated.
Request
GET https://www.googleapis.com/youtube/v3/channels?part=brandingSettings&forUsername=latenight&key={YOUR_API_KEY}
Response
{
// ... snip ...
"items": [
{
"kind": "youtube#channel",
"etag": "\"...\"",
"id": "UC8-Th83bH_thdKZDJCrn88g"
}]
}
I may be wrong, but I believe that, in v3 of the APIs, Channel IDs are the only way to get a full response, as the concept of a "username" doesn't really exist in the same way anymore. That is, newly created YouTube channels are linked to a G+ profile and can have a display name, but there isn't really any YouTube username anymore associated with such a channel.
Because usernames used to exist, though, and many channels are still known by them, the "forUsername" parameter is there to provide you the associated channelID and then issue the request for the branding settings with that.
Now, having said that, it's clear that the language on the API explorer page doesn't reflect that, and perhaps therein lies the problem; I'm taking my inferences from this documentation:
https://developers.google.com/youtube/v3/guides/working_with_channel_ids#v3
and from this bug report:
https://code.google.com/p/gdata-issues/issues/detail?id=4821&q=forUsername&colspec=API%20ID%20Type%20Status%20Priority%20Stars%20Summary
But it's always possible, too, that I'm reading incorrectly and you're actually seeing a new bug. The only way to know for sure would be to file it (or perhaps someone on the team could comment here)?

Resources