mirror of
https://github.com/hughrun/ephemetoot
synced 2025-01-10 04:52:40 +01:00
Merge pull request #1 from MarkEEaton/master
Handle IndexError and some boilerplate
This commit is contained in:
commit
0d6900eb26
@ -61,14 +61,18 @@ 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
|
||||||
max_id = timeline[-1:][0].id
|
try:
|
||||||
next_batch = mastodon.account_statuses(user_id, limit=40, max_id=max_id)
|
max_id = timeline[-1:][0].id
|
||||||
if len(next_batch) > 0:
|
next_batch = mastodon.account_statuses(user_id, limit=40, max_id=max_id)
|
||||||
checkToots(next_batch, deleted_count)
|
if len(next_batch) > 0:
|
||||||
else:
|
checkToots(next_batch, deleted_count)
|
||||||
print('Removed ' + str(deleted_count) + ' toots.')
|
else:
|
||||||
|
print('Removed ' + str(deleted_count) + ' toots.')
|
||||||
|
except IndexError:
|
||||||
|
print('No toots found!')
|
||||||
|
|
||||||
# trigger from here
|
# trigger from here
|
||||||
account = mastodon.account(user_id)
|
if __name__ == '__main__':
|
||||||
print('Checking ' + str(account.statuses_count) + ' toots...')
|
account = mastodon.account(user_id)
|
||||||
checkToots(timeline)
|
print('Checking ' + str(account.statuses_count) + ' toots...')
|
||||||
|
checkToots(timeline)
|
||||||
|
Loading…
Reference in New Issue
Block a user