如何从 YouTube V3 API 检索网址值



我正在尝试使用V3搜索API(https://www.googleapis.com/youtube/v3/search)检索有关YouTube视频的详细信息。我在 JSON 响应中获取了视频的所有详细信息,但没有获取视频的 URL。有人可以帮我如何检索网址吗?提前谢谢。

JSON 中没有视频网址,您需要使用 videoId。

例如,您有这样的结果:

{
 "kind": "youtube#searchListResponse",
 "etag": ""F9iA7pnxqNgrkOutjQAa9F2k8HY/KciEh2k6bPhgTexCFr55nrDyEuo"",
 "nextPageToken": "CAUQAA",
 "pageInfo": {
  "totalResults": 1031,
  "resultsPerPage": 5
 },
 "items": [
  {
   "kind": "youtube#searchResult",
   "etag": ""F9iA7pnxqNgrkOutjQAa9F2k8HY/1Y85a6l1YSEQprOw66ptMsh0Bzw"",
   "id": {
    "kind": "youtube#video",
    "videoId": "KG0vtEsiPgs"
   },
   "snippet": {
    "publishedAt": "2015-01-04T20:06:53.000Z",
    "channelId": "UC5nc_ZtjKW1htCVZVRxlQAQ",
    "title": "Real Slow - You Flow",
    "description": "That little vocal snippet has got me hooked :) Download... http://bit.ly/1xHDPlX Real Slow https://soundcloud.com/realslowbeats ...",
    "thumbnails": {
     "default": {
      "url": "https://i.ytimg.com/vi/KG0vtEsiPgs/default.jpg"
     },
     "medium": {
      "url": "https://i.ytimg.com/vi/KG0vtEsiPgs/mqdefault.jpg"
     },
     "high": {
      "url": "https://i.ytimg.com/vi/KG0vtEsiPgs/hqdefault.jpg"
     }
    },
    "channelTitle": "MrSuicideSheep",
    "liveBroadcastContent": "none"
   }
  },
  {

然后,您可以提取videoId以创建链接YouTube视频的URL。

例如items[0].id.videoId给我KG0vtEsiPgs

然后你需要将videoId与这个 url 连接起来https://www.youtube.com/watch?v=

https://www.youtube.com/watch?v='videoId'

然后你有视频链接。

相关内容

  • 没有找到相关文章

最新更新