如何使用YouTube API获取特定直播视频的当前观看人数? [英] How to get current number of viewers for specific live video with YouTube API?
问题描述
如何通过YouTube API获得当前观看实时视频的观众人数?
How to get current number of viewers for live video with YouTube API?
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?
推荐答案
现在可以通过YouTube API的V3实现……您请求视频对象,并传递代表实时流的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屋!