vrypan — panayotis vryonis
My blog is a digital scrapbook of ideas, thoughts and personal events. My home is vrypan.net.
Home — Archive: All · English · Greek — RSS Feeds: full feed · other options
#howto #pubsubhubbub #open web #scripting

trigger command-line scripts from pubsubhubbub

I’m working on a set of command line tools that will allow my home server (on my ADSL line) to aggregate content (my content, from tumblr, twitter, etc.) and publish it in a blog-like format using bucket3 and amazon S3.

[ note: In order to make this work on your actual home PC/server, you will probably have to use a dynamic DNS service, and set up you router so that port 9000 is mapped to your computer’s 9000 port. ]

A very important piece I was missing was a way to trigger events on my home server when my tumblog is updated.

I decided to rely on pubsubhubbub as tumblr use superfeedr.com for their feeds. Here are the steps I followed.

1. I created a simple pubsub “listener” script in python, listener.py

- listener.py listens to port 9000 on my home server, for requests like ‘/pubsub/…’
- if the request has a “hub.challenge” parameter it replies with its value (this is required during the pubsub registration process, more on this later).
- if the received HTTP Headers include a “LINK:” head, extract the corresponding feed name from it and print it to stdout.
- for all other requests, the listener replies with “OK”.

2. I created an account on superfeedr.com (it’s free).

3. Then, I went to superfeedr.com->Dashboard->XMPP Console and added a new feed. (make sure your listener.py is up and running before adding the feed!)

- feed URL: http://picks.vrypan.net/rss
- endpoint: http://my_server_name:9000/pubsub/

(If the subscription was successful, make sure you stop listener.py before reading on.)

4. Now, I use a script that looks something like this on my home server: whenever picks.vrypan.net is updated, in less than a couple of seconds, superfeedr pings listener.py and automator.sh does the rest.

Yes, it actually works!

Share this post:
The Letter is a newsletter I send out whenever I have something to say or share. It may take a few days, weeks or months for the next one.
Privacy: I hate spam as much as you do, maybe more. I will not share your email with advertisers, etc.