mirror of
https://github.com/hughrun/ephemetoot
synced 2025-01-10 04:52:40 +01:00
handle IndexError when there are no toots in the timeline
This commit is contained in:
parent
3af1296b83
commit
92643271d5
@ -61,12 +61,15 @@ def checkToots(timeline, deleted_count=0):
|
|||||||
# the account_statuses call is paginated with a 40-toot limit
|
# the account_statuses call is paginated with a 40-toot limit
|
||||||
# get the id of the last toot to include as 'max_id' in the next API call.
|
# get the id of the last toot to include as 'max_id' in the next API call.
|
||||||
# then keep triggering new rounds of checkToots() until there are no more toots to check
|
# then keep triggering new rounds of checkToots() until there are no more toots to check
|
||||||
|
try:
|
||||||
max_id = timeline[-1:][0].id
|
max_id = timeline[-1:][0].id
|
||||||
next_batch = mastodon.account_statuses(user_id, limit=40, max_id=max_id)
|
next_batch = mastodon.account_statuses(user_id, limit=40, max_id=max_id)
|
||||||
if len(next_batch) > 0:
|
if len(next_batch) > 0:
|
||||||
checkToots(next_batch, deleted_count)
|
checkToots(next_batch, deleted_count)
|
||||||
else:
|
else:
|
||||||
print('Removed ' + str(deleted_count) + ' toots.')
|
print('Removed ' + str(deleted_count) + ' toots.')
|
||||||
|
except IndexError:
|
||||||
|
print('No toots found!')
|
||||||
|
|
||||||
# trigger from here
|
# trigger from here
|
||||||
account = mastodon.account(user_id)
|
account = mastodon.account(user_id)
|
||||||
|
Loading…
Reference in New Issue
Block a user