Youtube /v3/search API no longer returning live videos
Asked Answered
G

4

9

I was using the YouTube search API to retrieve live videos by channel ID, but recently, the API has begun to return an empty response.

For example, I am retrieving from https://www.googleapis.com/youtube/v3/search?part=snippet&type=video&eventType=live&key={YOUTUBE_KEY}&channelId=UCPde4guD9yFBRzkxk2PatoA which should return all videos which are live from channelID = UCPde4guD9yFBRzkxk2PatoA. This channel has a 24/7 live stream, but the response I get back is:

{
 "kind": "youtube#searchListResponse",
 "etag": "\"8jEFfXBrqiSrcF6Ee7MQuz8XuAM/-f6JA5_OcXz2RWuH1mpAA2_9mM8\"",
 "regionCode": "US",
 "pageInfo": {
  "totalResults": 0,
  "resultsPerPage": 5
 },
 "items": []
}

As I mentioned before, this request was retrieving data fine up until recently. I was unable to find any changes on the YouTube API docs, so I'm wondering if anyone has any idea on what changed or if there's a different approach I can take to pull live videos by channel ID.

Grecism answered 10/9, 2019 at 18:33 Comment(0)
P
4

Not an answer, but it seems that endpoint isn't returning ANY recent videos that would include live. From what I can tell it doesn't return anything published in the previous 24 hours.

Found an open issue on Google Support https://support.google.com/youtube/thread/14611425?hl=en

Pasahow answered 17/9, 2019 at 15:59 Comment(1)
Thank you for the info. It sounds like there's an actual problem with the API then.Grecism
P
1

As an alternative, instead, you could load "uploads" playlist, check https://mcmap.net/q/98967/-youtube-api-to-fetch-all-videos-on-a-channel

Peseta answered 4/3, 2020 at 3:59 Comment(0)
S
0

try this code

   async static Task<IEnumerable<YouTubeVideo>> GetVideosList(Configurations configurations, string searchText = "", int maxResult = 20)
    {
        List<YouTubeVideo> videos = new List<YouTubeVideo>();

        using (var youtubeService = new YouTubeService(new BaseClientService.Initializer()
        {
            ApiKey = configurations.ApiKey
        }))
        {
            var searchListRequest = youtubeService.Search.List("snippet");
            searchListRequest.Q = searchText;
            searchListRequest.MaxResults = maxResult;
            searchListRequest.ChannelId = configurations.ChannelId;
            searchListRequest.Type = "video";
            searchListRequest.Order = SearchResource.ListRequest.OrderEnum.Date;// Relevance;


            var searchListResponse = await searchListRequest.ExecuteAsync();


            foreach (var responseVideo in searchListResponse.Items)
            {
                videos.Add(new YouTubeVideo()
                {
                    Id = responseVideo.Id.VideoId,
                    Description = responseVideo.Snippet.Description,
                    Title = responseVideo.Snippet.Title,
                    Picture = GetMainImg(responseVideo.Snippet.Thumbnails),
                    Thumbnail = GetThumbnailImg(responseVideo.Snippet.Thumbnails)
                });
            }

            return videos;
        }

    }
Semiliquid answered 20/8, 2020 at 11:41 Comment(0)
T
0
Trump answered 20/8, 2020 at 11:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.