Compare commits

...

7 Commits

Author SHA1 Message Date
jeancf
bfe3aa050e Added doc for version 3.2 2023-02-15 19:59:44 +01:00
jeancf
ecdc814dc7 Merge branch 'master' of https://oauth2:glpat-9o3gm_adQN1R3SJE3F7j@gitlab.com/jeancf/twoot.git 2023-02-15 19:54:31 +01:00
jeancf
275f7c9a3f Release 3.1.3 2023-02-15 19:53:00 +01:00
jeancf
a11a6cba65 Wait 15 seconds + Clean up 2023-02-06 21:40:18 +01:00
jeancf
faedf27a37 Remove unnecessary repeat creation of Mastodon object 2023-02-06 20:41:51 +01:00
jeancf
38e505ad6e Proper implementation of mitigation for API Error 422 2023-02-06 20:41:12 +01:00
jeancf
36248dbce1 tentative mitigation of error 422 2023-02-02 20:56:32 +01:00
3 changed files with 22 additions and 10 deletions

View File

@ -1,11 +1,17 @@
# Changelog # Changelog
**01 FEB 2023** VERSION 3.1.3
* Fixed *remove link redirections* option that would not work in some cases
* Added `utm_brand` to list of blacklisted query parameters removed by *remove trackers from URLs* option
**04 JAN 2023** VERSION 3.1.2 **04 JAN 2023** VERSION 3.1.2
* *Posting Privacy* setting of the Mastodon account now defines visibility of toots posted with Twoot * *Posting Privacy* setting of the Mastodon account now defines visibility of toots posted with Twoot
* Modified URL building for compatibility with Windows * Modified URL building for compatibility with Windows
**21 DEC 2022** VERSION 3.1.1 **21 DEC 2022** VERSION 3.1.1
Modified code that made twoot incompatible with python versions < 3.10 Modified code that made twoot incompatible with python versions < 3.10
**11 DEC 2022** VERSION 3.1 HOTFIX **11 DEC 2022** VERSION 3.1 HOTFIX
@ -27,7 +33,6 @@ Modified code that made twoot incompatible with python versions < 3.10
* Config file option `log_days =` specifies how long to keep log messages in file. Older messages are deleted. * Config file option `log_days =` specifies how long to keep log messages in file. Older messages are deleted.
**23 NOV 2022** VERSION 2.5 Added command-line option (`-l`) to remove **23 NOV 2022** VERSION 2.5 Added command-line option (`-l`) to remove
redirection from links included in tweets. Obfuscated links are replaced
by the URL that the resource is directly downloaded from. Also improved by the URL that the resource is directly downloaded from. Also improved
tracker removal by cleaning URL fragments as well (contrib: mathdatech, tracker removal by cleaning URL fragments as well (contrib: mathdatech,
thanks!). thanks!).

View File

@ -3,10 +3,9 @@
Twoot is a python script that mirrors tweets from a twitter account to a Mastodon account. Twoot is a python script that mirrors tweets from a twitter account to a Mastodon account.
It is simple to set-up on a local machine, configurable and feature-rich. It is simple to set-up on a local machine, configurable and feature-rich.
**UPDATE 01 FEB 2023** VERSION 3.1.3 **15/02/2023** VERSION 3.2 Added mitigation for Mastodon API error 422, 'Unprocessable Entity',
'Cannot attach files that have not finished processing. Try again in a moment!' reported
* Fixed *remove link redirections* option that would not work in some cases on some instances when posting toots with video.
* Added `utm_brand` to list of blacklisted query parameters removed by *remove trackers from URLs* option
> Previous updates can be found in CHANGELOG. > Previous updates can be found in CHANGELOG.

View File

@ -981,16 +981,24 @@ def main(argv):
# Post toot # Post toot
toot = {} toot = {}
try: try:
mastodon = Mastodon(
access_token=TOML['config']['mastodon_user'] + '.secret',
api_base_url='https://' + TOML['config']['mastodon_instance']
)
if len(media_ids) == 0: if len(media_ids) == 0:
toot = mastodon.status_post(tweet['tweet_text']) toot = mastodon.status_post(tweet['tweet_text'])
else: else:
toot = mastodon.status_post(tweet['tweet_text'], media_ids=media_ids) toot = mastodon.status_post(tweet['tweet_text'], media_ids=media_ids)
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 15 seconds and retrying.')
# Wait 15 seconds
time.sleep(15)
# retry posting
try:
toot = mastodon.status_post(tweet['tweet_text'], media_ids=media_ids)
except MastodonError as me:
logging.error('posting ' + tweet['tweet_text'] + ' to ' + TOML['config']['mastodon_instance'] + ' Failed')
logging.error(me)
except MastodonError as me: except MastodonError as me:
logging.error('posting ' + tweet['tweet_text'] + ' to ' + TOML['config']['mastodon_instance'] + ' Failed') logging.error('posting ' + tweet['tweet_text'] + ' to ' + TOML['config']['mastodon_instance'] + ' Failed')
logging.error(me) logging.error(me)