Department of dirty hacks: the link blog script

As promised, the link blog stuff is now working. It’s pulling links and descriptions from my Delicious bookmarks and posting them to LJ in batches of 10 or more, or when there’s stuff to be posted and nothing’s been posted for 4 days. Let me know if it becomes annoying.

Here comes the science

It turns out there’s a PHP script called Delicious Glue to do this, but that would involve using PHP, so no (gateway drug: next thing you know, you’ll be using Perl). It looks like that script also doesn’t cope with the brave new world of Unicode terribly well, doesn’t tag the LJ post using the tags from Delicious, and doesn’t support the elaborate posting scheme described in the previous paragraph. Also, it wasn’t invented here.

So I did it in Python. Mark Pilgrim’s excellent Universal Feed Parser module does much of the heavy lifting. Posting to LJ using XML RPC turns out to be surprisingly easy using the built-in xmlrpclib. Most of the faff comes in getting it to persist state between runs of the script, which I’m doing using pickle. Here’s the code: you’d need to be a programmer to adapt it for your own use, but if you are, it shouldn’t be hard. I’ll probably run it daily using cron.

2 Comments on "Department of dirty hacks: the link blog script"

  1. The version of the Delicious Glue script that I’m using does use tags.

    Doesn’t seem to cope so well with unicode – but I think that’s down to the server configuration I have, some people have no problem with it.

    The main issue I had was getting the timezone right – the original script posted at whatever the server time was, which meant that it hit the “You’re trying to post before an existing post!” problem occasionally. I had to write some code to get that right.

    yours sounds useful – but I’d have to set up a cron job to run it. And a few people are using my one at the moment, and presumably I’d have to set up separate copies for each person?

    Now, if you were to generalise this into a “RSS->LJ” poster, and stick a nice web front end on it…


    1. Delicious Glue script that I’m using does use tags.

      I was after something which would tag the LJ entry using tags from the delicious entries. I don’t think Delicious Glue currently does that, from looking at your link blog entries. (Also, I didn’t want my script to create new tags as I use a lot more tags on delicious and LJ has some arbitrary limit on the number of tags you can use, so the script checks that I’ve already used a tag in my LJ before using it to tag an entry).

      I’ve not run into timezone problems yet: I’m just using the local time where the script runs, which is also what I use for my entries, so it works. If you had people in other timezones, that’d be a problem.

      It’d certainly be possible to make the thing read a configuration file rather than having lots of hard URLs all over the place (but I did say it was a hack 🙂 I don’t think I’d want a web front-end: I don’t actually want lots of people’s LJ passwords…


Leave a Reply

Your email address will not be published. Required fields are marked *