如何使用 YouTube API 获取特定直播视频的当前观众人数? [英] How to get current number of viewers for specific live video with YouTube API?

查看:21
本文介绍了如何使用 YouTube API 获取特定直播视频的当前观众人数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 YouTube API 获取实时视频的当前观看人数?

How to get current number of viewers for live video with YouTube API?

我可以看到当前观看者的数量使用这样的视频供稿请求:https://gdata.youtube.com/feeds/api/charts/live/events/live_now?v=2&alt=json&inline=true&max-results=20&start-index=1

I can see number of current viewers using request for feed of videos like this: https://gdata.youtube.com/feeds/api/charts/live/events/live_now?v=2&alt=json&inline=true&max-results=20&start-index=1

它会返回随机视频,但我需要获取特定视频的当前观众.因此,当我使用视频请求时(例如 https://gdata.youtube.com/feeds/api/videos/fWuS8hM_5D8?v=2&alt=json )没有 currentViewers 字段,只有 viewCount.

It returns me random videos, but I need to get current viewers for specific video. So when I using request for video ( like this https://gdata.youtube.com/feeds/api/videos/fWuS8hM_5D8?v=2&alt=json ) there is no currentViewers field, onlie viewCount.

这个问题有解决办法吗?

Is there any solution of this issue?

推荐答案

现在可以使用 V3 的 YouTube API ...您请求视频对象,传入代表直播流的 videoID,并请求liveStreamingDetails"部分.返回的参数之一是concurrentViewers"——更多信息:

This is now possible with V3 of the YouTube API ... you request the videos object, passing in the videoID that represents the live stream, and ask for the "liveStreamingDetails" part. One of the parameters returned will be "concurrentViewers" -- for more info:

https://developers.google.com/youtube/v3/docs/videos#liveStreamingDetails.concurrentViewers

这篇关于如何使用 YouTube API 获取特定直播视频的当前观众人数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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