YouTube API v3 apiclient.errors.HttpError“未选择过滤器。” -在哪里选择过滤器?

Mor*_*lde 5 python youtube-api

我第一次尝试apiclient为YouTube 设置Google ,并按照文档进行了测试(没有找到YouTube API的特定示例):

import json
from apiclient.discovery import build
service = build('youtube', 'v3', developerKey = 'tralalala')
videos = service.videos()
request = videos.list(part = '7lCDEYXw3mM') # some video id
response = request.execute()
json.dumps(response, sort_keys = True, indent = 4)
Run Code Online (Sandbox Code Playgroud)

我明白了

{
 "error": {
  "errors": [
   {
    "domain": "youtube.parameter",
    "reason": "missingRequiredParameter",
    "message": "No filter selected.",
    "locationType": "parameter",
    "location": ""
   }
  ],
  "code": 400,
  "message": "No filter selected."
 }
}
Run Code Online (Sandbox Code Playgroud)

显然,我缺少此功能filter,但是我似乎无法在google-api-client-libraries.appspot.com文档中的任何位置找到它。我的意图是通过提供视频来获取视频详细信息id

Ibr*_*aya 5

您至少需要一个选择器来列出。'id' 就是其中之一。您可以随时查看YouTube API 示例项目以供参考。这是示例之一中的Python 列表用法