feed2omb – A feed to microblog posting tool

Update: For the latest version and up to date documentation, please see the project page.

feed2omb is a simple tool that takes input from Atom or RSS feeds and posts updates to the open microblogging service of your choice. It should also (though I’m not going to try it) quite happily post to Twitter.

The feed reading is handled by Mark Pilgrim’s excellent Universal Feed Parser so it should be able to deal with any feed you throw at it. On the posting side, you can send the updates to open microblogging services such as those based on Laconica – this includes Identica.

Installation:

You should be able to run this on any operating system where you can install Python (tested with 2.5). In addition to feed2omb itself, you need the Universal Feed Parser and ConfigObj. Both dependencies can either be installed properly or just placed in the same directory as feed2omb.

Usage:

Create one or more config files (one for each feed) using the sample.config file as an example.

Run feed2omb.py --update --test yours.config to check everything is working. This will not post anything, but just output the new messages it finds. If everything looks good, you can run again with the –test option and schedule this to run on a regular basis.

You can specify as many config files as you need – each will be processed in turn. For help on the command line, use feed2omb.py --help.

Other Options

Instead of --update, you can specify --eat. In this case, new messages found will be marked as sent, but will not actually be sent. This is useful when setting up a new feed, to prevent the sending of lots of old items.

The --max restricts processing to a specified number of items per run. For example, specify --max=1 to only process one item. When set up this way, even if there are multiple new items in the feed, only one (the oldest) will be processed on each run. This can be used to avoid flooding the omb service with a batch of messages all at once.

FAQ:

Q: Now twitterfeed.com supports Laconica, why not just use that or something like it?

A: That would be easier, but: a) you have to give it your account details, b) it’s not ‘open’ and you can’t customise it, and c) you might be running a private Laconica instance on a non-public network.

Q: Where’s the source code?

A: In the zipped download (see above), or you can browse the git repository or clone it using git from there – e.g.:

   git clone http://git.ciarang.com/feed2omb.git

Q: What license is this released under?

A: AGPL v3

Q: Can it output the author’s name along with the entry’s title?

A: Yes, version 0.5 adds a ‘msgmode’ setting to the config file. With this set to ‘title’ (the default) just the entry’s title is sent. Setting it to ‘authtitle’ sends the author’s name followed by the title – this is useful for feeds with multiple authors, or aggregated feeds such as those sourced from a Planet installation.

Q: Why isn’t my question answered here?

A: You haven’t asked it yet. Ask me.

