Using Twitter as Social Bookmarking Service

A while ago I realized that I totally stopped using social bookmarking services since I started tweeting. Whenever I find an interesting link I share it on Twitter. If I find interesting links tweeted by the people I follow I’m most likely to favorite that tweet. I guess that’s the way most people use Twitter. How often did you check someone’s public links on delicious? I rarely did.

With Twitter we now we have a social bookmarking system that works perfectly on the input side. Not only do I tag my links but I also describe in a few words what the website is about, and why it is worth sharing. But when it comes to getting the information out of Twitter, things start to get ugly. Have you ever tried to find a link you retweeted months ago? I did. The Twitter search won’t help you since it is limited to the most recent tweets. The only thing you can do is to scroll down your timeline and click the ‘load more’ link until you find what you look for.

Enough of the problem, let’s come to the solution. I wrote small python script that stores my tweets and favorites in a local sqlite database. It does so using Mike Verdone’s wonderful Twitter API for Python. I installed the script as a local cronjob that runs every hour so my database will remain up to date all the time.

Then a second script allows me to perform simple searches on that database and writes the output to a html file. Finally I integrated the search into Alfred, a spotlight-like tool for making my life easy. Now I just type “tweets foo” in Alfred and the search result html will be opened instantly.

Here’s a demo video:

While at hacking I also built two special modes: Typing “tweets favs” will simply output all tweets that I marked as favorites and typing “tweets March 2010″ will return, well, all tweets from that month.

Here’s the source code of the two scripts and the Alfred script. Just make sure to enter your own Twitter name and create some OAuth keys for the script.

https://gist.github.com/2349453

Last remark: I’m pretty sure that there’s some amazing web service out there that does the same for you without the need to hazzle around with python scripts. However, I haven’t checked them out since I like to access my tweets offline as well (for instance when sitting in a plane or train).