Compare commits

..

No commits in common. "969b6849b813fcb26ff97484d0d404eb9654e876" and "191c23074d258874c3a8a87ccd17e5011a643318" have entirely different histories.

2 changed files with 14 additions and 14 deletions

View File

@ -3,7 +3,7 @@
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.
**28 JUN 2023** VERSION 4.0 **19 JUN 2023** VERSION 4.0
* Added option to update avatar and banner pictures on profile if changed on Twitter * Added option to update avatar and banner pictures on profile if changed on Twitter
* Tweaked list of nitter instances * Tweaked list of nitter instances

View File

@ -796,8 +796,8 @@ def main(argv):
logging.info(' tweet_delay : ' + str(TOML['options']['tweet_delay'])) logging.info(' tweet_delay : ' + str(TOML['options']['tweet_delay']))
logging.info(' toot_cap : ' + str(TOML['options']['toot_cap'])) logging.info(' toot_cap : ' + str(TOML['options']['toot_cap']))
logging.info(' subst_twitter : ' + str(TOML['options']['subst_twitter'])) logging.info(' subst_twitter : ' + str(TOML['options']['subst_twitter']))
logging.info(' subst_youtube : ' + str(TOML['options']['subst_youtube'])) logging.info(' subst_twitter : ' + str(TOML['options']['subst_youtube']))
logging.info(' subst_reddit : ' + str(TOML['options']['subst_reddit'])) logging.info(' subst_twitter : ' + str(TOML['options']['subst_reddit']))
logging.info(' log_level : ' + str(TOML['options']['log_level'])) logging.info(' log_level : ' + str(TOML['options']['log_level']))
logging.info(' log_days : ' + str(TOML['options']['log_days'])) logging.info(' log_days : ' + str(TOML['options']['log_days']))
@ -887,13 +887,13 @@ def main(argv):
# Extract time stamp # Extract time stamp
time_string = status.find('span', class_='tweet-date').a.get('title') time_string = status.find('span', class_='tweet-date').a.get('title')
try: try:
timestamp = datetime.strptime(time_string, '%d/%m/%Y, %H:%M:%S') timestamp = datetime.strptime(time_string, '%d/%m/%Y, %H:%M:%S').timestamp()
except: except:
# Dec 21, 2021 · 12:00 PM UTC # Dec 21, 2021 · 12:00 PM UTC
timestamp = datetime.strptime(time_string, '%b %d, %Y · %I:%M %p %Z') timestamp = datetime.strptime(time_string, '%b %d, %Y · %I:%M %p %Z').timestamp()
# Check if time is within acceptable range # Check if time is within acceptable range
if not is_time_valid(timestamp.timestamp()): if not is_time_valid(timestamp):
out_date_cnt += 1 out_date_cnt += 1
logging.debug("Tweet outside valid time range, skipping") logging.debug("Tweet outside valid time range, skipping")
continue continue
@ -981,8 +981,8 @@ def main(argv):
tweet_text += '\n\nOriginal tweet : ' + substitute_source(full_status_url) tweet_text += '\n\nOriginal tweet : ' + substitute_source(full_status_url)
# Check what timestamp would look like # Check what timestamp would look like
logging.debug("TEST TIMESTAMP " + str(time_string)) logging.debug("TEST TIMESTAMP")
logging.debug(tweet_text + ' (' + datetime.strftime(timestamp, '%x %X') + ')') logging.debug(tweet_text + ' ' + time_string)
# If no media was specifically added in the tweet, try to get the first picture # If no media was specifically added in the tweet, try to get the first picture
# with "twitter:image" meta tag in first linked page in tweet text # with "twitter:image" meta tag in first linked page in tweet text
@ -1024,7 +1024,7 @@ def main(argv):
tweet = { tweet = {
"author": author, "author": author,
"author_account": author_account, "author_account": author_account,
"timestamp": timestamp.timestamp(), "timestamp": timestamp,
"tweet_id": tweet_id, "tweet_id": tweet_id,
"tweet_text": tweet_text, "tweet_text": tweet_text,
"video": video_file, "video": video_file,
@ -1107,9 +1107,9 @@ def main(argv):
except MastodonAPIError: except MastodonAPIError:
# Assuming this is an: # 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!') # 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.') logging.warning('Mastodon API Error 422: Cannot attach files that have not finished processing. Waiting 15 seconds and retrying.')
# Wait 60 seconds # Wait 15 seconds
time.sleep(60) time.sleep(15)
# retry posting # retry posting
try: try:
toot = mastodon.status_post(tweet['tweet_text'], media_ids=media_ids) toot = mastodon.status_post(tweet['tweet_text'], media_ids=media_ids)