YouTube API v3 Search not returning all videos

久未见 提交于 2019-12-13 03:31:48

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/52808721/youtube-api-v3-search-not-returning-all-videos

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!