Added configuration option

This commit is contained in:
jeancf 2023-06-15 14:35:27 +02:00
parent 870a1ee745
commit 6d90486c8b
2 changed files with 12 additions and 1 deletions

View File

@ -38,6 +38,11 @@ footer = ""
# default is false # default is false
remove_original_tweet_ref = false remove_original_tweet_ref = false
# Check if profile avatar or banner pictures were changed and update
# the Mastodon account if necessary
# Default is false
update_profile = false
# Maximum age of tweet to post (in days, decimal values accepted) # Maximum age of tweet to post (in days, decimal values accepted)
# Default is 1 # Default is 1
tweet_max_age = 1 tweet_max_age = 1

View File

@ -97,6 +97,7 @@ def build_config(args):
'subst_twitter': [], 'subst_twitter': [],
'subst_youtube': [], 'subst_youtube': [],
'subst_reddit': [], 'subst_reddit': [],
'update_profile': False,
'log_level': "WARNING", 'log_level': "WARNING",
'log_days': 3, 'log_days': 3,
} }
@ -157,6 +158,8 @@ def build_config(args):
TOML['options']['tweet_delay'] = float(args['d']) TOML['options']['tweet_delay'] = float(args['d'])
if args['c'] is not None: if args['c'] is not None:
TOML['options']['toot_cap'] = int(args['c']) TOML['options']['toot_cap'] = int(args['c'])
if args['p'] is True:
TOML['options']['update_profile'] = args['p']
# Verify that we have a minimum config to run # Verify that we have a minimum config to run
if 'twitter_account' not in TOML['config'].keys() or TOML['config']['twitter_account'] == "": if 'twitter_account' not in TOML['config'].keys() or TOML['config']['twitter_account'] == "":
@ -172,7 +175,9 @@ def build_config(args):
def update_profile(nitter_url, soup, sql, mast_password): def update_profile(nitter_url, soup, sql, mast_password):
""" """
Update the profile on Mastodon Update profile on Mastodon
Check if avatar or banner pictures have changed since last run
If they have, download them and upload them on the Mastodon account profile
:param soup: BeautifulSoup object containing the page :param soup: BeautifulSoup object containing the page
:param sql: database connection :param sql: database connection
:param mast_password: <PASSWORD> :param mast_password: <PASSWORD>
@ -705,6 +710,7 @@ def main(argv):
parser.add_argument('-u', action='store_true', help='Remove trackers from URLs') parser.add_argument('-u', action='store_true', help='Remove trackers from URLs')
parser.add_argument('-v', action='store_true', help='Ingest twitter videos and upload to Mastodon instance') parser.add_argument('-v', action='store_true', help='Ingest twitter videos and upload to Mastodon instance')
parser.add_argument('-o', action='store_true', help='Do not add reference to Original tweet') parser.add_argument('-o', action='store_true', help='Do not add reference to Original tweet')
parser.add_argument('-p', action='store_true', help='update profile if changed')
parser.add_argument('-a', metavar='<max age (in days)>', action='store', type=float) parser.add_argument('-a', metavar='<max age (in days)>', action='store', type=float)
parser.add_argument('-d', metavar='<min delay (in mins)>', action='store', type=float) parser.add_argument('-d', metavar='<min delay (in mins)>', action='store', type=float)
parser.add_argument('-c', metavar='<max # of toots to post>', action='store', type=int) parser.add_argument('-c', metavar='<max # of toots to post>', action='store', type=int)