I'm trying to get videos from Youtube playlists. I manage to get only 26 in playlists with 50+ videos. I noticed Youtube loads only 26 by default and other videos are loaded to page by scrolling down the playlist. EXAMPLE
The problem is that nextPageToken is undefined on second request, but by manually going to the playlist you can load more videos.
Is there any way to get remaining videos from playlists?
Here is what I'm doing: JSFiddle
function getVids(playlistId, nextPageToken){
$.get(
"https://www.googleapis.com/youtube/v3/playlistItems",{
part : 'snippet',
maxResults : 20,
playlistId : playlistId,
pageToken: nextPageToken,
key: '{API_KEY}'},
function(data) {
console.log(data.nextPageToken);
console.log(data.items.length);
getVids(playlistId, data.nextPageToken);
}
);
}
getVids('RDaUWYDaVp92I');