Autopost RSS feed content to GNUsocial

using feed2omb on uberspace

Thanks to a little script called feed2omb written by Ciaran Gultnieks basically everyone is able to publish content from publicly available RSS-feeds in GNUsocial.

Requirements

Step 0: Login via SSH

To start you need to login on your uberspace account via ssh. If you dont know, how you should first read the following page of the uberspace documentation.

Basically you will have to set a password for SSH first using the webinterface. Afterwards you will be able to login by using the Terminal mentioned under requirements and the following command:

ssh USERNAME@SERVERNAME.uberspace.de

Step 1: fetch the script from Gitlab

Navigate to the ~/bin/ folder of your uberspace using the following command:

cd ~/bin/

Now fetch the feed2omb Script from Gitlab using the git clone command:

git clone https://gitlab.com/CiaranG/feed2omb.git

This should automatically create a new folder ~/bin/feed2omb/ including all the content you need. Switch to that folder before you continue to the next step.

cd ~/bin/feed2omb/

Step 2: setting up the config file

Next thing to do is moving the sample config to a new spot before we start editing it. If you plan to run the script on several RSS feeds I would highly to create a config/ folder and store your tweaked .config-Files there.

mkdir ~/bin/feed2omb/config/

Now copy the sample.config to the brand new config folder

cp ~/bin/feed2omb/sample.config ~/bin/feed2omb/config/my.config
REMARK: If you plan to run the script on several feeds make sure that you name the config files in reference to the connected RSS feed or GNUsocial account, to easily differentiate between the different config files.

It is time to edit the config file using the text editor nano

nano ~/bin/feed2omb/config/my.config

You will at least have to change the following 4 lines to get the script working:

  • feedurl = URL to the RSS feed you would like to use
  • apibaseurl = URL to the GNUsocial instance (e.g. http://quitter.es/api)
  • user = name of the GNUsocial account you are using
  • password = passwod of the GNUsocial account you are using

Several other options are also woth a look:

  • shortenallways = yes (shorten the URL for every post)
  • msgmode = switch from title to summary (or any other option/combination) to alter the content of your messages
  • messageregex & messagereplace = alter the content of the messages using regular expressions (e.g. add group-tags, remove unnecessary content)
  • hashtags = auto-add hash-tags or load them from the category-tag of the RSS feed item.

After you changed the config file to your need you should safe it by pressing CTRL+O and quit Nano after saving by pressing CTRL+X.

Step 3: test your configuration

It is time to check if your config file is working properly. First we will check if fetching the RSS feed and styling the content of your message works as expacted.

python ~/bin/feed2omb/feed2omb.py --update --test ~/bin/feed2omb/config/my.config

This should fetch the content of the RSS feed and copy the output message to the Terminal instead of publishing it to your GNUsocial instance. If the message is not styled correctly you should tweak your my.config again using Nano and then trying the --test command again. Cycle this as long as you are not satisfied. When you are done: Try to post your first message to your GNUsocial instance by removing the --test flag in the upper command.

python ~/bin/feed2omb/feed2omb.py --update ~/bin/feed2omb/config/my.config

If you encounter any errors know this will be most likely caused by errors in either your password, the apibaseurl, user or password line. Make sure you are using the right URL and username. Some special characters that are commonly used in pass-phrases are also breaking the script. # and curly brackets are two (actually three) examples. Make sure you are not using superfancy special chars here.

If nothing went wrong you should see a new message in your GNUsocial Account.

Step 4: setting up a cronjob

It would be quite annoying to manually trigger the posting by typing in the command above every 5 minutes to post new messages from the RSS feed to GNUsocial.

As many others uberspace is offering you a cron scheduler to do tasks for you that should be repeated from time to time.

All you have to do is change the command above into a cron job. You can initiate and edit the cron task file by using the following command:

crontab -e

There should be a nearly blank screen add the following line to it:

*/5 * * * * python /home/USERNAME/bin/feed2omb/feed2omb.py -u /home/USERNAME/bin/feed2omb/config/my.config

Make sure you replaced USERNAME with your real exisiting Uberspace username which you already used to login using SSH.

This line runs your script every 5 minutes. Refer to the wikipedia page and various manuals and how-tos in the world wide web for tweaks and tricks on setting the time to your need. Quit the cron configuration window by hitting CTRL+O for saving and CTRL+X for exiting.

Your post-command should be executed at the given period now. Uberspace will inform you by mail if you messed up and (one of) your cronjob fails.

Show your support

Clapping shows how much you appreciated an anarchists perspective’s story.