Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Download all workouts from sports-tracker
// 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.
//
// I've compiled the changes proposed in the comments in the script below.
// to use the script, login to your sports-tracker account
// change URL to http://www.sports-tracker.com/diary/workout-list
// open browser console (Cmd-Shift-I)
// paste the script, hit enter - it'll run and print something like this to the cosole:
// curl -o SportsTracker-<..id..>.gpx "http://www.sports-tracker.com/apiserver....."
// right-click on the colsole and save the contents to a file, call it download-all-workouts.sh
// open terminal, change to the directory where you saved the contents of the console
// edit the file - remove the javascript at the beginning of the file leaving only curl commands
// fix permissions:
// $>chmod +x download-all-workouts.sh
// run the script:
// $>./download-all-workouts.sh
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 = 'http://www.sports-tracker.com/apiserver/v1/workout/exportGpx/' + id + '?token=' + token;
var filename = 'SportsTracker-' + id + '.gpx';
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);
@Flaviu1972

This comment has been minimized.

Copy link

@Flaviu1972 Flaviu1972 commented Jun 22, 2018

The "Download-all-workouts.sh" is Linux, right? Anyone knows of a way to do this in Windows? Found/tried a utility called STExport.exe and can't get it to work.... I'm out of options....

@rjvdboon

This comment has been minimized.

Copy link

@rjvdboon rjvdboon commented Jul 4, 2018

Have a look at the original for usage instructions (https://gist.github.com/anonymous/9abc8d9c376bbc6aa853b477a50e8932), and then maybe use my updated gist (https://gist.github.com/rjvdboon/54b9bbb8c56471fd864c00422b92a722) which fixes some problems

@Hao-Wu

This comment has been minimized.

Copy link

@Hao-Wu Hao-Wu commented Sep 27, 2018

Works fine, only if change the API url to https on line 31 https://gist.github.com/devalls/f82eaaa6d3b7f15a1c16fbdc388eb88e#file-sports-tracker-download-js-L31

And be also take care of pagination, you need to expand all workout in the list page to get all workouts id.

@lopic34

This comment has been minimized.

Copy link

@lopic34 lopic34 commented Dec 26, 2018

Thank you very much for this useful process!

Some tricks for some newbies (like me):

  • Before to "paste the script" (in console), you may need to write : allow pasting and hit Enter (in the console)
  • When you "clean" the javascript part in the script file, you may need to remove debugger eval code:10:3 (or something like this), in my case:
    curl -o SportsTracker-aaaaaaa.gpx "https://www.sports-tracker.com/apiserver/v1/workout/exportGpx/aaaaaaa?token=ggggggggggggadsr";sleep 2 **debugger eval code:10:3**
  • You can sort activities the webpage before to run the script (if you want to have one extract for bike GPS, another one for running...)
@lopic34

This comment has been minimized.

Copy link

@lopic34 lopic34 commented Dec 26, 2018

How can we get the "description" field ?
It would be great to give file name (or a part of the name) with this description.

@hannta

This comment has been minimized.

Copy link

@hannta hannta commented Feb 13, 2019

Btw. you can get .fit files if you change url to http://www.sports-tracker.com/apiserver/v1/workout/exportFit/ and the filename accordingly.

At least for me, .fit files works better when moving data to Strava.

@adamjak

This comment has been minimized.

Copy link

@adamjak adamjak commented Apr 23, 2019

I must edit curl command with L param like this curl -L -o ...

@KonstantinosSykas

This comment has been minimized.

Copy link

@KonstantinosSykas KonstantinosSykas commented Apr 21, 2020

Some updates:

  1. The API server name has changed to api.sports-tracker.com.
  2. I have come up with some code to add the activity type and date in the exported filename.

On that matter, I forked the code here to include these two updates.
The above was tested successfully (with @hannta's variation for .fit export) on Win10/PowerShell with Chrome.

@vojtah

This comment has been minimized.

Copy link

@vojtah vojtah commented Apr 24, 2020

That was the problem I was having. Thanks @adamjak

@inaldonascimento

This comment has been minimized.

Copy link

@inaldonascimento inaldonascimento commented Jul 29, 2020

Tks @KonstantinosSykas the update URL.
Tks @hannta the update to fit.
these make me successful download my workouts. thank you all!!!

@Bilan

This comment has been minimized.

Copy link

@Bilan Bilan commented Nov 2, 2020

I fixed some bugs and added activity images downloading:
https://gist.github.com/Bilan/33770ecb8160ee1a79864bd3d37c0f03

@jorugit

This comment has been minimized.

Copy link

@jorugit jorugit commented Nov 10, 2020

The "Download-all-workouts.sh" is Linux, right? Anyone knows of a way to do this in Windows? Found/tried a utility called STExport.exe and can't get it to work.... I'm out of options....

https://docs.microsoft.com/de-de/windows/wsl/install-win10
and than do this for access the generated files:
https://www.howtogeek.com/261383/how-to-access-your-ubuntu-bash-files-in-windows-and-your-windows-system-drive-in-bash/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.