From 381845e514e630178098cfa8fa57ac6c0cd80688 Mon Sep 17 00:00:00 2001 From: jeancf Date: Sat, 26 Nov 2022 15:04:00 +0100 Subject: [PATCH] Basic functionality OK with youtube --- default.toml | 16 ++++++++-------- twoot.py | 11 +++++------ 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/default.toml b/default.toml index 7963b79..f81904f 100644 --- a/default.toml +++ b/default.toml @@ -1,17 +1,17 @@ [config] # twitter account name without '@' -twitter_account = "" +twitter_account = "unrealengine" # Domain name of Mastodon instance -mastodon_instance = "" +mastodon_instance = "i" # Mastodon username (login email address) -mastodon_user = "" +mastodon_user = "u" [options] # Download videos from twitter and upload them on Mastodon # Default is false -upload_videos = true +upload_videos = false # Also post the "reply-to" tweets from twitter account # Default is false @@ -23,15 +23,15 @@ skip_retweets = false # Replace redirected links in tweets with direct URLs # Default is false -remove_link_redirections = false +remove_link_redirections = true # Clean up URLs in tweets to remove trackers # Default is false -remove_trackers_from_urls = false +remove_trackers_from_urls = true # Maximum age of tweet to post (in days, decimal values accepted) # Default is 1 -tweet_max_age = 1 +tweet_max_age = 2 # Minimum age of tweet to post (in minutes) # Default is 0 (post tweet as soon as possible) @@ -48,7 +48,7 @@ twitter = ["nitter.net", ] # Replace youtube.com link by random alternative out of this list # Default is [] -youtube = ["piped.kavin.rocks", ] +youtube = ["piped.kavin.rocks", "invidious.flokinet.to"] # Replace reddit.com link by random alternative out of this list # Default is [] diff --git a/twoot.py b/twoot.py index ae332eb..283b07f 100755 --- a/twoot.py +++ b/twoot.py @@ -152,8 +152,11 @@ def _substitute_source(domain): param domain: Domain name to substitute :return: domain or sustitute if applicable """ + + logging.debug("Checking domain " + domain) + youtube_subst = TOML["options"]["substitution"]["youtube"] - if domain == 'youtube.com' and youtube_subst != []: + if domain.find('youtube.com') >=0 and youtube_subst != []: domain = youtube_subst[random.randint(0, len(youtube_subst) - 1)] logging.debug("Replaced youtube.com by " + domain) @@ -178,7 +181,6 @@ def clean_url(dirty_url): _remove_trackers_query(url_parsed.query), _remove_trackers_fragment(url_parsed.fragment) ]) - if cleaned_url != dirty_url: logging.debug('Cleaned URL from: ' + dirty_url + ' to: ' + cleaned_url) @@ -739,15 +741,12 @@ def main(argv): tweets.append(tweet) logging.debug('Tweet %s added to list of toots to upload', tweet_id) + logging.debug('TEXT:\n' + tweet["tweet_text"]) # Log summary stats logging.info(str(out_date_cnt) + ' tweets outside of valid time range') logging.info(str(in_db_cnt) + ' tweets already in database') - # DEBUG: Print extracted tweets - # for t in tweets: - # print(t) - # Login to account on maston instance mastodon = None if len(tweets) != 0: