【问题标题】:Youtube /v3/search API no longer returning live videosYoutube /v3/search API 不再返回直播视频
【发布时间】:2020-01-12 13:08:47
【问题描述】:

我之前使用YouTube search 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 拉取实时视频。

【问题讨论】:

    标签: api youtube youtube-api youtube-data-api live-streaming


    【解决方案1】:

    不是答案,但似乎端点没有返回任何包含直播的最近视频。据我所知,它不会返回过去 24 小时内发布的任何内容。

    在 Google 支持上发现了一个未解决的问题 https://support.google.com/youtube/thread/14611425?hl=en

    【讨论】:

    • 感谢您提供的信息。听起来 API 确实存在问题。
    【解决方案2】:

    作为替代方案,您可以加载“uploads”播放列表, 检查https://stackoverflow.com/a/27872244/2154075

    【讨论】:

      【解决方案3】:

      试试这个代码

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

      【讨论】:

        【解决方案4】:

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2013-09-11
          • 2015-08-22
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2016-03-12
          • 2020-01-15
          相关资源
          最近更新 更多