YouTube API not listing all videos from channel

眉间皱痕 提交于 2019-12-25 01:06:57

问题


I am using the YouTube Data API to get info about videos from a channel. The API response is not including all the videos that are uploaded to the respective channel.

This is the channel (right now it has 6 videos): https://www.youtube.com/channel/UCdSjDEx46aNP0oKPN_J6hOA/videos

Video list (right now): https://i.ibb.co/K91bJxS/image.png

Here is my API call: https://www.googleapis.com/youtube/v3/search?part=snippet&type=video&key=API_KEY&maxResults=15&channelId=UCdSjDEx46aNP0oKPN_J6hOA&order=date

Here is the response (only 4 videos listed):

{ "kind":"youtube#searchListResponse", "etag":"\"p4VTdlkQv3HQeTEaXgvLePAydmU/be7hxSCsiJnKBCJePUfIg5bfJO4\"", "regionCode":"RO", "pageInfo":{ "totalResults":4, "resultsPerPage":15 }, "items":[ { "kind":"youtube#searchResult", "etag":"\"p4VTdlkQv3HQeTEaXgvLePAydmU/ntdnt3QTuNN5l9_iYJAAgH4kE-w\"", "id":{ "kind":"youtube#video", "videoId":"GkYNJH0qkKc" }, "snippet":{ "publishedAt":"2019-09-29T07:47:58.000Z", "channelId":"UCdSjDEx46aNP0oKPN_J6hOA", "title":"Tutorial comentado 3/3", "description":"Comentamos el tutorial de MTG Arena para quien no lo haya jugado nunca. Damos explicaciones útiles para jugadores noveles.", "thumbnails":{ "default":{ "url":"https://i.ytimg.com/vi/GkYNJH0qkKc/default.jpg", "width":120, "height":90 }, "medium":{ "url":"https://i.ytimg.com/vi/GkYNJH0qkKc/mqdefault.jpg", "width":320, "height":180 }, "high":{ "url":"https://i.ytimg.com/vi/GkYNJH0qkKc/hqdefault.jpg", "width":480, "height":360 } }, "channelTitle":"Car Bar", "liveBroadcastContent":"none" } }, { "kind":"youtube#searchResult", "etag":"\"p4VTdlkQv3HQeTEaXgvLePAydmU/w_3YGOA4SdmMgL15Fzg1qQaAQQo\"", "id":{ "kind":"youtube#video", "videoId":"OHLTiXWJ9pM" }, "snippet":{ "publishedAt":"2019-09-29T07:44:03.000Z", "channelId":"UCdSjDEx46aNP0oKPN_J6hOA", "title":"Tutorial comentado 2/3", "description":"Comentamos el tutorial de MTG Arena para quien no lo haya jugado nunca. Damos explicaciones útiles para jugadores noveles.", "thumbnails":{ "default":{ "url":"https://i.ytimg.com/vi/OHLTiXWJ9pM/default.jpg", "width":120, "height":90 }, "medium":{ "url":"https://i.ytimg.com/vi/OHLTiXWJ9pM/mqdefault.jpg", "width":320, "height":180 }, "high":{ "url":"https://i.ytimg.com/vi/OHLTiXWJ9pM/hqdefault.jpg", "width":480, "height":360 } }, "channelTitle":"Car Bar", "liveBroadcastContent":"none" } }, { "kind":"youtube#searchResult", "etag":"\"p4VTdlkQv3HQeTEaXgvLePAydmU/RE4dR9kF05E34eOpiVOGKgkIs4g\"", "id":{ "kind":"youtube#video", "videoId":"j9QQVjakiCM" }, "snippet":{ "publishedAt":"2019-09-29T07:25:42.000Z", "channelId":"UCdSjDEx46aNP0oKPN_J6hOA", "title":"Tutorial comentado 1/3", "description":"Comentamos el tutorial de MTG Arena para quien no lo haya jugado nunca. Damos explicaciones útiles para jugadores noveles.", "thumbnails":{ "default":{ "url":"https://i.ytimg.com/vi/j9QQVjakiCM/default.jpg", "width":120, "height":90 }, "medium":{ "url":"https://i.ytimg.com/vi/j9QQVjakiCM/mqdefault.jpg", "width":320, "height":180 }, "high":{ "url":"https://i.ytimg.com/vi/j9QQVjakiCM/hqdefault.jpg", "width":480, "height":360 } }, "channelTitle":"Car Bar", "liveBroadcastContent":"none" } }, { "kind":"youtube#searchResult", "etag":"\"p4VTdlkQv3HQeTEaXgvLePAydmU/56JGSQ25cLzFPdVa5Mk-Y63hHC0\"", "id":{ "kind":"youtube#video", "videoId":"46dml09YB1E" }, "snippet":{ "publishedAt":"2019-09-28T07:30:01.000Z", "channelId":"UCdSjDEx46aNP0oKPN_J6hOA", "title":"Presentacion Version Septiembre 2019", "description":"Revisamos las novedades de esta nueva versión, la 1.0 oficial de MTG Arena.", "thumbnails":{ "default":{ "url":"https://i.ytimg.com/vi/46dml09YB1E/default.jpg", "width":120, "height":90 }, "medium":{ "url":"https://i.ytimg.com/vi/46dml09YB1E/mqdefault.jpg", "width":320, "height":180 }, "high":{ "url":"https://i.ytimg.com/vi/46dml09YB1E/hqdefault.jpg", "width":480, "height":360 } }, "channelTitle":"Car Bar", "liveBroadcastContent":"none" } } ] }

Any help on this is appreciated.

Thank you.


回答1:


As stated from this answer in the issuetracker

You may use the following series of call as a workaround:

1) Get the upload playlist using Channels.list:

https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.channels.list?part=contentDetails&id=UCupvZG-5ko_eiXAupbDfxWw&fields=items(contentDetails%252FrelatedPlaylists%252Fuploads%252Cid)&_h=12&

2) Then use playlistitems.list to get the latest videos:

https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.playlistItems.list?part=snippet&playlistId=UUHnyfMqiRRG1u-2MsSQLbXA&_h=6&

That series of call is also more efficient as it uses 90% less quota.



来源:https://stackoverflow.com/questions/58171867/youtube-api-not-listing-all-videos-from-channel

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