29 comments

  1. børge’s avatar

    Can I use this on Dreamhost without a lot of haxx0r skillz? :)

  2. CiaranG’s avatar

    @børge – I’ve never used Dreamhost but from a quick look at their features list I think the answer is probably yes. You would need to:

    1. Download feed2omb and the two dependencies (all links above) to a directory on your computer.
    2. Copy sample.config to yourname.config and edit it so it does what you want.
    3. Upload the whole lot to your Dreamhost account using FTP. It would need to go OUTSIDE your public_html directory – you don’t want this accessible through the web server.
    4. Set up a cron task to run “/whereyouputit/feed2omb.py -u yourname.confg” every 30 minutes, every hour, or whatever.

    If you try it, let me know what happens – I’ll try to help out if possible.

  3. highzeth’s avatar

    Working great apart from a little UTF-8 encoding it seems? =)

    –snip–
    Found new entry: http://www.digi.no/php/art.php?id=784334
    Sending new message:
    Traceback (most recent call last):
    File “feed2omb.py”, line 68, in ?
    print ‘ ‘+text
    UnicodeEncodeError: ‘ascii’ codec can’t encode character u’\xf8′ in position 15: ordinal not in range(128)
    –snip–

  4. CiaranG’s avatar

    Oops. Thanks for the report – I’ll get it fixed.

  5. CiaranG’s avatar

    Ok, try version 0.3 – new zip file linked above, or get the source from the repository. It was just the console output that was the problem, and it should be ok now. Strangely, the Norwegian characters worked fine on my UK Linux and Windows machines, but if it still doesn’t work for you let me know your operating system and locale settings.

  6. highzeth’s avatar

    The .no chars are displayed upon -u -t, as well as -u now. So its progress since it didnt show æøå in konsoll upon fetching in v0.2.

    Ive tried this on Ubuntu (gutsy & hardy), and Gentoo, same locales.

    –snip–
    Sending new message:
    Kraftig fartsøkning for populært minnekort – http://bit.ly/Vk5QK
    Traceback (most recent call last):
    File “feed2omb.py”, line 80, in
    resp=opener.open(config[‘apibaseurl’]+’/statuses/update.xml’,urlencode(data))
    File “/usr/lib/python2.5/urllib.py”, line 1250, in urlencode
    v = quote_plus(str(v))
    UnicodeEncodeError: ‘ascii’ codec can’t encode character u’\xf8′ in position 13: ordinal not in range(128)
    –snip–

    root@fun:~/feed2omb# locale -a
    C
    en_AU.utf8
    en_BW.utf8
    en_CA.utf8
    en_DK.utf8
    en_GB.utf8
    en_HK.utf8
    en_IE.utf8
    en_IN
    en_NZ.utf8
    en_PH.utf8
    en_SG.utf8
    en_US.utf8
    en_ZA.utf8
    en_ZW.utf8
    it_CH.utf8
    it_IT.utf8
    nb_NO.utf8
    no_NO.utf8
    POSIX
    —-

    So you have working posting with a .no feed in your setup?
    http://digi.no/rss is the feed Im pulling above, thanx for the respons & work you have done! =)

  7. CiaranG’s avatar

    Version 0.4 should solve the remaining unicode problem. I tried it with the feed you gave – the examples here look right to me: http://micro.ciarang.com/test1/all

    There are a couple of new command-line options too, which I’ve documented above.

  8. highzeth’s avatar

    Superb! All works, thanx. =)

  9. CiaranG’s avatar

    Updated for version 0.5 – new ‘msgmode’ config option and a bug fix for the –max option.

  10. Børge’s avatar

    highzeth: This is interesting! Are you making an account for digi.no on identi.ca, or another Laconica based micro blog? What’s your account? I’m making a list of all Norwegians on identi.ca! :)

  11. highzeth’s avatar

    @Børge no I was just testing various .no RSS feeds. =)

    I can be found at; http://fun.ohhh.no/hz primarly.

  12. Børge’s avatar

    hz: Aha, so that’s you. I should’ve guessed! Then We’re already following each other! :) Are there any other norwegians I should follow on fun?

  13. highzeth’s avatar

    I have no idea, Im a man that hates borders. =)

  14. mippe’s avatar

    mibbul@kek:~$ python /home/XXX/feed2omb/feed2omb.py –update –test identica.config
    feed2omb version 0.5
    Copyright 2008 Ciaran Gultnieks

    Reading config: identica.config
    Reading feed…
    Traceback (most recent call last):
    File “/home/XXX/feed2omb/feed2omb.py”, line 64, in ?
    feed=feedparser.parse(config[‘feedurl’])
    File “/home/XXX/feed2omb/configobj.py”, line 580, in __getitem__
    val = dict.__getitem__(self, key)
    KeyError: ‘feedurl’

    Help! :(

    1. CiaranG’s avatar

      @mippe – looks like you are missing the feedurl in your config file.

    2. CiaranG’s avatar

      There is much more documentation, and the latest version, at http://projects.ciarang.com/p/feed2omb.

      You can also log bugs and feature requests in the tracker there.

    3. Alex’s avatar

      Thank you very musch for the application.
      I am trying to add RSS feed like this ‘feedurl = feed://feeds.feedburner.com/bla-bla-bla‘ and getting following output:
      % Reading config: cars.config
      % Reading feed…
      % Finished
      … and nothing :(
      Does ConfigObj supprort ‘feed://’. I changed feed to http and getting error in feedparser module.
      What am I doing wrong?

    4. CiaranG’s avatar

      Alex, I think it needs to be http, so you were right to change it. What’s the error you’re getting when you’ve done that?

    5. Alex’s avatar

      Error msg:
      Traceback (most recent call last):
      File “feed2omb.py”, line 243, in
      (t_year,t_month,t_day,t_hour,t_minute,t_second,t_x,t_x1,t_x2)=entry.updated_parsed
      File “/Users/alex/Desktop/feed2omb/extlib/feedparser/feedparser.py”, line 236, in __getattr__
      raise AttributeError, “object has no attribute ‘%s'” % key
      AttributeError: object has no attribute ‘updated_parsed’

      Feed url here _http://bit.ly/bBPDqN
      P.S. Regarding ‘feed://’ – I use Safari browser and it changed ‘http’ to ‘feed’ and opened the fedd itself :)

    6. CiaranG’s avatar

      Ok, that is a pretty bad feed, because it has no ‘last updated’ information. It’s not good that feed2omb is throwing that error message at you rather than something more helpful, but either way it still can’t deal with it the way it’s set up.

      HOWEVER – if you put ‘sentmode = sentlinks’ into the config file, in place of ‘sentmode = timestamp’ which I think you must have now, I think it will work. (Documentation for that feature can be found here: http://projects.ciarang.com/p/feed2omb/page/ConfigFiles.

    7. Alex’s avatar

      Thank you for help – it works!
      I have one more question: is it possible to form the OMB message from few fields, i.e. title+summary?
      And one more suggestion: to add some variable, where users could store some static text like tags or groups and add them to the end of msg. I am do this with RegExp’s, but it requer some knowledge of them and I am not sure everyone can use it so easy :)

    8. CiaranG’s avatar

      You can form the message from the author and the title, or from the title, or from the summary, but there’s no way currently of using the title and the summary together, although it would be easy to add.

      This is controlled by the ‘msgmode’ setting in the config file.

    9. marc’s avatar

      Hi

      I am testing feed2omb and got this error with any feed I try.

      Reading feed…
      Traceback (most recent call last):
      File “feed2omb.py”, line 238, in ?
      for entry in reversed(feed.entries):
      NameError: name ‘reversed’ is not defined

      It’s a DH shared hosting.

    10. marc’s avatar

      It was a python version problem. Sorry.

    11. CiaranG’s avatar

      @marc – yep, you just beat me to it. That ‘reversed’ function was introduced in Python 2.4, so you would need at least that. I’m pretty sure Dreamhost has later version, but they might not run by default.

    12. marc’s avatar

      Hi again

      I dont know why but… shortener is not working. I tried with all availables values.
      What it could be?

    13. marc’s avatar

      Ok, I missed the part where the shortener works only when the message its oversized, sorry.

Comments are now closed.