检索直播或最近直播的视频列表

Retrieving List of Videos that are LIVE or Recently Live

有谁知道是否可以使用 API.

检索实时 YouTube 视频列表或最近的实时视频列表

目前使用时似乎没有显示结果:

https://youtube.googleapis.com/youtube/v3/playlistItems?part=contentDetails%2Cid%2Csnippet%2Cstatus&id=PLU12uITxBEPEmhVTL-lsGEgudcTUZrpCe&key={API_KEY}

(我用我的实际密钥替换了 API_KEY)。

YouTube 是否不允许通过 API 访问查看此播放列表?

要获取实时视频列表,您可以使用 Search.list API 端点,使用以下参数查询:

  • order=date,
  • eventType=liveeventType=completed,以及
  • type=video.

例如,调用 URL 上的端点:

https://www.googleapis.com/youtube/v3/search?part=snippet&order=date&eventType=live&type=video&maxResults=2&key=...

我获得了以下 JSON 响应文本:

{
  "kind": "youtube#searchListResponse",
  "etag": "...",
  "nextPageToken": "CAIQAA",
  "regionCode": "...",
  "pageInfo": {
    "totalResults": 33971,
    "resultsPerPage": 2
  },
  "items": [
    {
      "kind": "youtube#searchResult",
      "etag": "f5CCkxfKHZJT1RrihJCGx-WN5cc",
      "id": {
        "kind": "youtube#video",
        "videoId": "sfEw6qe4rk8"
      },
      "snippet": {
        "publishedAt": "2020-12-12T23:15:22Z",
        "channelId": "UCBghEKEqODLq1qQuN7X9aTA",
        "title": "미국에서 무슨 ' 신내림'받았는지 일요일 새벽에 군포물류창고로 총집한 거ㅣ한들!",
        "description": "This stream is created with #PRISMLiveStudio.",
        "thumbnails": {
          ...
        },
        "channelTitle": "문갑식의 진짜 TV",
        "liveBroadcastContent": "live",
        "publishTime": "2020-12-12T23:15:22Z"
      }
    },
    {
      "kind": "youtube#searchResult",
      "etag": "hWMVkmSEsnSnnN_Cj-jmqXgNZ6E",
      "id": {
        "kind": "youtube#video",
        "videoId": "f7exmbx5DAc"
      },
      "snippet": {
        "publishedAt": "2020-12-12T23:10:53Z",
        "channelId": "UCSqEMt26wLsKC6K_wTyr9Cw",
        "title": "CyberPunk 2077 Play Through 2! type !discord",
        "description": "...",
        "thumbnails": {
          ...
        },
        "channelTitle": "Capron Funk",
        "liveBroadcastContent": "live",
        "publishTime": "2020-12-12T23:10:53Z"
      }
    }
  ]
}

关于你的第二个问题——播放列表PLU12uITxBEPEmhVTL-lsGEgudcTUZrpCe——你必须承认你的以下误解w.r.t。到您正在调用的 API 端点:

根据 PlaylistItems.list API 端点的官方规范,如果你想列出由其 ID 标识的播放列表的视频元数据,你应该使用 playlistId 请求参数(下面强调的是我的):

playlistId (string)
The playlistId parameter specifies the unique ID of the playlist for which you want to retrieve playlist items. Note that even though this is an optional parameter, every request to retrieve playlist items must specify a value for either the id parameter or the playlistId parameter.

id参数的含义完全不同(下面的重点也是我的):

id (string)
The id parameter specifies a comma-separated list of one or more unique playlist item IDs.

请注意,我使用 playlistId=PLU12uITxBEPEmhVTL-lsGEgudcTUZrpCe 调用了端点并获得了 100 个项目,与在 URL:

下的 YouTube Web UI 上看到的完全一样

https://www.youtube.com/playlist?list=PLU12uITxBEPEmhVTL-lsGEgudcTUZrpCe.