• Stars
    star
    117
  • Rank 301,828 (Top 6 %)
  • Language
    Python
  • License
    MIT License
  • Created over 4 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Download your runs data from Nike Run Club and convert it to GPX format that can be imported in other running apps.

🏃 NRC Exporter

Download your runs from Nike Run Club and convert them to GPX format that can be imported in other running apps. I wrote an article about how I reverse engineered the NRC APK at my blog. You might find it a fun read if you are into that sort of stuff.

📃 Introduction

There was a time when I was a huge fan of Nike Run Club. It was the first running application I got hooked on when I started this sport. Later on down the road I realized that most of my new running friends were using Strava. I wanted to move my old runs from NRC to Strava but couldn't find a way to do it. Nike had recently removed the option to extract your data so I was stuck.

I did what any programmer would do. I spent a weekend trying to whip up a Nike Run Club data exporter. This program extracts all of your runs which have associated GPS data and converts them into the GPX format that can be imported to Strava.

I have made this program in a modular way with helpful docstrings for all functions. You are more than welcome to add extra features you need in this program. If you aren't tech-savy and/or want my help please open up an issue and we can figure it out from there.

🔧 Installation

You can either install the package from PyPI or source.

Using pip

The PyPI method is the easiest as it installs the dependencies as well (other than geckodriver). Run the following command to install from PyPI:

$ pip install nrc-exporter

If everything goes well, you should be able to run this command:

$ nrc-exporter --help

  _   _ ____   ____                              _
 | \ | |  _ \ / ___|   _____  ___ __   ___  _ __| |_ ___ _ __
 |  \| | |_) | |      / _ \ \/ / '_ \ / _ \| '__| __/ _ \ '__|
 | |\  |  _ <| |___  |  __/>  <| |_) | (_) | |  | ||  __/ |
 |_| \_|_| \_\____|  \___/_/\_\ .__/ \___/|_|   \__\___|_|
                               |_|

                                            ~ Yasoob Khalid
                                              https://yasoob.me


usage: nrc-exporter [-h] [-e EMAIL] [-p PASSWORD] [-v] [-t TOKEN] [-i INPUT]

Login to Nike Run Club and download activity data in GPX format

optional arguments:
  -h, --help            show this help message and exit
  -e EMAIL, --email EMAIL
                        your nrc email
  -p PASSWORD, --password PASSWORD
                        your nrc password
  -v, --verbose         print verbose output
  -t TOKEN, --token TOKEN
                        your nrc token
  -i INPUT [INPUT ...], --input INPUT [INPUT ...]
                        A directory or directories containing NRC activities
                        in JSON format.You can also provide individual NRC
                        JSON files

From Source

Just clone the repo, install the dependencies and run it.

  • Clone it:
$ git clone [email protected]:yasoob/nrc-exporter.git
  • Install dependencies:
$ cd nrc-exporter
$ pip install -r requirements.txt
  • Add Geckodriver in path

The automated access token extraction makes use of selenium and geckodriver. I used geckodriver instead of Chrome because Chrome (selenium) was being blocked by Nike (Akamai Bot Manager) but geckodriver was not. This is an optional step. If you want to try automated extraction make sure you have downloaded the geckodriver from here and the binary is in your PATH.

  • Run it:
python nrc_exporter.py --help

If everything goes well you will see the following text:

  _   _ ____   ____                              _
 | \ | |  _ \ / ___|   _____  ___ __   ___  _ __| |_ ___ _ __
 |  \| | |_) | |      / _ \ \/ / '_ \ / _ \| '__| __/ _ \ '__|
 | |\  |  _ <| |___  |  __/>  <| |_) | (_) | |  | ||  __/ |
 |_| \_|_| \_\____|  \___/_/\_\ .__/ \___/|_|   \__\___|_|
                               |_|

                                            ~ Yasoob Khalid
                                              https://yasoob.me


usage: __main__.py [-h] [-e EMAIL] [-p PASSWORD] [-v] [-t TOKEN] [-i INPUT]

Login to Nike Run Club and download activity data in GPX format

