Mastodon.py
Mastodon.py copied to clipboard
TypeError on automated pagination
Hello and thanks for developing this library.
mastodon.fetch_next
called on an empty list of toots leads to:
File "/usr/lib/python3/dist-packages/mastodon/utility.py", line 206, in fetch_next
method = params['_pagination_method']
~~~~~~^^^^^^^^^^^^^^^^^^^^^^
TypeError: list indices must be integers or slices, not str
Steps to reproduce:
toots = mastodon.timeline()
while True:
toots = mastodon.fetch_next(toots)
It seems that fetch_next returns an empty list after 800 toots and breaks the next run. Perhaps the library could provide an iterator that terminates at the end instead?
Thanks!
yeah, that sounds like a really good idea, actually.
Workshopping this in my head, so I'm wondering, what do (or others) you think would make more sense:
- An iterator that iterates pages?
- An iterator that iterates post and fetches next page as needed?
- Both?
Late to the party, but IMHO, option 2 (An iterator that iterates post and fetches next page as needed?) seems better.