From fb8d83800e8ce829f69e82abd98fa69b5e19bcfc Mon Sep 17 00:00:00 2001 From: jeancf Date: Fri, 14 Jul 2023 13:21:12 +0200 Subject: [PATCH] add upload pause to config --- default.toml | 6 ++++++ twoot.py | 9 +++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/default.toml b/default.toml index 6caf33b..2787bb2 100644 --- a/default.toml +++ b/default.toml @@ -76,6 +76,12 @@ mastodon_user = "" # #tweet_delay = 15 +# How many seconds to pause between successive uploads of toots. +# Increase this value if successive tweets appear in the wrong order. +# Default is 0 (no pause) +# +# upload_pause = 5 + # Maximum number of toots to post in each run # Default is 0 (which means unlimited) # diff --git a/twoot.py b/twoot.py index 06dc951..d65f846 100755 --- a/twoot.py +++ b/twoot.py @@ -98,6 +98,7 @@ def build_config(args): 'remove_original_tweet_ref': False, 'tweet_max_age': float(1), 'tweet_delay': float(0), + 'upload_pause': float(0), 'toot_cap': int(0), 'subst_twitter': [], 'subst_youtube': [], @@ -1198,9 +1199,9 @@ def main(argv): except MastodonAPIError: # Assuming this is an: # ERROR ('Mastodon API returned error', 422, 'Unprocessable Entity', 'Cannot attach files that have not finished processing. Try again in a moment!') - logging.warning('Mastodon API Error 422: Cannot attach files that have not finished processing. Waiting 60 seconds and retrying.') - # Wait 60 seconds - time.sleep(60) + logging.warning('Mastodon API Error 422: Cannot attach files that have not finished processing. Waiting 30 seconds and retrying.') + # Wait 30 seconds + time.sleep(30) # retry posting try: toot = mastodon.status_post(tweet['tweet_text'], media_ids=media_ids) @@ -1218,7 +1219,7 @@ def main(argv): posted_cnt += 1 logging.debug('Tweet %s posted on %s', tweet['tweet_id'], TOML['config']['mastodon_user']) # Test to find out if slowing down successive posting helps with ordering of threads - time.sleep(5) + time.sleep(TOML['options']['upload_pause']) # Insert toot id into database if 'id' in toot: