Skip to content

Commit

Permalink
If no tweets to delete do not proceed
Browse files Browse the repository at this point in the history
  • Loading branch information
rameezk committed Oct 12, 2022
1 parent 90f9f90 commit 84a858e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"python.formatting.provider": "black"
}
5 changes: 5 additions & 0 deletions scrub.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,15 @@ def scrub_tweets():
print(f"Getting tweets older than {older_than}")
tweets = api.get_tweets(older_than=older_than)

if not tweets:
print("No tweets to delete")
return

total_tweets = len(tweets)
failed_to_delete = 0
for count, tweet in enumerate(tweets, start=1):
print(f"Deleting tweet [{count}/{total_tweets}]")

try:
is_deleted = api.delete_tweet_by_tweet_id(tweet["id"])
if not is_deleted:
Expand Down

0 comments on commit 84a858e

Please sign in to comment.