kkdai / youtube

Download Youtube Video in Golang
MIT License
3.37k stars 433 forks source link

Playlist Limit #212

Closed ItsClairton closed 2 years ago

ItsClairton commented 3 years ago

If you use client.GetPlaylist() with any playlist that has more than 100 items, it will only return the first 100 items. Is there any way to exceed this limit?

Sorry for English, Google Translate.

Julian-Chu commented 3 years ago

do you have any playlist for this? I guess it's the limitation of one page, maybe we can go through all pages and fetch all items, need to do some study with example, but now doesn't support it.

ItsClairton commented 3 years ago

Here is the one I used as a test: https://www.youtube.com/playlist?list=PLhsz9CILh357zA1yMT-K5T9ZTNEU6Fl6n

Probably it's limitation per page.

Julian-Chu commented 3 years ago

Unfortunately, I can't find useful information in the response body neither the request to fetch next page, maybe other expert can know how to fetch the entire playlist. label this issue.

xesnault commented 3 years ago

I managed to get it working, I made a quick implementation on my fork (I'm not a go developer so forgive me).

I found out that in the initial data, we have a "continuation command" token at this location: $.contents.twoColumnBrowseResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents[0].itemSectionRenderer.contents[0].playlistVideoListRenderer.contents[100].continuationItemRenderer.continuationEndpoint.continuationCommand.token

Then, calling this route https://www.youtube.com/youtubei/v1/browse?key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8 with this token in the continuation field returns the 100 next videos, with another "continuation command" token, but this time the location is $.onResponseReceivedActions[0].appendContinuationItemsAction.continuationItems[100].continuationItemRenderer.continuationEndpoint.continuationCommand.token (the location of the videos also changes)

Note that the index 100 in the paths above actually means "the last index"

I tested to download videos from the start/mid/end of a playlist with 669 videos and it worked, but as I said it's a quick implementation and I might have put things in the wrong place or missed something, so feel free to reuse/modify it directly in this repository.

ItsClairton commented 3 years ago

Thank you very much for your fork, I tested it here with 1558 videos, and it worked correctly.

Julian-Chu commented 3 years ago

awesome @xesnault , you're today's super star!!!

muthursyamburi commented 2 years ago

Your fork just worked like a charm and it saved a hell lot of my time!!! Thanks a ton @xesnault...