Instagram/python-instagram — pull request #87 by johncadengo (2014-07-07 02:22:21+00:00)
Title: Add option for max_pages=None

This allows a client to pull all user recent media. Previous [hacks](http://stackoverflow.com/a/14586216/693754) included changing `count=-1`, as in the example below,

feed = api.user_recent_media(user_id=user_id, count=-1, as_generator=true)

for media, next in feed:
# do something with media

But on last page of results the following error would occur:

File "instagram/bind.py", line 106, in _build_pagination_info
return pagination.get('next_url')
AttributeError: 'NoneType' object has no attribute 'get'

Instead, we can supply `max_pages=None` as an argument, and achieve the desired result,

feed = api.user_recent_media(user_id=user_id, max_pages=None, as_generator=true)

Though unusual to ask for, supplying `max_pages=0` will still achieve the expected result of returning no pages.