Giter Site home page Giter Site logo

Comments (4)

sclm avatar sclm commented on May 27, 2024

There actually should be an upper limit here, the fact that you can request 9001 is likely a bug. Pagination is required for our own performance.

The response object has pagination helper methods, so you can use them to get the next, last, first and previous pages. The pagination functions were previously always there, but I patched them so that they won't be set if they're set to null/None (this is in 2795110).

The code that would load all of the pages into a list is below, but bear in mind that this does mean that it's allocating memory for every one and won't be cleaned up. A more ideal way to do this would probably to process the data inside the same while loop and spare yourself that headache.

vc = vimeo.VimeoClient(**client_args)

all_videos = list()

resp = vc.me.videos(per_page=1)
all_videos = resp['body']['data']

while hasattr(resp, 'next') and resp.next:
    resp = resp.next()
    all_videos.extend(resp['body']['data'])

pprint(all_videos)

Sorry this does it one per page, but that's how I can test it since I don't quite have as many videos as you do.

from vimeo.py.

natfarleydev avatar natfarleydev commented on May 27, 2024

If paging is needed (which it is), then this solution seems good to me. I'll switch over my code to this method soon.

from vimeo.py.

natfarleydev avatar natfarleydev commented on May 27, 2024

I found that resp always has a next() method, and just loops round when it gets to the end. To solve this I just did

while resp.next()['body']['page'] == resp['body']['page'] + 1:
        resp = resp.next()
        all_my_videos.extend(resp['body']['data'])

for the loop instead.

from vimeo.py.

sclm avatar sclm commented on May 27, 2024

@nasfarley88 That was the bug that was corrected in my latest commit. We were always creating the helper methods for URIs in the paging object, even when the URI was none. The change performs a test for None (or any false-y value) before binding the method onto the object.

from vimeo.py.

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.