PyImgur icon indicating copy to clipboard operation
PyImgur copied to clipboard

Retrieving multiple pages with get_gallery_favorites()

Open parnaudo opened this issue 11 years ago • 2 comments

Awesome module. I've been trying to build an easy way to move all my imgur favorites between different photo sharing sites. I know the API call https://api.imgur.com/3/account/%s/gallery_favorites defaults to just page 0 with 60 images, but is there any way to iterate over all pages with PyImgur?

I know that when I access the API directly you can just iterate over a big enough number to access every page (IE https://api.imgur.com/3/account/me/gallery_favorites/0..25 or whatever page) but I can't see how to do that with PyImgur, any advice?

I'm pretty new to Python, but have plenty of experience in php and ruby, using your module to help learn so thanks =D

parnaudo avatar Oct 22 '14 17:10 parnaudo

Hey,

The intended way of doing this would be to simply specifying the number of items you want returned via the limit argument. pyimgur would then abstract away the concept of pages and fetch the number of requested resource. Breaking it into multiple requests if necessary. So the intended code would be something like


import pyimgur

im = pyimgur.Imgur(YOUR_CLIENT_CODE)
im.get_memes_gallery(limit=100)

Unfortunately though, when I try to do that it seems to lag out at the second request. I.e. if the limit is higher than what can be fetched in a single request.

I'm looking into what might be the cause of this. It's been a while though since I've worked with pyimgur and I'm just reacquinting myself with the library. I can't tell you when it will be fixed, but I can tell you that I'm working on it.

Also, totally awesome to see someone using my library to learn Python. It's a great language :-)

Damgaard avatar Nov 11 '15 15:11 Damgaard

Hey man,

Yea it's been fun to play around with. My place now is a python/scala shop so had a good chance to get into the language a bit, definitely a lot of fun. Haven't had much free time these days but if I can figure out why it's lagging I'll submit a PR. Good work altogether though!

parnaudo avatar Nov 12 '15 22:11 parnaudo