Cannot page through all results using nextPageToken on YouTube search API v3

浪尽此生 提交于 2019-12-11 02:35:48

问题


I am using the YouTube search API v3. I am trying to get snippets of all the videos of a channel. To go from page to page, I use the nextPageToken. The channel that I am interested in has 3,628 total results. After I get to 500 videos (the 10th page, as I am requesting 50 videos per page), the nextPageToken is no longer passed back.

Is there a limit on the total number of videos I can page through for a particular channel?

Initially, I start off with the following URL and follow the nextPageToken by appending to the query string &pageToken=[nextPageToken].

https://www.googleapis.com/youtube/v3/search?key=[key]&channelId=UCEBb1b_L6zDS3xTUrIALZOw&part=snippet,id&order=date&maxResults=50&safeSearch=none&videoEmbeddable=true&type=video

The URL for the 10th page is as follows.

https://www.googleapis.com/youtube/v3/search?key=[key]&channelId=UCEBb1b_L6zDS3xTUrIALZOw&part=snippet,id&order=relevance&maxResults=50&safeSearch=none&videoEmbeddable=true&type=video&pageToken=CMIDEAA

Also, I note something weird in that from page to page, the total number of videos changes. Is this a known bug?

The following table list the page along with the corresponding page token and total results. Note that I do not (need to) pass in a pageToken for the first page.

+------+------------+---------------+
| Page | Page Token | Total Results |
+------+------------+---------------+
|    1 | [none]     |          3628 |
|    2 | CDIQAA     |          3628 |
|    3 | CGQQAA     |          3626 |
|    4 | CJYBEAA    |          3626 |
|    5 | CMgBEAA    |          3625 |
|    6 | CPoBEAA    |          3625 |
|    7 | CKwCEAA    |          3625 |
|    8 | CN4CEAA    |          3624 |
|    9 | CJADEAA    |          3624 |
|   10 | CMIDEAA    |          3624 |
+------+------------+---------------+

回答1:


Maybe you want to use PlaylistItem instead of Search. It is much cheaper according to quota (100 vs 6) and gives up to 100.000 Videos for a given playlist. Every channel has got a uploads-playlist, in which all uploaded videos are stored.

For more details, watch: https://www.youtube.com/watch?v=RjUlmco7v2M



来源:https://stackoverflow.com/questions/31759677/cannot-page-through-all-results-using-nextpagetoken-on-youtube-search-api-v3

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