Skip to content

Commit

Permalink
Merge branch 'upstream'
Browse files Browse the repository at this point in the history
* upstream:
  fix: drop useless png
  fix: bring old logic back
  fix: yihong0618#484 keep gps data decode (yihong0618#524)
  updatereadme (yihong0618#527)

# Conflicts:
#	README-CN.md
#	README.md
#	run_page/keep_sync.py
  • Loading branch information
ben-29 committed Oct 23, 2023
2 parents c8a5795 + a7b2e68 commit 58fd21b
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions run_page/keep_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
import zlib
from collections import namedtuple
from datetime import datetime, timedelta
from Crypto.Cipher import AES

import eviltransform
import gpxpy
import polyline
import requests
from config import GPX_FOLDER, JSON_FILE, SQL_FILE, run_map, start_point
from Crypto.Cipher import AES
from generator import Generator
from utils import adjust_time

Expand All @@ -22,20 +22,17 @@
RUN_DATA_API = "https://api.gotokeep.com/pd/v3/stats/detail?dateUnit=all&type=running&lastDate={last_date}"
RUN_LOG_API = "https://api.gotokeep.com/pd/v3/runninglog/{run_id}"

# AES Decrypt key
key = b"56fe59;82g:d873c"
iv = b"2346892432920300"

# If your points need trans from gcj02 to wgs84 coordinate which use by Mappbox
# If your points need trans from gcj02 to wgs84 coordinate which use by Mapbox
TRANS_GCJ02_TO_WGS84 = True


def login(session, mobile, passowrd):
def login(session, mobile, password):
headers = {
"User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0",
"Content-Type": "application/x-www-form-urlencoded;charset=utf-8",
}
data = {"mobile": mobile, "password": passowrd}
data = {"mobile": mobile, "password": password}
r = session.post(LOGIN_API, headers=headers, data=data)
if r.ok:
token = r.json()["data"]["token"]
Expand Down Expand Up @@ -71,8 +68,10 @@ def get_single_run_data(session, headers, run_id):

def decode_runmap_data(text, is_geo=False):
_bytes = base64.b64decode(text)
key = "NTZmZTU5OzgyZzpkODczYw=="
iv = "MjM0Njg5MjQzMjkyMDMwMA=="
if is_geo:
cipher = AES.new(key, AES.MODE_CBC, iv)
cipher = AES.new(base64.b64decode(key), AES.MODE_CBC, base64.b64decode(iv))
_bytes = cipher.decrypt(_bytes)
run_points_data = zlib.decompress(_bytes, 16 + zlib.MAX_WBITS)
run_points_data = json.loads(run_points_data)
Expand Down

0 comments on commit 58fd21b

Please sign in to comment.