我使用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来提取实时视频。
发布于 2019-09-17 15:59:46
这不是一个答案,但似乎端点没有返回任何最近的视频,包括现场直播。据我所知,它没有返回在前24小时发布的任何内容。
在Google Support https://support.google.com/youtube/thread/14611425?hl=en上发现了一个悬而未决的问题
发布于 2020-03-04 03:59:32
作为另一种选择,您可以加载“上载”播放列表,检查https://stackoverflow.com/a/27872244/2154075
发布于 2020-08-20 11:41:47
试试这段代码
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;
}
}https://stackoverflow.com/questions/57876494
复制相似问题