Youtube API: 搜索端点与 videoCaption 不起作用

huangapple go评论54阅读模式
英文:

Youtube API: Search endpoint with videoCaption not working

问题

以下命令按预期工作:

GET https://youtube.googleapis.com/youtube/v3/search?maxResults=1&q=test&key=[YOUR_API_KEY] HTTP/1.1

Authorization: Bearer [YOUR_ACCESS_TOKEN]
Accept: application/json

以下命令未按预期工作:

GET https://youtube.googleapis.com/youtube/v3/search?part=snippet&maxResults=1&q=test&videoCaption=closedCaption&key=[YOUR_API_KEY] HTTP/1.1

Authorization: Bearer [YOUR_ACCESS_TOKEN]
Accept: application/json

这是完整的错误信息:

{
  "error": {
    "code": 400,
    "message": "请求包含无效参数。",
    "errors": [
      {
        "message": "请求包含无效参数。",
        "domain": "global",
        "reason": "badRequest"
      }
    ],
    "status": "INVALID_ARGUMENT"
  }
}

根据文档,这应该正常工作:https://developers.google.com/youtube/v3/docs/search/list

请有人帮忙吗?

最好,
Andy

英文:

The following command works as expected:

GET https://youtube.googleapis.com/youtube/v3/search?maxResults=1&q=test&key=[YOUR_API_KEY] HTTP/1.1

Authorization: Bearer [YOUR_ACCESS_TOKEN]
Accept: application/json

The following does not work as expected:

GET https://youtube.googleapis.com/youtube/v3/search?part=snippet&maxResults=1&q=test&videoCaption=closedCaption&key=[YOUR_API_KEY] HTTP/1.1

Authorization: Bearer [YOUR_ACCESS_TOKEN]
Accept: application/json

This is the full error:

{
  "error": {
    "code": 400,
    "message": "Request contains an invalid argument.",
    "errors": [
      {
        "message": "Request contains an invalid argument.",
        "domain": "global",
        "reason": "badRequest"
      }
    ],
    "status": "INVALID_ARGUMENT"
  }
}

This should work according to the documentation: https://developers.google.com/youtube/v3/docs/search/list

Could someone please help?

Best,
Andy

答案1

得分: 1

The docs state that for the videoCaption parameter you must set type to 'video' instead of the default 'video,channel,playlist'. This works:

https://youtube.googleapis.com/youtube/v3/search?part=snippet&maxResults=1&q=test&videoCaption=closedCaption&type=video&key=[YOUR_API_KEY]

英文:

The docs state that for the videoCaption parameter you must set type to 'video' instead of the default 'video,channel,playlist'. This works:

https://youtube.googleapis.com/youtube/v3/search?part=snippet&maxResults=1&q=test&videoCaption=closedCaption&type=video&key=[YOUR_API_KEY]

huangapple
  • 本文由 发表于 2023年3月10日 01:22:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/75688021.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定