« PyCon 2009 wrap-up: Organization | Main | New book on the Bach cello suites »

Twitter exercise reporting

I spent several hours this weekend writing a script to search a Twitter feed for posts describing a bike ride (or a walk, or a run) and summarizing the results. Here's the current output for my feed, stuck in an IFRAME element:

Barb suggested the original idea. The script searches a user's Twitter feed for tweets tagged with '#bike' or '#run' or '#walk'. Each tweet is scanned for a distance in the form 'N miles', 'N.N miles', 'N meters', or 'N km', and for a time in the form 'N.N hours' or 'N minutes'. The scanning script tries to be polite in its scanning of Twitter, caching tweets in an SQLite database and only re-scanning at intervals.

The HTML output of the script uses jQuery to assemble output based upon the stored data. Currently the final output is very simple, just a table of dates and the exercise activity on that day. This could be made much fancier; the script could output either HTML or JSON, Imperial or metric units; there could be different tabs to view bike rides, runs, or walks; graphs could be produced; etc. The goal is that you could put an IFRAME in your weblog's sidebar and show a running total of your exercise.

Currently I have the CGI script up at http://www.amk.ca/cgi-bin/running.cgi?twitter-id. I don't promise to keep that URL alive indefinitely -- eventually I'll need to wrap it in a little Django app to let you customize your display -- but you can play with it for now. The Mercurial repository is at code.amk.ca/running-sum/.

Post a comment

About

This page contains a single entry from the blog posted on April 19, 2009 3:33 PM.

The previous post in this blog was PyCon 2009 wrap-up: Organization.

The next post in this blog is New book on the Bach cello suites.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.31