Skip to content

Commit

Permalink
feat: fix garmin down (#505)
Browse files Browse the repository at this point in the history
  • Loading branch information
yihong0618 authored Sep 26, 2023
1 parent 38e044c commit 6c9d49b
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 155 deletions.
21 changes: 11 additions & 10 deletions .github/workflows/run_data_sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ env:
IGNORE_POLYLINE: 'ktjrFoemeU~IorGq}DeB'
IGNORE_RANGE: 10 # Unit meter
SAVE_DATA_IN_GITHUB_CACHE: false # if you deploy in the vercal, check the README
DATA_CACHE_PREFIX: "track_data"
DATA_CACHE_PREFIX: 'track_data'
BUILD_GH_PAGES: true # If you do not need GitHub Page please set it to `false`

jobs:
Expand All @@ -55,7 +55,7 @@ jobs:
id: setup_python
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: '3.10'
cache: pip
cache-dependency-path: 'requirements.txt'

Expand Down Expand Up @@ -102,7 +102,6 @@ jobs:
run: |
python run_page/strava_sync.py ${{ secrets.STRAVA_CLIENT_ID }} ${{ secrets.STRAVA_CLIENT_SECRET }} ${{ secrets.STRAVA_CLIENT_REFRESH_TOKEN }}
# If you only want to sync `type running` add args --only-run, default script is to sync all data (rides and runs).
# python run_page/garmin_sync.py ${{ secrets.GARMIN_EMAIL }} ${{ secrets.GARMIN_PASSWORD }} --only-run --is-cn

- name: Run sync Codoon script
if: env.RUN_TYPE == 'codoon'
Expand All @@ -113,16 +112,18 @@ jobs:
- name: Run sync Garmin script
if: env.RUN_TYPE == 'garmin'
run: |
python run_page/garmin_sync.py ${{ secrets.GARMIN_EMAIL }} ${{ secrets.GARMIN_PASSWORD }}
# make garimin secret string `python run_page/get_garmin_secret.py ${email} ${password}
python run_page/garmin_sync.py ${{ secrets.GARMIN_SECRET_STRING }}
# If you only want to sync `type running` add args --only-run, default script is to sync all data (rides and runs).
# python run_page/garmin_sync.py ${{ secrets.GARMIN_EMAIL }} ${{ secrets.GARMIN_PASSWORD }} --only-run
# python run_page/garmin_sync.py ${{ secrets.GARMIN_SECRET_STRING }} --only-run

- name: Run sync Garmin CN script
if: env.RUN_TYPE == 'garmin_cn'
run: |
python run_page/garmin_sync.py ${{ secrets.GARMIN_CN_EMAIL }} ${{ secrets.GARMIN_CN_PASSWORD }} --is-cn
# make garimin secret string `python run_page/get_garmin_secret.py ${email} ${password} --is-cn
python run_page/garmin_sync.py ${{ secrets.GARMIN_SECRET_STRING_CN }} --is-cn
# If you only want to sync `type running` add args --only-run, default script is to sync all data (rides and runs).
# python run_page/garmin_sync.py ${{ secrets.GARMIN_EMAIL }} ${{ secrets.GARMIN_PASSWORD }} --only-run --is-cn
# python run_page/garmin_sync.py ${{ secrets.GARMIN_SECRET_STING_CN }} --only-run --is-cn

- name: Run sync Only GPX script
if: env.RUN_TYPE == 'only_gpx'
Expand All @@ -142,17 +143,17 @@ jobs:
- name: Run sync Strava to Garmin(Run with strava(or others upload to strava) data backup in Garmin)
if: env.RUN_TYPE == 'strava_to_garmin'
run: |
python run_page/strava_to_garmin_sync.py ${{ secrets.STRAVA_CLIENT_ID }} ${{ secrets.STRAVA_CLIENT_SECRET }} ${{ secrets.STRAVA_CLIENT_REFRESH_TOKEN }} ${{ secrets.GARMIN_EMAIL }} ${{ secrets.GARMIN_PASSWORD }} ${{ secrets.STRAVA_EMAIL }} ${{ secrets.STRAVA_PASSWORD }}
python run_page/strava_to_garmin_sync.py ${{ secrets.STRAVA_CLIENT_ID }} ${{ secrets.STRAVA_CLIENT_SECRET }} ${{ secrets.STRAVA_CLIENT_REFRESH_TOKEN }} ${{ secrets.GARMIN_SECRET_STRING }} ${{ secrets.STRAVA_EMAIL }} ${{ secrets.STRAVA_PASSWORD }}
- name: Run sync Strava to Garmin-cn(Run with strava(or others upload to strava) data backup in Garmin-cn)
if: env.RUN_TYPE == 'strava_to_garmin_cn'
run: |
python run_page/strava_to_garmin_sync.py ${{ secrets.STRAVA_CLIENT_ID }} ${{ secrets.STRAVA_CLIENT_SECRET }} ${{ secrets.STRAVA_CLIENT_REFRESH_TOKEN }} ${{ secrets.GARMIN_CN_EMAIL }} ${{ secrets.GARMIN_CN_PASSWORD }} ${{ secrets.STRAVA_EMAIL }} ${{ secrets.STRAVA_PASSWORD }} --is-cn
python run_page/strava_to_garmin_sync.py ${{ secrets.STRAVA_CLIENT_ID }} ${{ secrets.STRAVA_CLIENT_SECRET }} ${{ secrets.STRAVA_CLIENT_REFRESH_TOKEN }} ${{ secrets.GARMIN_SECRET_STRING_CN }} ${{ secrets.STRAVA_EMAIL }} ${{ secrets.STRAVA_PASSWORD }} --is-cn
- name: Run sync Garmin-cn to Strava(Run with Garmin data backup in Strava)
if: env.RUN_TYPE == 'garmin_to_strava_cn'
run: |
python run_page/garmin_to_strava_sync.py ${{ secrets.STRAVA_CLIENT_ID }} ${{ secrets.STRAVA_CLIENT_SECRET }} ${{ secrets.STRAVA_CLIENT_REFRESH_TOKEN }} ${{ secrets.GARMIN_CN_EMAIL }} ${{ secrets.GARMIN_CN_PASSWORD }} --is-cn
python run_page/garmin_to_strava_sync.py ${{ secrets.STRAVA_CLIENT_ID }} ${{ secrets.STRAVA_CLIENT_SECRET }} ${{ secrets.STRAVA_CLIENT_REFRESH_TOKEN }} ${{ secrets.GARMIN_SECRET_STRING_CN }} --is-cn
- name: Run sync Garmin to Strava(Run with Garmin data backup in Strava)
if: env.RUN_TYPE == 'garmin_to_strava'
Expand Down
30 changes: 19 additions & 11 deletions README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

## note3: use v2.0 need change vercel setting from gatsby to vite

## note4: 2023.09.26 garmin need secret_string(and in Actions) get `python run_page/garmin_sync.py ${email} ${password}` if cn `python run_page/garmin_sync.py ${email} ${password} --is-cn`

![running_page](https://socialify.git.ci/yihong0618/running_page/image?description=1&font=Inter&forks=1&issues=1&language=1&logo=https%3A%2F%2Fraw.githubusercontent.com%2Fshaonianche%2Fgallery%2Fmaster%2Frunning_page%2Frunning_page_logo_150*150.jpg&owner=1&pulls=1&stargazers=1&theme=Light)

# [这里是白银越野赛全部 21 位逝者的故事](https://github.com/yihong0618/running_page/issues/135)
Expand Down Expand Up @@ -155,9 +157,9 @@ pnpm develop
# NRC
docker build -t running_page:latest . --build-arg app=NRC --build-arg nike_refresh_token=""
# Garmin
docker build -t running_page:latest . --build-arg app=Garmin --build-arg email="" --build-arg password=""
docker build -t running_page:latest . --build-arg app=Garmin --build-arg secret_string=""
# Garmin-CN
docker build -t running_page:latest . --build-arg app=Garmin-CN --build-arg email="" --build-arg password=""
docker build -t running_page:latest . --build-arg app=Garmin-CN --build-arg secret_string=""
# Strava
docker build -t running_page:latest . --build-arg app=Strava --build-arg client_id="" --build-arg client_secret="" --build-arg refresh_token=""
#Nike_to_Strava
Expand Down Expand Up @@ -460,13 +462,16 @@ python3(python) run_page/tulipsport_sync.py nLgy****RyahI
如果你想同步 `fit` 格式,增加命令 --fit

```python
python3(python) run_page/garmin_sync.py ${your email} ${your password}
# to get secret_string
python3(python) run_page/get_garmin_secret.py ${your email} ${your password}
# use this secret_string
python3(python) run_page/garmin_sync.py ${secret_string}
```

示例:

```python
python3(python) run_page/garmin_sync.py example@gmail.com example
python3(python) run_page/garmin_sync.py xxxxxxxxxxx
```

</details>
Expand All @@ -483,19 +488,22 @@ python3(python) run_page/garmin_sync.py example@gmail.com example
如果你想同步 `fit` 格式,增加命令 --fit

```python
python3(python) run_page/garmin_sync.py ${your email} ${your password} --is-cn
# to get secret_string
python3(python) run_page/get_garmin_secret.py ${your email} ${your password} --is-cn
# use this secret_string
python3(python) run_page/garmin_sync.py ${secret_string}
```

示例:

```python
python3(python) run_page/garmin_sync.py example@gmail.com example --is-cn
python3(python) run_page/garmin_sync.py xxxxxxxxx --is-cn
```

仅同步跑步数据:

```python
python3(python) run_page/garmin_sync.py example@gmail.com example --is-cn --only-run
python3(python) run_page/garmin_sync.py xxxxxxxxxx --is-cn --only-run
```

</details>
Expand Down Expand Up @@ -691,7 +699,7 @@ python3(python) run_page/nike_to_strava_sync.py eyJhbGciThiMTItNGIw****** xxx x
2. 在项目根目录下执行:

```python
python3(python) run_page/garmin_to_strava_sync.py ${client_id} ${client_secret} ${strava_refresh_token} ${garmin_email} ${garmin_password} --is-cn
python3(python) run_page/garmin_to_strava_sync.py ${client_id} ${client_secret} ${strava_refresh_token} ${garmin_secret_string} --is-cn
```

示例:
Expand All @@ -713,13 +721,13 @@ python3(python) run_page/garmin_to_strava_sync.py xxx xxx xxx xx xxx
2. 在项目根目录下执行:

```python
python3(python) run_page/strava_to_garmin_sync.py ${{ secrets.STRAVA_CLIENT_ID }} ${{ secrets.STRAVA_CLIENT_SECRET }} ${{ secrets.STRAVA_CLIENT_REFRESH_TOKEN }} ${{ secrets.GARMIN_EMAIL }} ${{ secrets.GARMIN_PASSWORD }} ${{ secrets.STRAVA_EMAIL }} ${{ secrets.STRAVA_PASSWORD }}
python3(python) run_page/strava_to_garmin_sync.py ${{ secrets.STRAVA_CLIENT_ID }} ${{ secrets.STRAVA_CLIENT_SECRET }} ${{ secrets.STRAVA_CLIENT_REFRESH_TOKEN }} ${{ secrets.GARMIN_SECRET_STRING }} ${{ secrets.STRAVA_EMAIL }} ${{ secrets.STRAVA_PASSWORD }}
```

如果你的佳明账号是中国区,执行如下的命令:

```python
python3(python) run_page/strava_to_garmin_sync.py ${{ secrets.STRAVA_CLIENT_ID }} ${{ secrets.STRAVA_CLIENT_SECRET }} ${{ secrets.STRAVA_CLIENT_REFRESH_TOKEN }} ${{ secrets.GARMIN_CN_EMAIL }} ${{ secrets.GARMIN_CN_PASSWORD }} ${{ secrets.STRAVA_EMAIL }} ${{ secrets.STRAVA_PASSWORD }} --is-cn
python3(python) run_page/strava_to_garmin_sync.py ${{ secrets.STRAVA_CLIENT_ID }} ${{ secrets.STRAVA_CLIENT_SECRET }} ${{ secrets.STRAVA_CLIENT_REFRESH_TOKEN }} ${{ secrets.GARMIN_SECRET_STRING_CN }} ${{ secrets.STRAVA_EMAIL }} ${{ secrets.STRAVA_PASSWORD }} --is-cn
```

如果要在同步到 Garmin 的运动记录中添加 Garmin 设备信息,需要添加`--use_fake_garmin_device`参数,这将在同步的 Garmin 锻炼记录中添加一个 Garmin 设备(默认情况下为 `Garmin Forerunner 245`,您可以在`garmin_device_adaptor.py`中更改设备信息),运动记录中有了设备信息之后就可以同步到其他 APP 中,比如数字心动(攒上马积分)这类不能通过 Apple Watch 同步的 APP,当然也可以同步到 Keep,悦跑圈,咕咚等 APP。
Expand All @@ -729,7 +737,7 @@ python3(python) run_page/strava_to_garmin_sync.py ${{ secrets.STRAVA_CLIENT_ID }
最终执行的命令如下:

```python
python3(python) run_page/strava_to_garmin_sync.py ${{ secrets.STRAVA_CLIENT_ID }} ${{ secrets.STRAVA_CLIENT_SECRET }} ${{ secrets.STRAVA_CLIENT_REFRESH_TOKEN }} ${{ secrets.GARMIN_CN_EMAIL }} ${{ secrets.GARMIN_CN_PASSWORD }} ${{ secrets.STRAVA_EMAIL }} ${{ secrets.STRAVA_PASSWORD }} --use_fake_garmin_device
python3(python) run_page/strava_to_garmin_sync.py ${{ secrets.STRAVA_CLIENT_ID }} ${{ secrets.STRAVA_CLIENT_SECRET }} ${{ secrets.STRAVA_CLIENT_REFRESH_TOKEN }} ${{ secrets.GARMIN_SECRET_STRING_CN }} ${{ secrets.STRAVA_EMAIL }} ${{ secrets.STRAVA_PASSWORD }} --use_fake_garmin_device
```

注意:**首次初始化的时候,如果你有大量的 strava 跑步数据,可能有些数据会上传失败,只需要多重试几次即可。**
Expand Down
32 changes: 20 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

## note3: use v2.0 need change vercel setting from gatsby to vite.

## note4: 2023.09.26 garmin need secret_string(and in Actions) get `python run_page/garmin_sync.py ${email} ${password}` if cn `python run_page/garmin_sync.py ${email} ${password} --is-cn`

<p align="center">
<img width="150" src="https://raw.githubusercontent.com/shaonianche/gallery/master/running_page/running_page_logo.png" />
</p>
Expand Down Expand Up @@ -138,9 +140,9 @@ Open your browser and visit <http://localhost:5173/>
# NRC
docker build -t running_page:latest . --build-arg app=NRC --build-arg nike_refresh_token=""
# Garmin
docker build -t running_page:latest . --build-arg app=Garmin --build-arg email="" --build-arg password=""
docker build -t running_page:latest . --build-arg app=Garmin --build-arg secret_string=""
# Garmin-CN
docker build -t running_page:latest . --build-arg app=Garmin-CN --build-arg email="" --build-arg password=""
docker build -t running_page:latest . --build-arg app=Garmin-CN --build-arg secret_string=""
# Strava
docker build -t running_page:latest . --build-arg app=Strava --build-arg client_id="" --build-arg client_secret="" --build-arg refresh_token=""
#Nike_to_Strava
Expand Down Expand Up @@ -270,19 +272,22 @@ If you only want `tcx` files add args --tcx
If you only want `fit` files add args --fit

```python
python3(python) run_page/garmin_sync.py ${your email} ${your password}
# to get secret_string
python3(python) run_page/get_garmin_secret.py ${your email} ${your password}
# use this secret_string
python3(python) run_page/garmin_sync.py ${secret_string}
```

example:

```python
python3(python) run_page/garmin_sync.py example@gmail.com example
python3(python) run_page/get_garmin_secret.py xxxxxxxxxxx
```

only-run:

```python
python3(python) run_page/garmin_sync.py example@gmail.com example --only-run
python3(python) run_page/garmin_sync.py xxxxxxxxxxxxxx(secret_string) --only-run
```

</details>
Expand All @@ -299,13 +304,16 @@ If you only want `tcx` files add args --tcx
If you only want `fit` files add args --fit

```python
python3(python) run_page/garmin_sync.py ${your email} ${your password} --is-cn
# to get secret_string
python3(python) run_page/get_garmin_secret.py ${your email} ${your password} --is-cn
# use this secret_string
python3(python) run_page/garmin_sync.py ${secret_string}
```

example:

```python
python3(python) run_page/garmin_sync.py example@gmail.com example --is-cn
python3(python) run_page/garmin_sync.py xxxxxxxxx(secret_string)--is-cn
```

</details>
Expand Down Expand Up @@ -517,13 +525,13 @@ python3(python) run_page/nike_to_strava_sync.py eyJhbGciThiMTItNGIw****** xxx x
2. Execute in the root directory:

```python
python3(python) run_page/garmin_to_strava_sync.py ${client_id} ${client_secret} ${strava_refresh_token} ${garmin_email} ${garmin_password} --is-cn
python3(python) run_page/garmin_to_strava_sync.py ${client_id} ${client_secret} ${strava_refresh_token} ${garmin_secret_string} --is-cn
```

e.g.

```python
python3(python) run_page/garmin_to_strava_sync.py xxx xxx xxx xx xxx
python3(python) run_page/garmin_to_strava_sync.py xxx xxx xxx xx
```

</details>
Expand All @@ -539,13 +547,13 @@ python3(python) run_page/garmin_to_strava_sync.py xxx xxx xxx xx xxx
2. Execute in the root directory:

```python
python3(python) run_page/strava_to_garmin_sync.py ${{ secrets.STRAVA_CLIENT_ID }} ${{ secrets.STRAVA_CLIENT_SECRET }} ${{ secrets.STRAVA_CLIENT_REFRESH_TOKEN }} ${{ secrets.GARMIN_EMAIL }} ${{ secrets.GARMIN_PASSWORD }} ${{ secrets.STRAVA_EMAIL }} ${{ secrets.STRAVA_PASSWORD }}
python3(python) run_page/strava_to_garmin_sync.py ${{ secrets.STRAVA_CLIENT_ID }} ${{ secrets.STRAVA_CLIENT_SECRET }} ${{ secrets.STRAVA_CLIENT_REFRESH_TOKEN }} ${{ secrets.GARMIN_SECRET_STRING }} ${{ secrets.STRAVA_EMAIL }} ${{ secrets.STRAVA_PASSWORD }}
```

if your garmin account region is **China**, you need to execute the command:

```python
python3(python) run_page/strava_to_garmin_sync.py ${{ secrets.STRAVA_CLIENT_ID }} ${{ secrets.STRAVA_CLIENT_SECRET }} ${{ secrets.STRAVA_CLIENT_REFRESH_TOKEN }} ${{ secrets.GARMIN_CN_EMAIL }} ${{ secrets.GARMIN_CN_PASSWORD }} ${{ secrets.STRAVA_EMAIL }} ${{ secrets.STRAVA_PASSWORD }} --is-cn
python3(python) run_page/strava_to_garmin_sync.py ${{ secrets.STRAVA_CLIENT_ID }} ${{ secrets.STRAVA_CLIENT_SECRET }} ${{ secrets.STRAVA_CLIENT_REFRESH_TOKEN }} ${{ secrets.GARMIN_SECRET_STRING_CN }} ${{ secrets.STRAVA_EMAIL }} ${{ secrets.STRAVA_PASSWORD }} --is-cn
```

If you want to add Garmin Device during sync, you should add `--use_fake_garmin_device` argument, this will add a Garmin Device (Garmin Forerunner 245 by default, and you can change device in `garmin_device_adaptor.py`) in synced Garmin workout record, this is essential when you want to sync the workout record to other APP like Keep, JoyRun etc.
Expand All @@ -555,7 +563,7 @@ If you want to add Garmin Device during sync, you should add `--use_fake_garmin_
the final command will be:

```python
python3(python) run_page/strava_to_garmin_sync.py ${{ secrets.STRAVA_CLIENT_ID }} ${{ secrets.STRAVA_CLIENT_SECRET }} ${{ secrets.STRAVA_CLIENT_REFRESH_TOKEN }} ${{ secrets.GARMIN_CN_EMAIL }} ${{ secrets.GARMIN_CN_PASSWORD }} ${{ secrets.STRAVA_EMAIL }} ${{ secrets.STRAVA_PASSWORD }} --use_fake_garmin_device
python3(python) run_page/strava_to_garmin_sync.py ${{ secrets.STRAVA_CLIENT_ID }} ${{ secrets.STRAVA_CLIENT_SECRET }} ${{ secrets.STRAVA_CLIENT_REFRESH_TOKEN }} ${{ secrets.GARMIN_SECRET_STRING_CN }} ${{ secrets.STRAVA_EMAIL }} ${{ secrets.STRAVA_PASSWORD }} --use_fake_garmin_device
```

ps: **when initializing for the first time, if you have a large amount of strava data, some data may fail to upload, just retry several times.**
Expand Down
Loading

1 comment on commit 6c9d49b

@vercel
Copy link

@vercel vercel bot commented on 6c9d49b Sep 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

running-page – ./

running-page-git-master-yihong0618.vercel.app
running-page.vercel.app
running-page-yihong0618.vercel.app

Please sign in to comment.