Skip to content

Commit

Permalink
#484 导出keep接口升级无法获取gpx数据的跑步记录 (#496)
Browse files Browse the repository at this point in the history
* fix: keep interface upgraded, retrieved gpx data maybe failed

* fix: lint

* style: reformat code

---------

Co-authored-by: F4ria <fariacool@gmail.com>
  • Loading branch information
F4ria and F4ria committed Sep 23, 2023
1 parent 84ffd06 commit 0ea2f4a
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions run_page/keep_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,23 +85,28 @@ def parse_raw_data_to_nametuple(
):
raw_data_url = run_data.get("rawDataURL")
r = session.get(raw_data_url)
# string strart with `H4sIAAAAAAAA` --> decode and unzip
run_points_data = decode_runmap_data(r.text)
run_points_data_gpx = run_points_data
if TRANS_GCJ02_TO_WGS84:
run_points_data = [
list(eviltransform.gcj2wgs(p["latitude"], p["longitude"]))
for p in run_points_data
]
for i, p in enumerate(run_points_data_gpx):
p["latitude"] = run_points_data[i][0]
p["longitude"] = run_points_data[i][1]
if r.ok:
# string strart with `H4sIAAAAAAAA` --> decode and unzip
run_points_data = decode_runmap_data(r.text)
run_points_data_gpx = run_points_data
if TRANS_GCJ02_TO_WGS84:
run_points_data = [
list(eviltransform.gcj2wgs(p["latitude"], p["longitude"]))
for p in run_points_data
]
for i, p in enumerate(run_points_data_gpx):
p["latitude"] = run_points_data[i][0]
p["longitude"] = run_points_data[i][1]
else:
run_points_data = [
[p["latitude"], p["longitude"]] for p in run_points_data
]
if with_download_gpx:
if str(keep_id) not in old_gpx_ids:
gpx_data = parse_points_to_gpx(run_points_data_gpx, start_time)
download_keep_gpx(gpx_data, str(keep_id))
else:
run_points_data = [[p["latitude"], p["longitude"]] for p in run_points_data]
if with_download_gpx:
if str(keep_id) not in old_gpx_ids:
gpx_data = parse_points_to_gpx(run_points_data_gpx, start_time)
download_keep_gpx(gpx_data, str(keep_id))
print(f"ID {keep_id} retrieved gpx data failed")
heart_rate = None
if run_data["heartRate"]:
heart_rate = run_data["heartRate"].get("averageHeartRate", None)
Expand Down

1 comment on commit 0ea2f4a

@vercel
Copy link

@vercel vercel bot commented on 0ea2f4a Sep 23, 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.vercel.app
running-page-yihong0618.vercel.app
running-page-git-master-yihong0618.vercel.app

Please sign in to comment.