note2: 2023.09.26 garmin need secret_string(and in Actions) get python run_page/garmin_sync.py ${secret_string} if cn python run_page/garmin_sync.py ${secret_string} --is-cn
- For old data: To include
Elevation Gainfor past activities, perform a full reimport.
简体中文 | English
This project is based on running_page and adds support for multi sports types. Follow the steps in the origin repo to deploy.
- support multi sports types, like Ride/Hike/Swim/Rowing
- support new apps
- Codoon(咕咚) (Couldn't automate for its limitation from the server side)
- Xingzhe(行者)
- Google Health
- support RoadTrip(GoogleMaps), show Road Trip on maps
- Modify Ride Color:
RIDE_COLORinsrc/utils/const.js
- Modify
TYPE_DICT&MAPPING_TYPEinscripts/config.py - Add Type Name and add it into
RUN_TITLESinsrc/utils/const.js - Modify
colorFromType&titleForRuninsrc/utils/util.js - see commit
- or comment here
Get your Codoon data
python3(python) scripts/codoon_sync.py ${your mobile or email} ${your password}example:
python3(python) scripts/codoon_sync.py 13333xxxx xxxxuse
--with-gpxflag to save your gpx datause
--from-auth-tokenflag to login by refresh_token&user_id
example:
python3(python) scripts/codoon_sync.py 54bxxxxxxx fefxxxxx-xxxx-xxxx --from-auth-tokenGet your Xingzhe data
python3(python) scripts/xingzhe_sync.py ${your mobile or email} ${your password}example:
python3(python) scripts/xingzhe_sync.py 13333xxxx xxxxuse
--with-gpxflag to save your gpx datause
--from-auth-tokenflag to login by refresh_token&user_id
example:
python3(python) scripts/xingzhe_sync.py w0xxx 185000 --from-auth-tokenGet your Google Health data
Google Health API is the v4 Google API that replaces the legacy Fitbit Web API. This sync downloads exercise records from https://health.googleapis.com/v4/users/me/dataTypes/exercise/dataPoints, exports each exercise as TCX with :exportExerciseTcx?alt=media, saves the files to TCX_OUT by default, then imports them into data.db and activities.json. If you choose GPX output, the script converts the v4 TCX export locally and saves files to GPX_OUT.
-
Create a Google Cloud project, enable Google Health API, and create an OAuth 2.0 Web client. Add your account as a test user while the app is in Testing mode.
- Go to the Google Cloud Console and create a new project (or select an existing one).
- Enable the Google Health API:
- Navigate to APIs & Services → Library
- Search for Google Health API and click Enable
- Create OAuth 2.0 credentials:
- Go to APIs & Services → Credentials → Create Credentials → OAuth client ID
- Choose Desktop app as the application type
- Download the JSON credentials file or note your Client ID and Client Secret
- Configure the OAuth consent screen (APIs & Services → OAuth consent screen):
- Set the user type to External
- Add yourself as a Test user
- Add both scopes (required for all formats):
https://www.googleapis.com/auth/googlehealth.activity_and_fitness.readonlyhttps://www.googleapis.com/auth/googlehealth.location.readonly
-
Open the authorization URL below after replacing
${client_id}. The redirect URI must match the one configured in Google Cloud.https://accounts.google.com/o/oauth2/v2/auth?client_id=${client_id}&redirect_uri=http://localhost&response_type=code&access_type=offline&scope=https://www.googleapis.com/auth/googlehealth.activity_and_fitness.readonly%20https://www.googleapis.com/auth/googlehealth.location.readonly&prompt=consent -
Copy the returned
codeand exchange it for arefresh_token:curl -L -X POST 'https://oauth2.googleapis.com/token' \ -H 'Content-Type: application/x-www-form-urlencoded' \ -d 'client_id=${client_id}&client_secret=${client_secret}&code=${code}&redirect_uri=http://localhost&grant_type=authorization_code'
-
Sync Google Health data:
python run_page/google_health_sync.py ${client_id} ${client_secret} ${refresh_token}
If you only want running exercises:
python run_page/google_health_sync.py ${client_id} ${client_secret} ${refresh_token} --only-run
Optional filters:
--start-date YYYY-MM-DDsyncs exercises starting from that civil date. If omitted, the script uses the lateststart_date_localindata.dbas the Google Healthexercise.interval.civil_start_timelower bound.--end-date YYYY-MM-DDsyncs exercises before that civil date.--allignores the local database date and asks Google Health for all exercises.--format gpxexports GPX files toGPX_OUT; the default is--format tcx.
Example for GPX:
python run_page/google_health_sync.py ${client_id} ${client_secret} ${refresh_token} --format gpx
-
For GitHub Actions, add
GOOGLE_HEALTH_CLIENT_ID,GOOGLE_HEALTH_CLIENT_SECRET, andGOOGLE_HEALTH_REFRESH_TOKENto GitHub Secrets, then setRUN_TYPEtogoogle_health. -
Configure the OAuth consent screen (APIs & Services → OAuth consent screen):
- Set the user type to Internal; otherwise, you need to publish the app.
Import KML from Google Maps
- Create a map in Google Maps (keep the route in one Layer)
- Export Layer to KML file
- Rename the file to
import.kmland place it intoscripts - Modify
scripts/kml2polyline.py, fill in the trip info
# TODO modify here
# trip name
track.name = "2020-10 Tibet Road Trip"
# start/end time Year-Month-Day-Hour-Minute
track.start_time = datetime(2020, 9, 29, 10, 0)
track.end_time = datetime(2020, 10, 10, 18, 0)
# total distance
distance = 4000 # KM
# total days
days = 12
# average daily distance
hours_per_day = 6
- Execute in Console
python3(python) scripts\kml2polyline.py- @yihong0618 for Awesome running_page, Great Thanks


