Git Product home page Git Product logo

Comments (3)

alexmercerind avatar alexmercerind commented on September 27, 2024 3

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 🍀

from youtube-search-python.

alexmercerind avatar alexmercerind commented on September 27, 2024 3

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. ✨

from youtube-search-python.

Themis3000 avatar Themis3000 commented on September 27, 2024 1

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!

from youtube-search-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.