mirror of
https://gitlab.com/jeancf/twoot.git
synced 2025-02-26 01:48:42 +00:00
Basic functionality OK with youtube
This commit is contained in:
parent
3404b7df6a
commit
381845e514
16
default.toml
16
default.toml
@ -1,17 +1,17 @@
|
|||||||
[config]
|
[config]
|
||||||
# twitter account name without '@'
|
# twitter account name without '@'
|
||||||
twitter_account = ""
|
twitter_account = "unrealengine"
|
||||||
|
|
||||||
# Domain name of Mastodon instance
|
# Domain name of Mastodon instance
|
||||||
mastodon_instance = ""
|
mastodon_instance = "i"
|
||||||
|
|
||||||
# Mastodon username (login email address)
|
# Mastodon username (login email address)
|
||||||
mastodon_user = ""
|
mastodon_user = "u"
|
||||||
|
|
||||||
[options]
|
[options]
|
||||||
# Download videos from twitter and upload them on Mastodon
|
# Download videos from twitter and upload them on Mastodon
|
||||||
# Default is false
|
# Default is false
|
||||||
upload_videos = true
|
upload_videos = false
|
||||||
|
|
||||||
# Also post the "reply-to" tweets from twitter account
|
# Also post the "reply-to" tweets from twitter account
|
||||||
# Default is false
|
# Default is false
|
||||||
@ -23,15 +23,15 @@ skip_retweets = false
|
|||||||
|
|
||||||
# Replace redirected links in tweets with direct URLs
|
# Replace redirected links in tweets with direct URLs
|
||||||
# Default is false
|
# Default is false
|
||||||
remove_link_redirections = false
|
remove_link_redirections = true
|
||||||
|
|
||||||
# Clean up URLs in tweets to remove trackers
|
# Clean up URLs in tweets to remove trackers
|
||||||
# Default is false
|
# Default is false
|
||||||
remove_trackers_from_urls = false
|
remove_trackers_from_urls = true
|
||||||
|
|
||||||
# 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 = 2
|
||||||
|
|
||||||
# Minimum age of tweet to post (in minutes)
|
# Minimum age of tweet to post (in minutes)
|
||||||
# Default is 0 (post tweet as soon as possible)
|
# 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
|
# Replace youtube.com link by random alternative out of this list
|
||||||
# Default is []
|
# Default is []
|
||||||
youtube = ["piped.kavin.rocks", ]
|
youtube = ["piped.kavin.rocks", "invidious.flokinet.to"]
|
||||||
|
|
||||||
# Replace reddit.com link by random alternative out of this list
|
# Replace reddit.com link by random alternative out of this list
|
||||||
# Default is []
|
# Default is []
|
||||||
|
11
twoot.py
11
twoot.py
@ -152,8 +152,11 @@ def _substitute_source(domain):
|
|||||||
param domain: Domain name to substitute
|
param domain: Domain name to substitute
|
||||||
:return: domain or sustitute if applicable
|
:return: domain or sustitute if applicable
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
logging.debug("Checking domain " + domain)
|
||||||
|
|
||||||
youtube_subst = TOML["options"]["substitution"]["youtube"]
|
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)]
|
domain = youtube_subst[random.randint(0, len(youtube_subst) - 1)]
|
||||||
logging.debug("Replaced youtube.com by " + domain)
|
logging.debug("Replaced youtube.com by " + domain)
|
||||||
|
|
||||||
@ -178,7 +181,6 @@ def clean_url(dirty_url):
|
|||||||
_remove_trackers_query(url_parsed.query),
|
_remove_trackers_query(url_parsed.query),
|
||||||
_remove_trackers_fragment(url_parsed.fragment)
|
_remove_trackers_fragment(url_parsed.fragment)
|
||||||
])
|
])
|
||||||
|
|
||||||
if cleaned_url != dirty_url:
|
if cleaned_url != dirty_url:
|
||||||
logging.debug('Cleaned URL from: ' + dirty_url + ' to: ' + cleaned_url)
|
logging.debug('Cleaned URL from: ' + dirty_url + ' to: ' + cleaned_url)
|
||||||
|
|
||||||
@ -739,15 +741,12 @@ def main(argv):
|
|||||||
tweets.append(tweet)
|
tweets.append(tweet)
|
||||||
|
|
||||||
logging.debug('Tweet %s added to list of toots to upload', tweet_id)
|
logging.debug('Tweet %s added to list of toots to upload', tweet_id)
|
||||||
|
logging.debug('TEXT:\n' + tweet["tweet_text"])
|
||||||
|
|
||||||
# Log summary stats
|
# Log summary stats
|
||||||
logging.info(str(out_date_cnt) + ' tweets outside of valid time range')
|
logging.info(str(out_date_cnt) + ' tweets outside of valid time range')
|
||||||
logging.info(str(in_db_cnt) + ' tweets already in database')
|
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
|
# Login to account on maston instance
|
||||||
mastodon = None
|
mastodon = None
|
||||||
if len(tweets) != 0:
|
if len(tweets) != 0:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user