From d70759f332b191dc1f0cbb8bd3631dde8f2a3548 Mon Sep 17 00:00:00 2001 From: Dryusdan Date: Sat, 10 Mar 2018 20:51:34 +0100 Subject: [PATCH] check all favorite --- dlimage.py | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/dlimage.py b/dlimage.py index 4c69b71..dfc8b8d 100644 --- a/dlimage.py +++ b/dlimage.py @@ -31,10 +31,14 @@ def get_parameter( parameter, file_path ): def get_media(): media_attachments = toot.media_attachments for media in media_attachments: - print(media.url[-20:]) - response = requests.get(media.remote_url) - pattern = Image.open(BytesIO(response.content), "r").convert('RGB') - pattern.save('save_media/'+media.url[-20:]) + if os.path.isfile('./save_media/'+media.remote_url[-20:]): + sys.exit(0) + + if media.remote_url[-3:] != "mp4": + print(media.remote_url[-20:]) + response = requests.get(media.remote_url) + pattern = Image.open(BytesIO(response.content), "r").convert('RGB') + pattern.save('save_media/'+media.remote_url[-20:]) secrets_filepath = "secrets/secrets.txt" @@ -50,11 +54,18 @@ mastodon = Mastodon( api_base_url = 'https://' + mastodon_hostname, ) + masto_allfav = mastodon.favourites(None, None, 40) -for toot in masto_allfav: - if toot.account.acct == "account@domain.com": - get_media() - else : - if toot.account.acct == "otheraccount@domain.com": +while masto_allfav != []: + for toot in masto_allfav: + if toot.account.acct == "bonjourtoutlemonde@hostux.social": get_media() - + else : + if toot.account.acct == "BonjourMadame@hostux.social": + get_media() + else : + if toot.account.acct == "hato0517@mstdn.jp": + get_media() + masto_allfav = mastodon.fetch_next(masto_allfav) + time.sleep(10) +