Browse Source

move tweet deletion out of the downloading loop so it actually downloads multiple images lmao

master
mark 4 months ago
parent
commit
1d87177ec6
1 changed files with 6 additions and 6 deletions
  1. +6
    -6
      main.py

+ 6
- 6
main.py View File

@@ -49,8 +49,7 @@ class MediaStreamListener(tweepy.StreamListener):
pass
video_urls.append(best_url)

# Go through and download everything, and optionally delete the tweet
# after downloading.
# Go through and download everything
for url in photo_urls + video_urls:
fname = url.split("/")[-1].split("?")[0]
r = requests.get(url, stream=True)
@@ -59,13 +58,14 @@ class MediaStreamListener(tweepy.StreamListener):
with open(path.join(config["output_dir"], fname), 'wb') as outfile:
r.raw.decode_content = True
shutil.copyfileobj(r.raw, outfile)

if config["burn_after_reading"]:
api.destroy_status(status.id)
print(f"Tweet {status.id} deleted.")
else:
print(f"Whoops. Something went wrong downloading {fname}")

# Optionally delete the tweet after doing the downloading
if config["burn_after_reading"]:
api.destroy_status(status.id)
print(f"Tweet {status.id} deleted.")


listener = MediaStreamListener()
stream = tweepy.Stream(auth=auth, listener=listener)

Loading…
Cancel
Save