Getting more then 100 video results with Playlist.get()
Closed this issue ยท 3 comments
It appears that their isn't yet a Playlist.get().next() or equivalent implemented. Is their a way to get more then 100 video results yet? If not is this a feature that is planned to be implemented in the future?
Also, thank you for creating/maintaining this wonderful library! I appreciate all your hard work. Have a great day!
Hi there @Themis3000 !
Yeah, you pointed it out right.
Playlist.get
is really new in this library, so next
attribute isn't added to it yet.
I'll see how I can do that.
Thanks for your positive comment.
Greetings ๐
Hi there @Themis3000 ! ๐
Hope you're doing great ๐. Sorry, it took me a lot of time to get to this one. I had kinda busy schedule & this project in general takes a lot of study for adding/fixing features. So, here I am with what you asked for.
Now you can get more than 100 videos from a playlist. I have made everything very simple to use.
playlist = Playlist('https://www.youtube.com/playlist?list=PLRBp0Fe2GpgmsW46rJyudVFlY6IYjFBIK')
print(f'Videos Retrieved: {len(playlist.videos)}')
if playlist.hasMoreVideos:
print('Getting more videos...')
playlist.getNextVideos()
else:
print('Found all the videos.')
print(f'Videos Retrieved: {len(playlist.videos)}')
if playlist.hasMoreVideos:
print('Getting more videos...')
playlist.getNextVideos()
else:
print('Found all the videos.')
print(f'Videos Retrieved: {len(playlist.videos)}')
if playlist.hasMoreVideos:
print('Getting more videos...')
playlist.getNextVideos()
else:
print('Found all the videos.')
Now hasMoreVideos
will indicate if more videos are present, and getNextVideos
will give you more videos of the playlist.
Result:
Videos Retrieved: 100
Getting more videos...
Videos Retrieved: 200
Getting more videos...
Videos Retrieved: 209
Found all the videos.
If above example seems bit spread out, you can simply use a loop as follows (looks elegant I guess) to get all the videos:
from youtubesearchpython import *
playlist = Playlist('https://www.youtube.com/playlist?list=PLRBp0Fe2GpgmsW46rJyudVFlY6IYjFBIK')
print(f'Videos Retrieved: {len(playlist.videos)}')
while playlist.hasMoreVideos:
print('Getting more videos...')
playlist.getNextVideos()
print(f'Videos Retrieved: {len(playlist.videos)}')
print('Found all the videos.')
Greetings. โจ
Perfect! Thank you so much! I'm happy this is now implemented, I will be making use of it
Have a great day, I appreciate your work!