api - YouTube API无法从结束的广播事件中获取liveChatId

标签 api youtube request youtube-api livechat

我正在尝试检索从实时流式传输中获得的所有聊天消息,该流式传输已经结束。但是使用下面的请求,它不会检索任何snippet.liveChatId,如Google文档中所述:https://developers.google.com/youtube/v3/live/docs/liveBroadcasts#snippet.liveChatId
如果我尝试即将进行的流式传输,则可以正常运行。
如果无法获得适当的liveChatId,在这种情况下如何获取聊天消息?
一些值替换为MY_XPTO
请求:

    GET https://www.googleapis.com/youtube/v3/liveBroadcasts?part=snippet&id=MY_ID&key=[YOUR_API_KEY] HTTP/1.1

    Authorization: Bearer [YOUR_ACCESS_TOKEN]
    Accept: application/json
响应:
    {
     "kind": "youtube#liveBroadcastListResponse",
     "etag": "MY_ETAG",
     "pageInfo": {
      "totalResults": 0,
      "resultsPerPage": 5
     },
     "items": [
      {
       "kind": "youtube#liveBroadcast",
       "etag": "MY_ETAG,
       "id": "MY_ID",
       "snippet": {
        "publishedAt": "2020-04-03T21:23:06.000Z",
        "channelId": "MY_CHANNEL_ID",
        "title": "MY_TITLE",
        "description": "MY_DESCRIPTION",
        "thumbnails": {
         "default": {
          "url": "MYURL",
          "width": 120,
          "height": 90
         },
         "medium": {
          "url": "MY_URL",
          "width": 320,
          "height": 180
         },
         "high": {
          "url": "MY_URL",
          "width": 480,
          "height": 360
         },
         "standard": {
          "url": "MY_URL",
          "width": 640,
          "height": 480
         },
         "maxres": {
          "url": "MY_URL",
          "width": 1280,
          "height": 720
         }
        },
        "scheduledStartTime": "2020-04-07T20:00:00.000Z",
        "actualStartTime": "2020-04-07T20:01:00.326Z",
        "actualEndTime": "2020-04-07T21:43:52.000Z",
        "isDefaultBroadcast": false
       }
      }
     ]
    }

最佳答案

The documentation指出:

string (return type) The ID of the currently active live chat attached to this video. This field is filled only if the video is a currently live broadcast that has live chat. Once the broadcast transitions to complete this field will be removed and the live chat closed down. For persistent broadcasts that live chat id will no longer be tied to this video but rather to the new video being displayed at the persistent page.


强调我的。
这意味着YouTube完成后会销毁liveChatId(更确切地说,流结束后约400秒,或首映结束后约60秒),因此通过合法方式获取liveChatId是不可能的。而且,即使您设法获得该ID,您也将无法使用该ID来修改以前的直播的聊天记录。

关于api - YouTube API无法从结束的广播事件中获取liveChatId,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61111699/

相关文章:

javascript - YouTube 自动播放并静音

java - 使用 java 创建 YouTube 事件而不提示从浏览器登录

jsf - 传递作为 EL 操作方法参数传递的请求范围变量不起作用

javascript - 从桌面上的 Node 脚本访问网页

azure - 使用 API 在 Azure AD 中注册应用程序(应用程序注册)?

azure - 如何使用 Azure 数据工厂管道调用 REST API?

Angular sanitizer - YouTube iframe 的异常(exception)

c# - 如何在 asp.net web api 中实现幂等 key ?

ios - 正在 phonegap iOS 应用程序中加载博客文章...无法嵌入 Youtube 视频

java - CORBA + JAVA + 动态客户端 - Request 对象的 invoke() 方法失败