首页 > 解决方案 > 从频道 ID 获取广播 ID - youtube api v3

问题描述

我需要根据视频 URL 知道实时聊天的 ID(或广播,以便我可以获取实时聊天的 ID)(我已经有了基于视频 URL 的频道 ID)。我尝试按照此处解释的 API 端点进行操作。

这是我输入到 URL 地址的内容/我使用 GET 请求的内容:

https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=UChs0pSaEoNLV4mevBFGAoKA&eventType=live&type=video&key=AIzaSyDl9Le2hxgLBTLuWidkZL0mqMI7BpFNzsA

这就是输出:

{
  "kind": "youtube#searchListResponse",
  "etag": "HThuNpak09_KEjLGVv8ha1kgI3A",
  "regionCode": "PL",
  "pageInfo": {
    "totalResults": 2,
    "resultsPerPage": 5
  },
  "items": [
    {
      "kind": "youtube#searchResult",
      "etag": "ui0jIAKvsHNSKCOhqlbrgXGcH4o",
      "id": {
        "kind": "youtube#video",
        "videoId": "36YnV9STBqc"
      },
      "snippet": {
        "publishedAt": "2020-03-28T00:19:07Z",
        "channelId": "UChs0pSaEoNLV4mevBFGaoKA",
        "title": "The Good Life Radio • 24/7 Live Radio | Best Relax House, Chillout, Study, Running, Gym, Happy Music",
        "description": "The Good Life is live streaming the best of Relaxing & Chill House Music, Deep House, Tropical House, EDM, Dance & Pop as well as Music for Sleep, Focus, ...",
        "thumbnails": {
          "default": {
            "url": "https://i.ytimg.com/vi/36YnV9STBqc/default_live.jpg",
            "width": 120,
            "height": 90
          },
          "medium": {
            "url": "https://i.ytimg.com/vi/36YnV9STBqc/mqdefault_live.jpg",
            "width": 320,
            "height": 180
          },
          "high": {
            "url": "https://i.ytimg.com/vi/36YnV9STBqc/hqdefault_live.jpg",
            "width": 480,
            "height": 360
          }
        },
        "channelTitle": "The Good Life Radio x Sensual Musique",
        "liveBroadcastContent": "live",
        "publishTime": "2020-03-28T00:19:07Z"
      }
    },
    {
      "kind": "youtube#searchResult",
      "etag": "kRiJkYyDYEITPVKTY4ZwhzM2LeE",
      "id": {
        "kind": "youtube#video",
        "videoId": "wKOEl_vwPSo"
      },
      "snippet": {
        "publishedAt": "2020-04-29T15:57:15Z",
        "channelId": "UChs0pSaEoNLV4mevBFGaoKA",
        "title": "Deep House Radio • 24/7 Live Radio | Vocal Deep House & Chill House Music",
        "description": "Deep House Radio • 24/7 Live Radio | Vocal Deep House & Chill House Music Listen to the Playlist on Spotify: ...",
        "thumbnails": {
          "default": {
            "url": "https://i.ytimg.com/vi/wKOEl_vwPSo/default_live.jpg",
            "width": 120,
            "height": 90
          },
          "medium": {
            "url": "https://i.ytimg.com/vi/wKOEl_vwPSo/mqdefault_live.jpg",
            "width": 320,
            "height": 180
          },
          "high": {
            "url": "https://i.ytimg.com/vi/wKOEl_vwPSo/hqdefault_live.jpg",
            "width": 480,
            "height": 360
          }
        },
        "channelTitle": "The Good Life Radio x Sensual Musique",
        "liveBroadcastContent": "live",
        "publishTime": "2020-04-29T15:57:15Z"
      }
    }
  ]
}

做,我在这里找不到广播 id 或聊天 id。你们知道某种解决方法,或者解决这个问题吗?您知道自从我链接的答案发布后发生了什么变化吗?

标签: apihttpyoutube-api

解决方案


推荐阅读