Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pagination breaks when account_followers number == limit #79

Closed
ghost opened this issue Sep 5, 2017 · 1 comment
Closed

Pagination breaks when account_followers number == limit #79

ghost opened this issue Sep 5, 2017 · 1 comment

Comments

@ghost
Copy link

ghost commented Sep 5, 2017

Hi,

Using this code I got a severe crash only in one case: when the followers number of the account is 40:

res = mastodon.account_followers(userid)
        for page in mastodon.fetch_remaining(res):
            nbfollowers += 1

Below is the issue:

Traceback (most recent call last):
  File "./mastocount.py", line 35, in <module>
    Main()
  File "/home/chaica/progra/python/mastocount/mastocount/main.py", line 38, in __init__
    self.main()
  File "/home/chaica/progra/python/mastocount/mastocount/main.py", line 63, in main
    followers = get_followers(credentials)
  File "/home/chaica/progra/python/mastocount/mastocount/followers.py", line 38, in get_followers
    for page in mastodon.fetch_remaining(res):
  File "/usr/local/lib/python3.5/dist-packages/mastodon/Mastodon.py", line 814, in fetch_remaining
    current_page = self.fetch_next(current_page)
  File "/usr/local/lib/python3.5/dist-packages/mastodon/Mastodon.py", line 773, in fetch_next
    return self.__api_request(method, endpoint, params)
  File "/usr/local/lib/python3.5/dist-packages/mastodon/Mastodon.py", line 963, in __api_request
    if url['rel'] == 'next':
KeyError: 'rel'

It's only produce when my number of followers is equal to the parameter limit of account_followers. Without limit, it breaks if the number of account followers is 40.

This code perfectly works on 3 other accounts with different number of account_followers and works on the same account if the number of followers is different of 40.

I tested modifying the limit and each time account followers number equals limit, it breaks.

Let me know if you need more information,
Carl

@ghost ghost changed the title Ppagination Pagination breaks when account_followers number == limit Sep 5, 2017
@halcy
Copy link
Owner

halcy commented Sep 5, 2017

Huh, I wonder why there are URLs in there that have no "rel".

In any case, probably Mastodon.py should just silently ignore those.

@halcy halcy closed this as completed in 1c93e35 Sep 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant