forked from sam-dumont/cowboybike-strava-sync
-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload-file.py
26 lines (25 loc) · 841 Bytes
/
upload-file.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import requests
import json
import sys
import os
json = json.loads(sys.argv[1])
files = {
"file": (
json["filename"],
open(json["filename"], "rb"),
"application-type",
)
}
payload = {
"activity_type": "ebikeride",
"name": json["title"],
"data_type": "tcx",
"description": f"Average motor power: {json['average_motor_power']}W\nAverage user power: {json['average_user_power']}W",
}
req = requests.post(
"https://www.strava.com/api/v3/uploads",
headers={"Authorization": f"Bearer {json['access_token']}"},
data=payload,
files=files,
)
os.remove(json["filename"])