YouTube API v3 搜索未返回所有视频 [英] YouTube API v3 Search not returning all videos

查看:43
本文介绍了YouTube API v3 搜索未返回所有视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试检索某个频道的所有视频,但 api 没有返回一些视频.我在规范中找不到任何说明为什么有些不在结果集中的内容.

我打的电话是:

https://www.googleapis.com/youtube/v3/search?type=video&key=__key_here__&channelId=UCxS2lX7728bTnmK1t21bYlA&part=id,snippet&maxResults=50&order=title

[要对此进行测试,您需要您自己的 api 密钥]

结果的第一页至少缺少一个视频.2018 年 8 月 15 日,标题为 我学会了如何做一个新技巧!,它位于此处,不在结果集中,即使它在日期范围内,也是前 50 个结果.

有谁知道这是否是一个已知问题?

我已经验证,如果我添加 q 参数,带有视频 ID,它会检索它.

解决方案

你可以参考这个链接.><块引用>

如果您想获取频道中的视频,您应该进行的 API 调用是一个 youtube.playlistItems.list()playlistIdplaylistId上传"频道的播放列表.(这通常以 UU... 开头,但这是将来可能会更改的实现细节.

以下是 API 浏览器.

通过搜索操作获取相同的数据并不能保证返回所有内容;搜索索引不能替代您可以通过 youtube.playlistItems.list() 调用获取的后端数据.这与这篇博文(尽管重点是 v2).

总而言之,要从某个频道获取所有上传内容,您需要使用该播放列表 ID 上的 playlistItems.list 而不是调用 search 从该频道的上传播放列表中获取项目.list 在频道 ID 上.

I'm trying to retrieve all videos for a channel, and some are not being returned by the api. I cannot find anything in the spec that indicates why some would not be in the result set.

The call I'm making is:

https://www.googleapis.com/youtube/v3/search?type=video&key=__key_here__&channelId=UCxS2lX7728bTnmK1t21bYlA&part=id,snippet&maxResults=50&order=title

[To test this you'll need your own api key]

The first page of results is missing at least one video. The one from 8-15-2018, titled I LEARNED HOW TO DO A NEW TRICK!, which is located here, is not in the result set, even though it falls within the date range, and the first 50 results.

Does anyone know if this is a known issue?

I have verified that if I add the q parameter, with the video id, it will retrieve it.

解决方案

You may refer with this link.

The API call that you should make if you want to get the videos in a channel is a youtube.playlistItems.list() with the playlistId of the "uploads" playlist for the channel. (This usually stars with UU..., but that's an implementation detail that might change in the future.

Here's an example of the call in the API Explorer.

Getting the same data via a search operation isn't guaranteed to return everything; the search index isn't a replacement for the backend data that you can obtain via the youtube.playlistItems.list() call. It's very much the same point raised in this blog post (though the focus there is on v2).

To summarize, to get all the uploads from a channel, you need to get the items from the uploads playlist for the channel using playlistItems.list on that playlist's ID rather than calling search.list on the channel ID.

这篇关于YouTube API v3 搜索未返回所有视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