optional arguments:
  -h, --help            show this help message and exit
  -e EMAIL, --email EMAIL
                        your nrc email
  -p PASSWORD, --password PASSWORD
                        your nrc password
  -v, --verbose         print verbose output
  -t TOKEN, --token TOKEN
                        your nrc token
  -i INPUT, --input INPUT
                        A directory containing NRC activities in JSON format

🚀 Usage

You have multiple ways to run this application. You can either provide an email password combination, access tokens for Nike or a directory containing NRC activities in JSON format.

  • Email/Password

This is probably the easiest way to run the application. The program will try to automatically extract the access_tokens for NRC by logging you in using Selenium and intercepting the requests. You will have to run nrc_exporter like this:

$ nrc-exporter -e [email protected] -p sample_password

This method will probably be blocked by Nike in the near future. If it doesn't work use the access tokens method described below.

  • Access Tokens

This is useful for when the program is unable to extract the tokens automatically. You will have to manually provide the access tokens to the program. If you don't know where to get the access tokens from, just run the program without any arguments and it should automatically open the URL where you can log in. For extracting the tokens from that page check out these instructions. Once you have the tokens, you can run nrc_extractor like this:

$ nrc-exporter -t <access_token>
  • Activities folder

Some of you might have already downloaded your NRC runs data using this script and are now wondering how to convert that JSON data to GPX data. Put all of those activity JSON files in a folder and pass that folder's name to nrc_extractor. Let's suppose you put all of those files in the activities folder. It should look something like this:

$ tree activities
activities
├── 0019f189-d32f-437f-a4d4-ef4f15304324.json
├── 0069911c-2cc8-489b-8335-8e613a81124s.json
├── 01a09869-0a95-49f2-bd84-75065b701c33.json
└── 07e1fa42-a9a9-4626-bbef-60269dc4a111.json

Now you can run nrc_extractor like this:

$ nrc-exporter -i activities
or 
$ nrc-exporter -i 07e1fa42-a9a9-4626-bbef-60269dc4a111.json 01a09869-0a95-49f2-bd84-75065b701c33.json

💲 Extracting access tokens

Nike uses Akamai Bot Manager which doesn't allow scripts to automatically log users in and extract the access tokens. Sometimes you might be lucky and automated token extraction works but mostly you will find the automated token extraction to be broken. Luckily, manually extracting the access token isn't too hard.

Just open up your favorite browser, open developer tools, and head over to this login url and log in.

Submitting the form will not do much. You will just have a blank page in front of you but you will be logged in. Now in order to extract the access tokens, open up developer tools. You can search online about how to open the developer tools for your specific browser. Once the developer tools are open, click on the Console and type this:

JSON.parse(window.localStorage.getItem('com.nike.commerce.nikedotcom.web.credential')).access_token

This should print your access tokens on screen. If this doesn't work and/or gives you errors, just click on storage and check out local storage. You should be able to access_tokens as part of the value for a particular key. It should look something like this:

Extract key

If the local storage doesn't contain any access tokens, then go to the "network" tab in the developer tools. A couple of requests should be visible there assuming you logged in after opening the developer tools:

image

Click on the /login request and check the response. It will contain the required access_token:

image

Now copy these access_tokens and provide them to the program.

❗ Limitations

This was a weekend project so there are definitely a lot of rough edges to this script. Try it at your own risk. I have extracted my runs successfully with this program so I am hopeful that it will work for you too. In case it fails please open up an issue and I will take a look.

For now, one major isssue is that the script does not correctly add elevation data to the GPX file. NRC provides us with the ascent and descent data of different runs but I am not sure of the math that is required to convert that into actual elevation data. This data wasn't particularly important for me to maintain for historic runs so I did not spend a lot of time on it. You are more than welcome to open up a PR if you know how to do it.

📷 Screenshots

Who doesn't love screenshots?

  • Initial run

help message

📡 Release

This is for my own documentation. There are three steps involved with releasing a new version to PyPI after updating the code.

  • Increment the version number in setup.py
  • Build the distribution package
