Compare commits

..

4 Commits

Author SHA1 Message Date
jeancf
b6396f7b51 Make sure we are logged to get max_characters 2023-07-19 19:45:43 +02:00
jeancf
a50a077cd3 Not much 2023-07-19 18:31:50 +02:00
jeancf
4200c12204 Get max_characters from instance 2023-07-19 18:10:46 +02:00
jeancf
8ddf85c0cf Test getting max_characters 2023-07-19 17:59:28 +02:00

View File

@ -598,7 +598,7 @@ def process_media_body(tt_iter):
tweet_text += url
else:
logging.warning("No handler for tag in twitter text: " + tag.prettify())
logging.warning("No handler for tag %s in twitter text: ", tag.prettify())
return tweet_text
@ -954,7 +954,6 @@ def main(argv):
# Select random nitter instance to fetch updates from
nitter_url = 'https://' + TOML['options']['nitter_instances'][random.randint(0, len(TOML['options']['nitter_instances']) - 1)]
# Load twitter page of user
soup, timeline = get_timeline(nitter_url)
@ -1044,7 +1043,7 @@ def main(argv):
if quote_div is not None:
tweet_text += substitute_source('\n\nhttps://twitter.com' + quote_div.get('href').strip('#m'))
# Process card : extract image if necessary
# Process card: extract image if necessary
card_class = status.find('a', class_='card-container')
if card_class is not None:
photos.extend(process_card(nitter_url, card_class))
@ -1150,6 +1149,16 @@ def main(argv):
if len(tweets) != 0 and mastodon is None:
mastodon = login(mast_password)
# Check toot character limit on mastodon instance
if mastodon is not None:
try:
max_characters = mastodon.instance().configuration.statuses['max_characters']
logging.debug('Instance character limit is '+ str(max_characters))
except Exception:
# Default value for Mastodon
max_characters = 500
logging.debug('Tried to get toot character limit from Mastodon instance but failed. Assuming 500')
# **********************************************************
# Iterate tweets in list.
# post each on Mastodon and record it in database