Replaced mast_account

This commit is contained in:
jeancf 2022-11-18 16:57:44 +01:00
parent 7c307e1003
commit 99a63463d3

View File

@ -398,7 +398,6 @@ def main(argv):
print('Missing Mastodon user') print('Missing Mastodon user')
exit(-1) exit(-1)
# mast_account = args['m']
# mast_password = args['p'] # mast_password = args['p']
# suppress_retweets = args['s'] # suppress_retweets = args['s']
# get_vids = args['v'] # get_vids = args['v']
@ -549,7 +548,7 @@ def main(argv):
# Check in database if tweet has already been posted # Check in database if tweet has already been posted
db.execute( db.execute(
"SELECT * FROM toots WHERE twitter_account=? AND mastodon_instance=? AND mastodon_account=? AND tweet_id=?", "SELECT * FROM toots WHERE twitter_account=? AND mastodon_instance=? AND mastodon_account=? AND tweet_id=?",
(toml['config']['twitter_account'], toml['config']['mastodon_instance'], mast_account, tweet_id)) (toml['config']['twitter_account'], toml['config']['mastodon_instance'], toml['config']['mastodon_user'], tweet_id))
tweet_in_db = db.fetchone() tweet_in_db = db.fetchone()
if tweet_in_db is not None: if tweet_in_db is not None:
@ -673,7 +672,7 @@ def main(argv):
# Login to account on maston instance # Login to account on maston instance
mastodon = None mastodon = None
if len(tweets) != 0: if len(tweets) != 0:
mastodon = login(toml['config']['mastodon_instance'], mast_account, mast_password) mastodon = login(toml['config']['mastodon_instance'], toml['config']['mastodon_user'], mast_password)
# ********************************************************** # **********************************************************
# Iterate tweets in list. # Iterate tweets in list.
@ -727,7 +726,7 @@ def main(argv):
toot = {} toot = {}
try: try:
mastodon = Mastodon( mastodon = Mastodon(
access_token=mast_account + '.secret', access_token=toml['config']['mastodon_user'] + '.secret',
api_base_url='https://' + toml['config']['mastodon_instance'] api_base_url='https://' + toml['config']['mastodon_instance']
) )
@ -742,12 +741,12 @@ def main(argv):
else: else:
posted_cnt += 1 posted_cnt += 1
logging.debug('Tweet %s posted on %s', tweet['tweet_id'], mast_account) logging.debug('Tweet %s posted on %s', tweet['tweet_id'], toml['config']['mastodon_user'])
# Insert toot id into database # Insert toot id into database
if 'id' in toot: if 'id' in toot:
db.execute("INSERT INTO toots VALUES ( ? , ? , ? , ? , ? )", db.execute("INSERT INTO toots VALUES ( ? , ? , ? , ? , ? )",
(toml['config']['twitter_account'], toml['config']['mastodon_instance'], mast_account, tweet['tweet_id'], toot['id'])) (toml['config']['twitter_account'], toml['config']['mastodon_instance'], toml['config']['mastodon_user'], tweet['tweet_id'], toot['id']))
sql.commit() sql.commit()
logging.info(str(posted_cnt) + ' tweets posted to Mastodon') logging.info(str(posted_cnt) + ' tweets posted to Mastodon')