YouTube 数据 API:视频的标题不在 commentThreads 端点结果中

YouTube Data API: video's title not in commentThreads endpoint result

我正在为我的项目使用 YouTube 数据 API v3,我想知道是否通过这个 API 调用:

https://www.googleapis.com/youtube/v3/commentThreads?key=YOUR_KEY&textFormat=plainText&part=snippet&maxResults=5&order=relevance&videoId=YOUR_ID,

我能不能得到那个视频的标题?

这是我从中得到的 API:

    {
        "kind": "youtube#commentThreadListResponse",
        "etag": "KcqDjUnisqZz_7Kr1dfxHxM4jSM",
        "nextPageToken": "QURTSl9pMUxESzFEZk53RV9nNnUzRWx6S2VQY1A5QVpPS2JrZUltdnl2MzhidmM4bzRaY1ZTa1ZzaXBQbGdiYWd0LXRvc1lTVzJQSHdnLXdKRW11MzlDMHp1WGpFS1dCVEczb0hXZ3JhcEQ0b3FnVlprb1duRUJTWVh1d0J1dzVJdw==",
        "pageInfo": {
          "totalResults": 5,
          "resultsPerPage": 5
        },
        "items": [
          {
            "kind": "youtube#commentThread",
            "etag": "h3h5DKe5ApoaVan5iX4vC2glnYA",
            "id": "Ugxxqkvik0jDB9_WSth4AaABAg",
            "snippet": {
              "videoId": "8juRm9I__uk",
              "topLevelComment": {
                "kind": "youtube#comment",
                "etag": "pjDNsBFra34PxM9VOQtI49R9-_Y",
                "id": "Ugxxqkvik0jDB9_WSth4AaABAg",
                "snippet": {
                  "videoId": "8juRm9I__uk",
                  "textDisplay": "Nyesel beli realme 3 pro ",
                  "textOriginal": "Nyesel beli realme 3 pro ",
                  "authorDisplayName": "Dodi Satria",
                  "authorProfileImageUrl": "https://yt3.ggpht.com/ytc/AAUvwnir7Yxd0qmDbKtLo568c7RKbDQvGlFeq_LjlGxM4A=s48-c-k-c0xffffffff-no-rj-mo",
                  "authorChannelUrl": "http://www.youtube.com/channel/UC28fGIqdC7B1y5BRVhmI8Eg",
                  "authorChannelId": {
                    "value": "UC28fGIqdC7B1y5BRVhmI8Eg"
                  },
                  "canRate": true,
                  "viewerRating": "none",
                  "likeCount": 3,
                  "publishedAt": "2019-08-01T11:52:39Z",
                  "updatedAt": "2019-08-01T11:52:39Z"
                }
              },
              "canReply": true,
              "totalReplyCount": 1,
              "isPublic": true
            }
          },

视频ID在里面,但是我能得到视频的标题吗?

作为 @DaImTo suggested , you need to call the Videos.list API 端点获取与您感兴趣的视频对应的元数据信息。

这是一个通用的 URL,当在 GET HTTP 方法上发出时,调用 Videos.list:

https://www.googleapis.com/youtube/v3/videos?key=YOUR_API_KEY&part=snippet&fields=items/snippet/title&id=YOUR_VIDEO_ID.

请注意,上面我使用了 fields 请求参数来仅从 API 获取实际需要的信息。

例如,在 idbKINwXXzlaQ 的情况下,端点 returns 以下 JSON 响应文本:

{
  "items": [
    {
      "snippet": {
        "title": "The European semiconductor industry and its global competition | DW News"
      }
    }
  ]
}