søndag den 26. februar 2012

Exporting RunKeeper data to Garmin Connect

Not exactly audio-related, but I wanted to put it somewhere for others to find it (maybe turn it into a bookmarklet).

I've used RunKeeper for tracking workout activities a while ago, but today I use Garmin Connect. They both support the .gpx format for activities, but the first one doesn't support mass export and the second doesn't support mass import.

Here's the quick-and-dirty approach I did (using TextMate, but you can improvise):

  1. Fire up Safari or Chrome, log into runkeeper.com and go to Activities.
  2. Open the javascript console and write the following:
    l=$("#activityHistoryMenu div.accordianCellContents div[link]") for(var i=0;i<l.length;i++){ console.log(l[i].getAttribute("link"))} This uses JQuery (which is already loaded by the site) to gather all activity elements and the prints out the activity link for each activity to the console.
  3. Copy these links to TextMate and mess around with the regexp search-replace so that the links look like this: http://runkeeper.com/download/activity?activityId=9990434&downloadType=gpx&downloadType=gpx Remember, TextMate supports group capturing, so you can search for eg. /user/[username]/activity/(\d) and replace with http://..........$1&downloadType=.......
  4. Now change to Ruby-mode, surround your list of urls with l=%w{...} and append this to your 'script':  l.each{|u| system ("open -a Safari \"#{u}\"") sleep 1 }
  5. Make sure you're already logged into Runkeeper in Safari, and execute the script (cmd-R). All your activities will end up in the Downloads-folder as .gpx files.
  6. So that's the Runkeeper-part. The Garmin Connect-part is quite a bit easier, since there's already a python-script for mass-uploading to Garmin Connect. Get it here: http://sourceforge.net/projects/gcpuploader/
  7. Now just execute this in the terminal:
    python gupload.py -v 1 -l [username] [password] ~/Downloads/*.gpx
    The script will show you the status of the upload.

Ingen kommentarer:

Send en kommentar