replaced mast_instance

This commit is contained in:
jeancf 2022-11-18 16:55:50 +01:00
parent aa75146580
commit 7c307e1003

View File

@ -398,7 +398,6 @@ def main(argv):
print('Missing Mastodon user')
exit(-1)
# mast_instance = args['i']
# mast_account = args['m']
# mast_password = args['p']
# suppress_retweets = args['s']
@ -550,7 +549,7 @@ def main(argv):
# Check in database if tweet has already been posted
db.execute(
"SELECT * FROM toots WHERE twitter_account=? AND mastodon_instance=? AND mastodon_account=? AND tweet_id=?",
(toml['config']['twitter_account'], mast_instance, mast_account, tweet_id))
(toml['config']['twitter_account'], toml['config']['mastodon_instance'], mast_account, tweet_id))
tweet_in_db = db.fetchone()
if tweet_in_db is not None:
@ -674,7 +673,7 @@ def main(argv):
# Login to account on maston instance
mastodon = None
if len(tweets) != 0:
mastodon = login(mast_instance, mast_account, mast_password)
mastodon = login(toml['config']['mastodon_instance'], mast_account, mast_password)
# **********************************************************
# Iterate tweets in list.
@ -729,7 +728,7 @@ def main(argv):
try:
mastodon = Mastodon(
access_token=mast_account + '.secret',
api_base_url='https://' + mast_instance
api_base_url='https://' + toml['config']['mastodon_instance']
)
if len(media_ids) == 0:
@ -738,7 +737,7 @@ def main(argv):
toot = mastodon.status_post(tweet['tweet_text'], media_ids=media_ids, visibility='public')
except MastodonError as me:
logging.error('posting ' + tweet['tweet_text'] + ' to ' + mast_instance + ' Failed')
logging.error('posting ' + tweet['tweet_text'] + ' to ' + toml['config']['mastodon_instance'] + ' Failed')
logging.error(me)
else:
@ -748,7 +747,7 @@ def main(argv):
# Insert toot id into database
if 'id' in toot:
db.execute("INSERT INTO toots VALUES ( ? , ? , ? , ? , ? )",
(toml['config']['twitter_account'], mast_instance, mast_account, tweet['tweet_id'], toot['id']))
(toml['config']['twitter_account'], toml['config']['mastodon_instance'], mast_account, tweet['tweet_id'], toot['id']))
sql.commit()
logging.info(str(posted_cnt) + ' tweets posted to Mastodon')