通过 youtube api 检索视频的公共统计信息 [英] Retrieve public statistics of video via youtube api

查看:19
本文介绍了通过 youtube api 检索视频的公共统计信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以获取视频的公开统计数据吗?

It's possible to obtain public statistics of video?

使用这样的东西,我可以得到视频的总观看次数和喜欢计数:

Using something like this i can get just total views of video and like count:

https://www.googleapis.com/youtube/v3/videos?part=statistics&key=API_KEY&id=ekzHIouo8Q4

有可能获得那些公开的统计数据吗?我发现了这个问题

It's possible to get those public statistics? I found this question

Youtube GData API:检索公共统计数据

但也许有些事情发生了变化?

But maybe something has changed?

推荐答案

您需要创建 YouTubeService 对象并可以获取关键字的搜索结果

You would need to create YouTubeService object and can get search results for the keywords

YouTubeService youtubeService = new YouTubeService(new BaseClientService.Initializer()
{
  ApiKey = "dfhdufhdfahfujashfd",
  ApplicationName = this.GetType().ToString()
});

 var searchListRequest = youtubeService.Search.List("snippet");
      searchListRequest.Q = "cute cats"; 
      searchListRequest.MaxResults = 10;

  var searchListResponse = await searchListRequest.ExecuteAsync();
  var videoId = searchListResponse.Items.First().Id.VideoId is the unique id of the video

// Video Request    
VideosResource.ListRequest request = new VideosResource.ListRequest(youTubeService, "statistics")
{
  Id = videoId
};

VideoListResponse response = request.Execute();
if (response.Items.First() != null && response.Items.First().Statistics != null)
{
  Console.WriteLine(response.Items.First().Statistics.ViewCount);
}

这篇关于通过 youtube api 检索视频的公共统计信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