Data Migration from sports-tracker.com to strava.com

A few years ago, I used the Sports-Tracker.com app for activity logging. After switching to Strava, I wanted to move my activity data to the new platform. Sports-Tracker allows exporting of activities, but only one-by-one. This is rather tedious with a few hundred activities.

Then I came across a small script that will create batch download commands for each activity when run in Chrome. The original script can be found here, but I had to do a few slight modifications to make it work again.

// based entirely on this blog post:
// http://druss.co/2016/04/export-all-workouts-from-sports-tracker/
// unfortunately the original script no longer works, moslty because jQuery is 
// no longer available on sports-tracker pages.
// 

var key = "sessionkey=";
var valueStartIndex = document.cookie.indexOf(key) + key.length;
var token = document.cookie.substring(valueStartIndex, document.cookie.indexOf(';', valueStartIndex));
function downloadOne(item) {
    var href = item.href;
    var id = href.substr(href.lastIndexOf('/') + 1, 24);
    var url = 'https://www.sports-tracker.com/apiserver/v1/workout/exportFit/' + id + '?token=' + token;
    var filename = 'SportsTracker-' + id + '.fit';
    console.log('curl -o ' + filename + ' "' + url + '";sleep 2');
} 
function loopThroughItems(items)
{
    var i = 0;
    for (i = 0; i < items.length; i++) {
        downloadOne(items[i]);
}
var items = document.querySelectorAll("ul.diary-list__workouts li a");
document.body.innerHtml = '';
loopThroughItems(items); 

To run the script, you have to do the following:
1) Login to your sports-tracker account using Google Chrome
2) Change URL to https://www.sports-tracker.com/diary/workout-list
3) Open browser console (Ctrl-Shift-I)
4) Paste the script, hit enter – it’ll run and print something like this to the cosole:
curl -o SportsTracker-<..id..>.fit „https://www.sports-tracker.com/apiserver…..“
5) Right-click on the colsole and save the contents to a file – call it something like „download-all-workouts.sh“
6) Edit the file: remove the javascript at the beginning of the file leaving only curl commands
6) Open (Linux bash) terminal (MinGW would be an option if you are using Windows)
7) Change to the directory where you saved the contents of the console
8) Fix permissions using chmod +x download-all-workouts.sh
9) Run the script: ./download-all-workouts.sh

Alternatively, you could download GPX files instead of FIT files. Just replace all occurences of fit with gpx in the JavaScript.

Some files will be downloaded with zero length. Just put the corresponding curl statements in another script and run it again until all files have been downloaded correctly.