From 482ff34430de3b587e933e71f218939a7dbe5b93 Mon Sep 17 00:00:00 2001 From: Ed Summers Date: Sat, 9 Jun 2018 13:28:17 -0400 Subject: [PATCH] added hashtags --- README.md | 26 ++++++++++++++++---------- feediverse.py | 18 +++++++++++------- setup.py | 2 +- 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index da84228..76a74e4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ *feediverse* will read RSS/Atom feeds and send the messages as Mastodon posts. -It's kind of the same thing as [feed2toot] but just one module that works with -Python 3. +Please use responsibly! *feediverse* is kind of the same thing as [feed2toot] +but it's just one module that works with Python 3 ... and I was bored. ## Install @@ -26,10 +26,14 @@ format is: {title} {url} -But you can use the `{summary}` as well, and also add text like so: +If you want you can use `{summary}` in your template, and add boilerplate text +like so: Bookmark: {title} {url} {summary} +`{hashtags}` will look for tags in the feed entry and turn them into a space +separated list of hashtags. + ## Multiple Feeds Since *feeds* is a list you can add additional feeds to watch if you want. @@ -43,14 +47,16 @@ Since *feeds* is a list you can add additional feeds to watch if you want. ## Why? -I created *feediverse* because I wanted to send my Pinboard bookmarks to Mastodon. -I've got an IFTTT recipe that does this for Twitter, but IFTTT doesn't appear to -work with Mastodon yet. +I created *feediverse* because I wanted to send my Pinboard bookmarks to +Mastodon. I've got an IFTTT recipe that does this for Twitter, but IFTTT +doesn't appear to work with Mastodon yet. That being said *feediverse* should +work with any RSS or Atom feed (thanks to [feedparser]). -That being said *feediverse* should work with any RSS or Atom feed (thanks to -[feedparser]). But please be responsible. Don't fill up Mastodon with tons of -junk just because you can. That kind of toxic behavior is why a lot of people -are leaving other social media platforms and trying to start over in Mastodon. +## Warning! + +Please be responsible. Don't fill up Mastodon with tons of junk just because you +can. That kind of toxic behavior is why a lot of people are trying to establish +other forms of social media like Mastodon. [feed2toot]: https://gitlab.com/chaica/feed2toot/ [feedparser]: http://feedparser.org/ diff --git a/feediverse.py b/feediverse.py index bd95714..72e1b74 100755 --- a/feediverse.py +++ b/feediverse.py @@ -30,6 +30,13 @@ def main(): save_config(config, config_file) +def get_config_file(): + if __name__ == "__main__" and len(sys.argv) > 1: + config_file = sys.argv[1] + else: + config_file = os.path.join(os.path.expanduser("~"), ".feediverse") + return config_file + def save_config(config, config_file): copy = dict(config) copy['updated'] = datetime.now(tz=timezone.utc).isoformat() @@ -57,10 +64,14 @@ def get_feed(feed_url, last_update): return new_entries def get_entry(entry): + hashtags = [] + for tag in entry.get('tags', []): + hashtags.add('#{}'.format(tag.value)) return { 'url': entry.id, 'title': entry.title, 'summary': entry.get('summary', ''), + 'hashtags': ' '.join(hashtags), 'updated': dateutil.parser.parse(entry['updated']), } @@ -97,12 +108,5 @@ def setup(config_file): print("Add a line line this to your crontab to check every 15 minutes:") print("*/15 * * * * /usr/local/bin/feediverse") -def get_config_file(): - if __name__ == "__main__" and len(sys.argv) > 1: - config_file = sys.argv[1] - else: - config_file = os.path.join(os.path.expanduser("~"), ".feediverse") - return config_file - if __name__ == "__main__": main() diff --git a/setup.py b/setup.py index 7837253..048a97d 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ with open("README.md") as f: setup( name='feediverse', - version='0.0.1', + version='0.0.2', url='https://github.com/edsu/feediverse', author='Ed Summers', author_email='ehs@pobox.com',