文档中写道:
"liveChatId参数指定将返回消息的聊天室的ID。与广播相关联的实时聊天室ID在liveBroadcast资源的snippet.liveChatId属性中返回。"
但是,当使用API Explorer和youtube.liveBroadcasts.list获取liveBroadcast的片段时,返回的结果上没有liveChatId属性。
我使用以下URI(省略了键):
https://www.googleapis.com/youtube/v3/liveBroadcasts?part=snippet&mine=真实
我做错了什么?
以下是响应(一些值替换为…):
{
"kind": "youtube#liveBroadcastListResponse",
"etag": "...",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 5
},
"items": [
{
"kind": "youtube#liveBroadcast",
"etag": "...",
"id": "...",
"snippet": {
"publishedAt": "2016-04-18T17:04:24.000Z",
"channelId": "...",
"title": "...",
"description": "...",
"thumbnails": {
"default": {
"url": "...",
"width": 120,
"height": 90
},
"medium": {
"url": "...",
"width": 320,
"height": 180
},
"high": {
"url": "...",
"width": 480,
"height": 360
},
"standard": {
"url": "...",
"width": 640,
"height": 480
},
"maxres": {
"url": "...",
"width": 1280,
"height": 720
}
},
"scheduledStartTime": "1970-01-01T00:00:00.000Z",
"actualStartTime": "2016-04-18T17:04:24.250Z",
"isDefaultBroadcast": false
}
}
]
}
在请求时,流上也发生了活动对话。
显然,使用"立即流媒体"创建的直播不包含liveChatId,即使它们包含实时聊天。
有没有办法获得"立即流媒体"直播的liveChatId?
这是一篇相当古老的帖子,但鉴于我在互联网上到处寻找答案,却找不到答案,我希望有人能找到这篇文章。
要获取而非您的实时事件的liveChatId,您可以执行以下操作:
首先,获取videoId
response.items[0].id.videoId
然后获取liveStreamingDetails
buildApiRequest('GET',
'/youtube/v3/videos', {
'id': videoID,
'part': 'snippet,contentDetails,statistics,liveStreamingDetails'
});
现在,您可以通过以下方式从上面的响应中获取liveChatId:
response.items[0].liveStreamingDetails.activeLiveChatId
有没有办法获得"立即流媒体"直播的liveChatId?
是的,你可以。我有一个自动化系统,只使用这个设置"立即流"流。
据我所见,我对您所做的唯一不同之处在于,在API URI中指定broadcastType=all
或broadcastType=persistent
。
你会注意到我的流是默认的流,但它不一定是。事实上,基本上LiveStream
端点唯一有用的方面是.status.configurationIssues
信息。(甚至连streamName
摄取地址都不匹配)
这就是我将两个端点关联起来的方式。也许你可以用这个模板填空。(所有字符串随机化并删除thumbnails
部分)
LiveStreams:
URI:https://www.googleapis.com/youtube/v3/liveStreams/?part=status,摘录&default=true
回应:;
{"kind":"youtube#liveStreamListResponse","etag":"\"j1yhvAPYkjsoF8yjoVGsTlIFzCS/rqgpDvaMrWOPqUrLPxJd4XUFoKg\","pageInfo":{"totalResults":1,"每页结果":5},"项目":[{"kind":"youtube#liveStream","etag":"\"j1yhvAPYkjsoF8yjoVGsTlIFzCS/SRutyOE9apA9K1qAdh2s9ZYE Dp\","id":"e5LT2xEURi9BQzf2rLe5eB325081929219850",<--liveBroadcasts.boundStreamId"snippet":{"发布日期":"2016-09-05T23:21:33.000Z","channelId":"QIr0IE1wRTRj2SUku4eFj0mK","title":"默认流","description":","isDefaultStream":true},"状态":{"streamStatus":"活动","healthStatus":{"状态":"良好"}}}]}
直播广播:
URI:https://www.googleapis.com/youtube/v3/liveBroadcasts/?part=status,contentDetails,snippet,id&broadcastStatus=活动&broadcastType=持久
响应:
{"kind":"youtube#liveBroadcastListResponse","etag":"\"j1yhvAPYkjsoF8yjoVGsTlIFzCS/MFvQunCBDdqlkhPMness6LN1zao\","pageInfo":{"totalResults":1,"每页结果":5},"项目":[{"kind":"youtube#直播","etag":"\"j1yhvAPYkjsoF8yjoVGsTlIFzCS/mK_CAQ9rrVulNXbKbeIveFnQPd8\","id":"eXrevq9RzVQ","snippet":{"发布日期":"2017-05-07T16:58:05.000Z","channelId":"QIr0IE1wRTRj2SUku4eFj0mK","title":"514306 pgju","description":","scheduledStartTime":"1970-01-01T00:00:00.000Z","实际开始时间":"2017-05-08T01:21:45.000Z","isDefaultBroadcast":true,"liveChatId":"NiHXTKPfAyCJrPgREDRnvMSL0N5LBiVUlZoLSULA9vqyoR"},"状态":{"lifeCycleStatus":"live","privacyStatus":"未列出","recordingStatus":"正在录制"},"contentDetails":{"boundStreamId":"e5LT2xEURi9BQzf2rLe5eB325081929219850",<--LiveStreams.id"boundStreamLastUpdateTimeMs":"2016-09-05T23:2:3.749Z","monitorStream":{"enableMonitorStream":false},"enableEmbed":true,"enableDvr":true,"enableContentEncryption":false,"startWithSlate":false,"recordFromStart":true,"enableClosedCaptions":false,"closedCaptionsType":"closedCaptionsDisabled","enableLowLatency":false,"投影":"矩形"}}]}
请注意,正如您在某种程度上注意到的,通过API处理"Stream Now"事件,而不仅仅是liveChatId
特有的,有一些配置设置可以更改使用默认参数返回结果的方式,有时它们可以更改流程中涉及的顺序和步骤。我甚至发现,实际上有一些与LiveStream
端点相关的参数没有文档记录,与LiveBroadcast
端点类似此外还有一些错误。
YouTube目前不支持将API调用与"Stream Now"混合,也不支持通过API创建事件。没有办法从"立即流"广播中获取聊天消息,只有完全使用API创建的广播。
如果您认为这是一个API缺陷,我建议在这里打开一个增强或缺陷票据。