Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Hua committed Mar 1, 2020
0 parents commit 0975f9f
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 0 deletions.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Adidas-Runtastic-Map-Convertor

Map data exported from Adidas Runtastic is using Unix timestamp which is non-readable by human being.

This script convert them into datetime so users can pick the correct data file for their own purposes.

## Download the Map data

1. login to your Runtastic account in your browser

2. Click your profile icon on the top right corner and select `Settings`

3. Switch to `Export` tab and click `Export`

4. Wait and then download

## Use this script

1. extract `Sport-sessions/*.json` into `maps` folder in this project

2. run `npm run dev`

3. the result will save to `summary.json` of this project

4. open `summary.json` and look for the date and filename

5. find the gpx file in `GPS-data` folder

6. enjoy
57 changes: 57 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
'use strict';

const fs = require('fs');

listFiles()
.then(summary => {
//console.log(summary);
writeSummary(summary);
});

function listFiles() {
return new Promise((resolve, reject) => {
let summary = [];
fs.readdir('maps', (err, maps) => {
let promises = maps.map(map => {
return new Promise((resolve, reject) => {
return readFile(`maps/${map}`)
.then(mapObj => {
console.log(`Processing ${map}`);
let mapInfo = JSON.parse(mapObj.toString());
summary.push({
name: map,
start_time: new Date(mapInfo.start_time),
end_time: new Date(mapInfo.end_time)
});
return resolve(summary);
}, err => {
return reject(err);
});
});
});
Promise.all(promises)
.then(() => {
summary.sort((a, b) => {
return (a.start_time > b.start_time ? 1 : -1);
})
return resolve(summary);
});
});
});
}

function readFile(path) {
return new Promise((resolve, reject) => {
fs.readFile(path, (err, data) => {
if (err) return reject(err);
return resolve(data);
});
});
}

function writeSummary(summary, path) {
fs.writeFile('summary.json', JSON.stringify(summary), err => {
if (err) console.log(err);
console.log('summary done');
});
}
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "adidas-runtastic-map-convertor",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"dev": "node app.js"
},
"author": "Wahackr"
}
Loading

0 comments on commit 0975f9f

Please sign in to comment.