diff --git a/mastodon_main.py b/mastodon_main.py index 9b6b0b5..6b2dafa 100755 --- a/mastodon_main.py +++ b/mastodon_main.py @@ -15,8 +15,17 @@ if __name__ == "__main__": mastodon = Mastodon(access_token = TOKEN,api_base_url = API_URL) status = createStrip("mastodon.png") if status == 0: - new_strip = mastodon.media_post(fileDir+"mastodon.png","image/png") - mastodon.status_post("Nuova striscia",media_ids=new_strip) + published = False + for i in range(1,100): + try: + new_strip = mastodon.media_post(fileDir+"mastodon.png","image/png") + mastodon.status_post("Nuova striscia",media_ids=new_strip) + published = True + except: + continue + break + if not(published): + print("Auth error") else: print("error creating image\n") print(status) diff --git a/twitter_main.py b/twitter_main.py index 737922c..c3c5cfe 100755 --- a/twitter_main.py +++ b/twitter_main.py @@ -15,10 +15,16 @@ if __name__ == "__main__": auth = tweepy.OAuthHandler(tokens[0],tokens[1]) auth.set_access_token(tokens[2],tokens[3]) api = tweepy.API(auth) - try: - api.verify_credentials() - api.update_with_media(fileDir+"twitter.png","Generatore automatico di strip. Striscia di oggi.") - except: + published = False + for i in range(0,100): + try: + api.verify_credentials() + api.update_with_media(fileDir+"twitter.png","Generatore automatico di strip. Striscia di oggi.") + published = True + except: + continue + break + if not(published): print("Auth error") else: print("Error creating image\n")