Tag Archives: mastodon

Join mastodon and slowly posting a wordpress RSS/atom feed

Mastodon is a social network that appears similar to twitter: you get a feed where you can see “toots” instead of “tweets” and you can send your own toots that will be seen by others listening to you or looking for a hashtag found in your toot.

Mastodon differs from twitter in that, like diaspora, it is not under corporate control. Also like diaspora, Mastodon is a non-profit, user-owned, distributed social network. The mastodon software is free software (GNU AGPL-3.0 or later). The mastodon server side is written in ruby and the mastodon frontend is written in react/redux. And also, like diaspora, it is part of the fediverse.

The first thing to do is to find a server to join. Again like diaspora, mastodon consist of interconnected servers. The servers are owned by different people with different rules for joining and different rules for what can be posted. The rules for registration can be quite different.

Note: you can share posts and listen to postings across servers. You’re not limited to the server you’re joining.

I looked at a couple of server and found them too restrictive, and ended up joining mastodon.social.

I can be reached on mastodon with @steinarb@mastodon.social.

The next thing to do, was to find a way to slowly post my wordpress feed in chronolgical order.

I quickly found a utility called feediverse. It’s written in python, and according to its author, written over the course of a weekend. According to the commits on feediverse’s github page it was written 2 years ago and has received no commits since then.

But it still does the job.

The first thing to do was install it on my debian server, as root, first install pip3, then install feediverse:

apt install python3-pip
pip3 install feediverse

But that took me only part of the way, because pointing that at my wordpress feed, would have fed the entire feed to mastodon in reverse chronological order. And like for diaspora, I wanted to post the feed one post a day in reverse order.

Note: The diaspora post contains changes to the wordpress feed (make the feed contain only the summaries of all posts on the blog) that should be applied to get the expected results.

I made the github issue Make it possible to slowly toot a comple feed in cronological order for feediverse with the intent to provide a PR on this.

However, I decided on a simpler solution: create a separate script that reads the feed and posts the entries, one post at a time, to a local file.

To use this script on a debian system:

  1. As root, install the dependencies of the script, using pip3:

    pip3 install pyyaml
    pip3 install feedparser
    pip3 install python-dateutil
    pip3 install feedgen
    pip3 install beautifulsoup4
  2. As your own user:
    1. Clone the github repo of the script:

      mkdir -p $HOME/git
      cd $HOME/git
      git clone https://github.com/steinarb/feedreverser.git
    2. Run feedreverser once manually with the following command:

      /usr/bin/python3 $HOME/git/feedreverser/feedreverser.py
    3. When prompted, give the feed URL (you will find this by right-clicking on an RSS symbol in your blog and copy the URL) and give /tmp/reversed.rss as the file to store the reversed feed in
    4. Add a crontab entry that runs the script once every 24h:

      10 6 * * * /usr/bin/python3 $HOME/git/feedreverser/feedreverser.py

At this point, /tmp/reversed.rss contains the oldest post in the feed, and within 24h it will be replaced by the second oldest post.

So the next thing to do, is to set up feediverse to post the contents of the feed in this local file, to mastodon.

First create an app in mastodon:

  1. Click on “Preferences”
  2. In the page that opens, click on “Development”
  3. In “Your applications”, click on “New application”
  4. In “New application”:
    1. In application name, give:

    2. Make sure read and wite are checked (they are, by default)
    3. Click on “Submit”
  5. In “Your applications”, click on “feediverse”
  6. Make a note of the values for access token and client secret. You will need them when doing the initial setup run of feediverse

Then, as your own user, run feediverse from the command line:


When prompted for

  1. “What is your Mastodon Instance URL”, give the top URL for your mastodon instance (for me, it is https://mastodon.social )
  2. “Do you have your app credentials already? [y/n]”, answer “y”
  3. “What is your app’s client id”, answer:

  4. “What is your client secret”, give the client secret you made a note of, earlier
  5. “access_token”, give the access token you made a not of, earlier
  6. “RSS/Atom feed URL to watch”, give a file URL for the file you told feedreverser to write to, i.e.

  7. Open the $HOME/.feediverse file (a YAML file), in a text editor, and change the line

    - template: '{title} {url}'


    - template: '{title} {url} {hashtags} {summary}'
  8. If your first post contains hashtags and a summary you would like to see as much of as possible in the toot, then delete the “updated:” line in the .feediverse file and re-run the feediverse command (mine didn’t)

Then add a crontab entry that runs feediverse once every 15 minutes:

15 * * * * /usr/local/bin/feediverse 2>/dev/null

The error redirect is because of the feediverse issue yaml warning from feediverse (I have provided a PR for this warning, referenced from the issue).

At this point feediverse is set up to slowly post your wordpress feed one feed entry a day.

If you let the setup continue past the emptying the feed backlog it will still work, but it will only post a single feed entry per day.

If you want to make feediverse post new entries to your feed just:

  1. In crontab, remove the entry for feedriverser
  2. In the $HOME/.feediverse file, replace:

    url: file:///tmp/reversed.rss

    with the feed URL you gave to feedreverser, e.g.

    url: https://steinar.bang.priv.no/feed/atom/

But note that there are some feediverse issues that might bite you, that feedreverser protects you from, by fixing them:

  1. Correctly handle hashtags with spaces: wordpress categores and tags with spaces in them, are currently posted as separate hashtags (e.g. “debian 8” becomes “#debian #8”). I have provided a PR for this, that replaces the spaces in categories and tags, with underscores
  2. toots with more than 500 characters fails: there is a typo in the commit that attempted to correct this, I have provided a PR that fixes the typo
  3. Would it be able to change html to readable plain text, and post images?: This means that titles with character entities in them show up sort of unreadable e.g. “Installing apache karaf on debian stretch”, and descriptions with both HTML tags and character entites can get very unreadable. The feedreverser script uses BeautifulSoup to fix this. There is at the point of writing no PR to feediverse to fix this

If you want a version of of feediverse that fixes the first two, you can get my fork of feediverse and use that instead:

  1. Clone my fork of feediverse and use the branch where I’ve combined my PRs:

    mkdir -p $HOME/git
    cd $HOME/git
    git clone https://github.com/steinarb/feediverse.git
    cd feediverse
    git checkout steinarsbranch
  2. Change the crontab line to run the cloned script instead of the script installed with pip3 (note that the need to redirect the error output is gone because the yaml issue is fixed):

    15 * * * * /usr/bin/python3 $HOME/git/feediverse/feediverse.py