python setup.py sdist bdist_wheel
  • Upload to PyPI:
python -m twine upload --skip-existing --repository pypi dist/*

📜 License

This program is distributed under the MIT license. You are more than welcome to take a look, modify and redistribute it (even for commercial purposes). Just make sure that the LICENSE file stays intact and you redistribute it under the same license.

MIT License

Copyright (c) 2020 M.Yasoob Ullah Khalid ☺

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

More Repositories

1

intermediatePython

Python
3,843
star
2

youtube-dl-GUI

This repository contains code for a youtube-dl GUI written in PyQt.
Python
200
star
3

Baseline-JPEG-Decoder

Python
101
star
4

practical-python-projects

Jupyter Notebook
99
star
5

fb-messenger-bot

A Facebook + Reddit bot
Python
60
star
6

torrents-crawler

This is a scrapy project in which I have implemented several crawlers for different torrent and direct link websites.
Python
57
star
7

soundcloud-dl

A well documented soundcloud searcher and downloader made in python
Python
32
star
8

learn-git

Learn git with Yasoob
HTML
24
star
9

listmonk-setup

HTML
23
star
10

personal_blog

HTML
20
star
11

watchcartoononline-dl

It is a cartoon downloader made in python. Just run this script and type in the url of the cartoons which you want to download from http://www.watchcartoononline.com/
Python
20
star
12

sqlalchemy-strawberry-fastapi-nextjs

Python
16
star
13

Flask-React-JWT

A tutorial on how to setup a JWT auth app using React and Flask and then deploy it using NGINX and Gunicorn.
16
star
14

github-action-scraper-tutorial

Python
15
star
15

logit-bin

A simple pastebin in Flask. Implements basic Authentication and uses WTForms and Flask-Sqlalchemy.
Python
14
star
16

ex.fm-dl

It is a ex.fm music searcher and downloader made in python by M.Yasoob [email protected]
Python
12
star
17

PythonTips

This repo contains all the tutorials published on http://www.freepythontips.wordpress.com/
12
star
18

Reddit-Twitter-bot

This bot copies posts from /r/Python from Reddit and posts them to Twitter while keeping every safety measure in check.
Python
9
star
19

python-tips

HTML
6
star
20

dailymotion-dl

Python
4
star
21

crash_course

Jupyter Notebook
4
star
22

nwba-booking-bot

Python
3
star
23

IRC-logger

This is a simple python application that will log IRC channels.
Python
3
star
24

gotrans

This is a simple text translator made in python. The GUI is made with wxPython
Python
3
star
25

FIFA-twilio-bot

Python Flask based bot to stay updated with FIFA 2018 world cup
Python
2
star
26

flask-login

A sample application showing how to deal with login and signup in flask
Python
2
star
27

email_django

JavaScript
2
star
28

blog

contains all of my blog files
JavaScript
2
star
29

acmun

JavaScript
2
star
30

redtube-dl

redtube-dl
Python
2
star
31

PythonDataScience

A list of resources for learning Data Science using Python
2
star
32

remix-fly-test

TypeScript
1
star
33

Vbox7-dl

A downloader for Vbox7 (a very popular bulgarian video sharing website) . All the code is written in python and should support python 2.6 upto 3.3 . I hope you guys like it. Dont forget to star this project.
Python
1
star
34

yasoob

1
star
35

codebolt

Makefile
1
star
36

Express_Mongodb

CSS
1
star
37

rabia

Rabia's portfolio website
HTML
1
star
38

github_oauth

JavaScript
1
star
39

dramacrazy

A downloader for dramacrazy. It is a Korean drama streaming website.
Python
1
star
40

remix-render-test

TypeScript
1
star
41

hygraph-tutorial

TypeScript
1
star
42

remix-render-test2

TypeScript
1
star
43

gci

HTML
1
star
44

json_python

Python
1
star
45

pyemailer

A very basic emailer i wrote in python. Just type in your email password and message and this script will send the email. It is mainly for bulk email sending. Suppose you have a list of emails in a txt file you can use this script to send the same email to everyone.
Python
1
star