From 6d90486c8b319fe29923a6fce9e6bebd55849e9f Mon Sep 17 00:00:00 2001 From: jeancf Date: Thu, 15 Jun 2023 14:35:27 +0200 Subject: [PATCH] Added configuration option --- default.toml | 5 +++++ twoot.py | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/default.toml b/default.toml index d60f0d3..21f589b 100644 --- a/default.toml +++ b/default.toml @@ -38,6 +38,11 @@ footer = "" # default is 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) # Default is 1 tweet_max_age = 1 diff --git a/twoot.py b/twoot.py index fac1ba0..d9b6a53 100755 --- a/twoot.py +++ b/twoot.py @@ -97,6 +97,7 @@ def build_config(args): 'subst_twitter': [], 'subst_youtube': [], 'subst_reddit': [], + 'update_profile': False, 'log_level': "WARNING", 'log_days': 3, } @@ -157,6 +158,8 @@ def build_config(args): TOML['options']['tweet_delay'] = float(args['d']) if args['c'] is not None: 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 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): """ - 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 sql: database connection :param mast_password: @@ -705,6 +710,7 @@ def main(argv): 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('-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='', action='store', type=float) parser.add_argument('-d', metavar='', action='store', type=float) parser.add_argument('-c', metavar='', action='store', type=int)