add upload pause to config

This commit is contained in:
jeancf 2023-07-14 13:21:12 +02:00
parent d6ed64d6fc
commit fb8d83800e
2 changed files with 11 additions and 4 deletions

View File

@ -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)
#

View File

@ -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: