本文介绍了YouTube Data API playlistItems:List 最多只返回 100 个数据项 - 或 2 页数据,7 月 16 日正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 YouTube 数据 API v3 - 今天 playlistItems:List 只返回最多 100 个数据项或所有视频播放列表的 2 页数据(UU + 频道 ID 的最后 22 个字符).我相信在第一页之后的下一页令牌也可能不正确,因为它在第三页上显示了错误的上一页令牌.

I am using YouTube Data API v3 - and today playlistItems:List only returns max of 100 data items or 2 pages of data for the all videos playlist (UU + last 22 char of channel id) . I believe the next page token also may be incorrect after the first page, because it shows the wrong previous page token on the third page.

UPDATE: Further testing shows that the playlistItems:List api works correctly
for some channels -

All video playlist - UU4mLlRa_dezwvytudo9s1sw works

https://developers.google.com/youtube/v3/docs/playlistItems/list?apix=true&apix_params=%7B%22part%22%3A%5B%22id%2Csnippet%22%5D%2C%22maxResults%22%3A50%2C%22playlistId%22%3A%22UU4mLlRa_dezwvytudo9s1sw%22%7D


but at least two others do not work correctly and only return 100 items:

UUGGZ_POGmIWG1pQXTDzQv-g
UUwD4x63A9KC7Si2RuSfg-SA

这几年来一直正常工作.它在 7 月 16 日正常运行.同样的行为发生在 API Explorer 中.

This has been working correctly for several years. It worked correctly July 16. The same behavior happens in the API Explorer.

API Explorer 示例 &所有视频播放列表 UUwD4x63A9KC7Si2RuSfg-SA 的结果:

API Explorer example & results for all video playlist UUwD4x63A9KC7Si2RuSfg-SA:

https://developers.google.com/youtube/v3/docs/playlistItems/list?apix=true&apix_params=%7B%22part%22%3A%5B%22id%2Csnippet%22%5D%2C%22maxResults%22%3A50%2C%22pageToken%22%3A%22CDIQAA%22%2C%22playlistId%22%3A%22UUwD4x63A9KC7Si2RuSfg-SA%22%7D

first page of results:

{
  "kind": "youtube#playlistItemListResponse",
  "etag": "oE9yCl2NBCpgzQbX82RR1jjqkco",
  "nextPageToken": "CDIQAA",
  "items": [


second page - page token CDIQAA:

{
  "kind": "youtube#playlistItemListResponse",
  "etag": "w8PJ0yDadTWJfwSP2CWcODoMzuk",
  "nextPageToken": "CGQQAA",
  "prevPageToken": "CDIQAQ",
  "items": [

third page - page token CGQQAA:

{
  "kind": "youtube#playlistItemListResponse",
  "etag": "AQSyYYKWgu50RiGPA10TjRTE7Ys",
  "nextPageToken": "CJYBEAA",
  "prevPageToken": "CGQQAQ",
  "items": [],                  <---- NO DATA, but 521 items still to show
  "pageInfo": {
    "totalResults": 621,
    "resultsPerPage": 50
  }
}

可能的解决方法

  1. 使用 YouTube 数据 API v3 - 搜索:指定频道 ID、无查询和结果过滤器类型 = 视频的列表.这在配额方面很昂贵,每个查询/50 个结果的页面需要 100 个配额.但是,这个 API 现在似乎最多可以为一个频道提供大约 300 个左右的结果.

  1. Use YouTube Data API v3 - search:List specifying channel ID, no query, and result filter type = videos. This is expensive in quota, it costs 100 quota per query/page of 50 results. However, this API now seems to max out at about 300 or so results for a channel.

使用 YouTube 数据 API v3 - playlistItems:List 和频道所有者授权的 OAuth 令牌,而不是公共 API 密钥.这和以前一样工作,没有 100 项限制.但是,这意味着如果没有所有者的 OAuth 令牌,您将无法获得频道或播放列表的视频列表(超过 100 个视频).

Use YouTube Data API v3 - playlistItems:List with a channel-owner authorized OAuth token instead of the public API key. This works as before without the 100 item limit. However, it means you cannot get a video list (over 100 videos) for a channel or a playlist without an OAuth token from the owner.

推荐答案

这是 YouTube API 中的一个已知错误.该错误的公开确认和跟踪位于:https://issuetracker.google.com/issues/161628022

This is a known bug in the YouTube API. Public acknowledgement and tracking of the bug is here: https://issuetracker.google.com/issues/161628022

也有一些重复.我发现

可能最好等待它修复.它只开放/分配了一天左右,所以它可能会很快得到修复.再说一次,它可能不会.以前发生过,需要很长时间才能修复.

Probably best to just wait for it to be fixed. It has only been open/assigned for a day or so, so it might get fixed quickly. Then again, it might not. It has happened before and taken a long time to fix.

启发式地,在我看来,这是对未列出播放列表的限制,也就是说,在给定 channelId 的情况下,playlists.list 不会返回播放列表.

Heuristically, it looks to me like this is a limitation on Unlisted Playlists, which is to say Playlists not returned by playlists.list given the channelId.

我检查并确认,即使使用较小的页面大小,未列出的播放列表也只会返回前 100 个播放列表项(我只查看了上传"播放列表,因为我手头没有很多大的未列出的播放列表),并且使用页面大小 50,列出的播放列表将返回所有项目(播放列表 PLC474234E124B5213 返回所有 102 个项目,播放列表 FLSC1HqVmTaE4Shn32ihbC7w 返回所有 136 个项目).根据我的经验,YouTube API 中的此类错误很少有解决方法.花很多时间在上面是不值得的.暂时忍受这个限制,记录(给关心的人)这是一个已知的错误/限制,然后继续前进,就好像它是一个记录的限制,有一个待处理的功能请求删除限制.

I checked and confirmed that even when using smaller page sizes, only the first 100 playlist items are returned for unlisted playlists (I only looked at "uploads" playlists as I do not have a lot of big unlisted playlists handy), and using page size of 50, listed playlists will return all the items (playlist PLC474234E124B5213 returns all 102 items, playlist FLSC1HqVmTaE4Shn32ihbC7w returns all 136 items). In my experience, there are rarely workarounds for these kinds of bugs in the YouTube API. It is not worth spending a lot of time on. Live with the limit for now, document (to whoever cares) that it is a known bug/limitation, and move on as if it is a documented limitation with a pending feature request to remove the limitation.

这篇关于YouTube Data API playlistItems:List 最多只返回 100 个数据项 - 或 2 页数据,7 月 16 日正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 11:39