YouTube API 是否限制一次搜索查询最多 500 个视频?
我为一个搜索查询获取了大约 500 个 YouTube 数据。
我正在使用从 youtube_tutorial 克隆的代码。
def geo_query(video_id):
youtube = build(YOUTUBE_API_SERVICE_NAME, YOUTUBE_API_VERSION,
developerKey=DEVELOPER_KEY)
video_response = youtube.videos().list(
id=video_id,
part='snippet, recordingDetails, statistics'
).execute()
有没有办法无限制地提取所有 YouTube 视频? YouTube 是否限制一次搜索查询只能显示 500 个视频?
I am getting around 500 YouTube data for one search query.
I am using the code cloned from youtube_tutorial.
def geo_query(video_id):
youtube = build(YOUTUBE_API_SERVICE_NAME, YOUTUBE_API_VERSION,
developerKey=DEVELOPER_KEY)
video_response = youtube.videos().list(
id=video_id,
part='snippet, recordingDetails, statistics'
).execute()
Is there any way to extract all the YouTube videos without any limit?
Does YouTube limit you to 500 videos for one search query?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不可以,原因有两个:文档明确指出最多可以有 500 个视频,其次配额成本会很大。
即使没有,您也会遇到配额问题。
配额数学
您使用的方法是 search.list
此方法返回每个请求的最大结果为 50 行
每次发出请求时,您都会收到 50 行,然后您可以使用页面令牌来请求下一组行
现在请求告诉我们总共有 1000000 行等待您。
如果一次 50 行,则需要 20,000 个请求。如果我们然后检查配额计算器每个请求的成本
默认配额为 10000,这意味着您可以在用完当天配额之前发出 1000 个请求。因此,您一天最多可以观看 50,000 个视频。
No for two reasons, the documentation clearly states you can have a maximum of 500 videos and secondly the quota cost would be huge.
Even if it didnt you would have issues with quota.
quota math
The method you are using is search.list
This method returns a max result of 50 rows per request
Each time you make a request you get 50 rows back you can then use the page tokens to request the next set of rows
Now the request tells us that there is a total of 1000000 rows waiting for you.
At 50 rows at a time that would be 20,000 requests. If we then check the quota calculator the cost for each request
The default quota is 10000 which would mean you can make 1000 requests before you run out of quota for the day. So you should be looking at a max of 50,000 videos you could get back in a day.