Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
667 views
in Technique[技术] by (71.8m points)

youtube data api - PlaylistItems seems to be limited to 20 000 entires for uploads playlist. Is there any workaround?

It seems that somewhat recently uploads playlists were limited to 20 000 entries. Is there a way to get list of all videos uploaded by a channel?

For example channel UCFL1sCAksD6_7JIZwwHcwjQ has 57 849 videos when searching for it:

https://www.youtube.com/results?search_query=jtbc+entertainment.

But its uploads playlist has only 20 000 videos:

https://www.youtube.com/playlist?list=UUFL1sCAksD6_7JIZwwHcwjQ.

When querying YouTube Data API through Python, after reaching page that has 20 000th entry, nextPageToken doesn't exist.

How can I find rest of the videos?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You may try using repeatedly the Search.list API endpoint queried with the following parameters:

  • channelId=UCFL1sCAksD6_7JIZwwHcwjQ,
  • type=video,
  • order=date,
  • publishedBefore=...,
  • maxResults=50,

where publishedBefore is computed appropriately.

The initial publishedBefore is set to 1 second before the value of the publishedAt property of the (chronologically) last video you have obtained from PlaylistItems.list endpoint invoked with playlistId=UUFL1sCAksD6_7JIZwwHcwjQ.

Successive values of publishedBefore will be set, similarly, to 1 second before the value of the publishedAt property of the (chronologically) last video of the previous call to Search.list endpoint.

One more remark: do note that -- even if the API will allow you to go beyond the 20000 limit using the algorithm above (I don't know if it will; you have to test that yourself) -- the cost of this procedure is quite high: each Search.list endpoint call has a quota cost of 100 units (expensive indeed).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...