【问题标题】:Unable to get only the youtube video description by the following link using json无法通过以下链接使用 json 仅获取 youtube 视频描述
【发布时间】:2017-07-10 17:12:02
【问题描述】:

您好,我正在尝试使用 videoid 获取 youtube 视频详细信息,但无法在此获取描述,我该如何获取它。这是我的链接

https://www.youtube.com/oembed?url=http://www.youtube.com/watch?v=iwGFalTRHDA&format=json

这是json:

{
  "title": "Trololo",
  "width": 459,
  "height": 344,
  "thumbnail_height": 360,
  "html": "\u003ciframe width=\"459\" height=\"344\" src=\"https:\/\/www.youtube.com\/embed\/iwGFalTRHDA?feature=oembed\" frameborder=\"0\" allowfullscreen\u003e\u003c\/iframe\u003e",
  "thumbnail_width": 480,
  "author_url": "https:\/\/www.youtube.com\/user\/KamoKatt",
  "provider_name": "YouTube",
  "version": "1.0",
  "type": "video",
  "provider_url": "https:\/\/www.youtube.com\/",
  "author_name": "KamoKatt",
  "thumbnail_url": "https:\/\/i.ytimg.com\/vi\/iwGFalTRHDA\/hqdefault.jpg"
}

【问题讨论】:

标签: javascript json youtube-api


【解决方案1】:

使用来自 Youtube API 的视频 ID 和这个端点。

https://www.googleapis.com/youtube/v3/videos?part=snippet&id={VIDEO_ID}&fields=items/snippet/title,items/snippet/description&key={YOUR_API_KEY} - jlmcdonald

对于带有 url 的视频:

https://www.youtube.com/oembed?url=http://www.youtube.com/watch?v=iwGFalTRHDA&format=json

视频 ID 为 iwGFalTRHDA,现在您只需使用您的 API_KEY。如果您没有,您可以按照说明操作,然后启用 youtube API 并使用提供给您的密钥来获得一个 here

使用这个 videoid 和我的 api 密钥(我没有把它放在下面)

https://www.googleapis.com/youtube/v3/videos?part=snippet&id=iwGFalTRHDA&fields=items/snippet/title,items/snippet/description&key={YOUR_API_KEY}

结果是这样的:

{
 "items": [
  {
   "snippet": {
    "title": "Trololo",
    "description": ""
   }
  }
 ]
}

这是一个视频,视频 ID 为 e-5obm1G_FY

{
 "items": [
  {
   "snippet": {
    "title": "Anjana Vakil: Learning Functional Programming with JavaScript - JSUnconf 2016",
    "description": "Slides: https://slidr.io/vakila/learning-functional-programming-with-javascript"
   }
  }
 ]
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-03-22
    • 2012-02-08
    • 2014-07-31
    • 1970-01-01
    • 2015-07-26
    • 2016-04-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多