Youtube /v3/search API不再返回直播视频。

9
我使用YouTube搜索API通过频道ID检索实时视频,但最近,该API开始返回空响应。
例如,我正在从https://www.googleapis.com/youtube/v3/search?part=snippet&type=video&eventType=live&key={YOUTUBE_KEY}&channelId=UCPde4guD9yFBRzkxk2PatoA检索,这应该返回所有来自channelID = UCPde4guD9yFBRzkxk2PatoA的实时视频。 这个频道有24/7的直播流,但我收到的响应是:
{
 "kind": "youtube#searchListResponse",
 "etag": "\"8jEFfXBrqiSrcF6Ee7MQuz8XuAM/-f6JA5_OcXz2RWuH1mpAA2_9mM8\"",
 "regionCode": "US",
 "pageInfo": {
  "totalResults": 0,
  "resultsPerPage": 5
 },
 "items": []
}

如我之前所提到的,这个请求最近一直能够成功地检索数据。我在 YouTube API 文档中没有发现任何更改,因此我想知道是否有人知道发生了什么变化,或者是否有不同的方法可以通过频道 ID 拉取实时视频。

4个回答

4

这并不是一个答案,但看起来终点没有返回包括直播的任何最新视频。从我所了解的情况来看,它不会返回过去24小时内发布的任何东西。

在Google支持中心找到一个未解决的问题 https://support.google.com/youtube/thread/14611425?hl=en


谢谢您提供的信息。听起来API确实存在问题。 - ceejayc7

1

0

0

试试这段代码

   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;
        }

    }

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接