gpt4 book ai didi

javascript - 是否可以通过 YouTube API 获取有多少人正在观看 YouTube 直播视频?

转载 作者:行者123 更新时间:2023-11-28 14:17:16 25 4
gpt4 key购买 nike

我将使用 YouTube API 构建一个应用程序。我从 API 获取视频事件并在视频上线时在网站上播放视频。

我正在获取所需的所有数据,除了观看视频的人数之外。

有什么办法可以得到它吗?

最佳答案

您可以在请求视频详细信息时通过请求 liveStreamingDetails 部分来获取这些统计信息。以下是 HTTPS 请求示例 ( ref ):

GET https://www.googleapis.com/youtube/v3/videos?part=snippet%2Cstatistics%2CliveStreamingDetails&id=21X5lGlDOfg&key=[YOUR_API_KEY] HTTP/1.1

Authorization: Bearer [YOUR_ACCESS_TOKEN]
Accept: application/json

结果:

{
"kind": "youtube#videoListResponse",
"etag": "\"Bdx4f4ps3xCOOo1WZ91nTLkRZ_c/ARYNDpdj0hFzJ8zKV9SLVLV4PWE\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#video",
"etag": "\"Bdx4f4ps3xCOOo1WZ91nTLkRZ_c/_SdqmAfikf6n_Jny6hfytlYz1wY\"",
"id": "21X5lGlDOfg",
"snippet": {
"publishedAt": "2018-12-28T18:40:15.000Z",
"channelId": "UCLA_DiR1FfKNvjuUpBHmylQ",
"title": "NASA Live: Official Stream of NASA TV",
"description": "Direct from America's space program to YouTube, watch NASA TV live streaming here to get the latest from our..."
},
"statistics": {
"viewCount": "8512883",
"likeCount": "130811",
"dislikeCount": "6836",
"favoriteCount": "0",
"commentCount": "0"
},
"liveStreamingDetails": {
"actualStartTime": "2018-12-28T18:41:30.221Z",
"scheduledStartTime": "2018-12-28T19:00:00.000Z",
"concurrentViewers": "108"
}
}
]
}

看看 concurrentViewers 元素。

关于javascript - 是否可以通过 YouTube API 获取有多少人正在观看 YouTube 直播视频?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56888608/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com