Wed
Apr 29th

Delicious Twitter Sync

Quite Useful has a Delicious account which we use to share links we post to twitter.com/quiteuseful.  I wanted to sync up our Twitter link posts with Delicious, so I wrote a script to do the job.

The script will download a Twitter account’s recent posts, find links, and tag links based on hashtags — which is why our Twitter posts almost always have a generous helping of hashtags.

Running the twitter2delicious script with --help will show the available options:

Usage: ./twitter2delicious.rb [options]
    -d, --delicious=username         Your Delicious username
    -p, --password=password          Your Delicious password
    -t, --twitter=username           Your Twitter username
    -H, --help                       This text

It can also be run interactively, where it will prompt for usernames and passwords.

You can get the script from here: twitter2delicious.  It’s a ruby script and requires a few gems to get going, so you may need to install rdelicious, simple-rss and hpricot.

If you like the script or have any ideas for it, message me on GitHub! (I’m alexyoung on there).

Code Notes

Twitter’s search API includes hashtags as links.  Of course, you don’t want to post these to Twitter, so the script will filter them.  However, it also escapes the hashtags, so it filters like this:

url.match(/\/search\?q=#/) or url.match(/\/search\?q=%23/))

The Delicious API doesn’t mind if you post the same link twice, so I’ve taken the easy option and ignored this.  I run the script once a day (you could actually cron it), and it silently ignores reposted links reliably.

It also tries to follow tinyurl links to get the link’s real title.  It doesn’t include the original tweet in the Delicious post description in case it doesn’t make sense — we write tweets in this format: “an interesting link: http://example.com #tags” which doesn’t translate into a Delicious description very well.

Comments (View)
Related Posts Widget for Blogs by LinkWithin