From adb09092978edd4f7af17895f84f6ce958d6786c Mon Sep 17 00:00:00 2001 From: octospacc Date: Tue, 16 Aug 2022 13:39:24 +0200 Subject: [PATCH] Add README, commit Config --- MastodonFeedHTML/Example.Config.py | 30 ++++++++++++++++++++++++++++ MastodonFeedHTML/MastodonFeedHTML.py | 6 +++--- MastodonFeedHTML/README.md | 10 ++++++++++ 3 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 MastodonFeedHTML/Example.Config.py create mode 100644 MastodonFeedHTML/README.md diff --git a/MastodonFeedHTML/Example.Config.py b/MastodonFeedHTML/Example.Config.py new file mode 100644 index 0000000..6dfab9d --- /dev/null +++ b/MastodonFeedHTML/Example.Config.py @@ -0,0 +1,30 @@ +# Feeds configuration. +Feeds = [ + { + "URLs": ["https://mastodon.social/@Mastodon", "https://botsin.space/@sitoctt"], # List of Mastodon profile URLs to scrape. + "IncludeRetoots": True, + "IncludeReplies": True, + "LocalSave": True, # Whether or not to save posts as HTML files locally. + "SendMail": False, # Whether or not to send posts via email. + "MailTo": ["example@example.com"] # List of email recipients. + } +] + +# SMTP configuration (only required for sending mail). +MailUsername = "example@example.com" +MailPassword = "Example" +MailServer = "smtp.example.com" +MailPort = 465 + +# How often to refresh the feeds (in seconds). Set to 0 for a single run, instead of having the program sleep. +LoopTime = 300 + +# Additional time (in seconds) to sleep between every mail sent, to prevent spam. +MailSleep = 10 + +# Whether or not to allow spaces in file names. +SpacesInFiles = True + +# Other advanced settings. +AppName = "MastodonFeedHTML" +UserAgent = AppName diff --git a/MastodonFeedHTML/MastodonFeedHTML.py b/MastodonFeedHTML/MastodonFeedHTML.py index 9bde210..833720f 100644 --- a/MastodonFeedHTML/MastodonFeedHTML.py +++ b/MastodonFeedHTML/MastodonFeedHTML.py @@ -20,7 +20,7 @@ def SureList(Item): def MakePathStr(Str): for c in ('<>:"/\\|?*'): Str = Str.replace(c, '_') - if NoSpacesFile: + if not SpacesInFiles: Str = Str.replace(' ', '_') return Str @@ -77,7 +77,7 @@ def HandleFeed(URLs, IncludeRetoots, IncludeReplies, LocalSave, SendMail, MailTo


-

Via https://gitlab.com/-/snippets/2388397

+

Via https://gitlab.com/octospacc/bottocto/-/tree/main/MastodonFeedHTML

""" if SendMail: Message = MIMEMultipart() @@ -136,7 +136,7 @@ def HandleFeed(URLs, IncludeRetoots, IncludeReplies, LocalSave, SendMail, MailTo def HandleFeedList(List): for Feed in List: - print(f"[I] Handling item ->\n: {Feed}") + print(f"[I] Handling Feed ->\n: {Feed}") HandleFeed( URLs=SureList(Feed['URLs']), IncludeRetoots=Feed['IncludeRetoots'] if 'IncludeRetoots' in Feed else True, diff --git a/MastodonFeedHTML/README.md b/MastodonFeedHTML/README.md new file mode 100644 index 0000000..6071599 --- /dev/null +++ b/MastodonFeedHTML/README.md @@ -0,0 +1,10 @@ +Python script that scapes public posts from lists of Mastodon profile URLs, and: + - Sends them to lists of email addresses; + - Saves them as HTML files on your machine. + +It works with any type of post, be it text or media. Retoots and replies are also supported. + +_Note: This script only sees the last 20 posts on a profile page. Multi-page scraping is not yet supported. If you post or share a lot, you may want to set the refresh time at a very low number._ + +Useful for archiving your own posts, or whatever. +Protip: you can repost your content on via email with this tool!