-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide another way to upload all kinds of sport type of TCX file to … #666
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
run_page/tcx_to_strava_sync.py
Outdated
type = to_upload_dict.get(i)["type"].lower() | ||
if type not in STRAVA_GARMIN_TYPE_DICT.values(): | ||
continue | ||
strava_type = list(STRAVA_GARMIN_TYPE_DICT.keys())[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about storing a reverted dict first:
GARMIN_STRAVA_TYPE_DICT = {value: key for key, value in STRAVA_GARMIN_TYPE_DICT.items()}
and this 3 lines can be replace by
strava_type = GARMIN_STRAVA_TYPE_DICT[type]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK,I'll fix it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
89ed833
Fixed here.
run_page/utils.py
Outdated
with open(file_name, "rb") as f: | ||
try: | ||
r = client.upload_activity( | ||
activity_file=f, data_type=data_type, activity_type=type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder how Strava determines the type if you just upload the file but don't specify the activity_type?
For example, if you upload a tcx with the type of hiking
, what type would it be in Strava?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- got the description in Stravalib API here:
:param activity_type: (optional) case-insensitive type of activity.
possible values: ride, run, swim, workout, hike, walk,
nordicski, alpineski, backcountryski, iceskate, inlineskate,
kitesurf, rollerski, windsurf, workout, snowboard, snowshoe
Type detected from file overrides, uses athlete's default type if not specified
:type activity_type: str
- I have performed a test on my pc, and the result is just like uploading failed without strong hint:
to load all tcx files maybe take some time
Access ok
Start syncing
.
Process finished with exit code 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've checked the documentation for the upload API, which states that it detects the sport type
from the file. refer: https://developers.strava.com/docs/uploads/
- I have performed a test on my pc, and the result is just like uploading failed without strong hint:
to load all tcx files maybe take some time Access ok Start syncing . Process finished with exit code 0
A dot (.
) in the console indicates an updated activity, and a plus (+
) indicates a created activity. I'm guessing the file you uploaded was already synced to Strava.
Can you help me test the following steps:
- Export a TCX of an activity in a others type, such as hiking or cycling.
- Delete the activity in Strava (you can re-upload it with the exported TCX file).
- Upload it using
utils.upload_file_to_strava
withforce_to_run = False
- Check the activity type uploaded to Strava. if the type is correct then I believe we can use this function instead of adding
upload_file_to_strava_with_type
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tested the TCX format of 'Running' and 'Biking'. The result is just as you said, and the type which shows at Strava is correct.
So, It seems that this PR is no longer needed?
@ben-29
0602a90
to
89ed833
Compare
run_page/tcx_to_strava_sync.py
Outdated
|
||
|
||
def get_to_generate_files(last_time): | ||
""" | ||
reuturn to values one dict for upload | ||
return to values one dict for upload |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😂
run_page/tcx_to_strava_sync.py
Outdated
try: | ||
upload_file_to_strava(client, tcx_file, "tcx") | ||
upload_file_to_strava_with_type(client, tcx_file, "tcx", strava_type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about reverting other changes and adding a force_to_run = False
parameter here instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about reverting other changes and adding a
force_to_run = False
parameter here instead?
Sounds fair. I will do it later.
89ed833
to
2a2a414
Compare
Please have another look. Thx. @ben-29 @yihong0618 |
@@ -92,7 +92,7 @@ def get_strava_last_time(client, is_milliseconds=True): | |||
return 0 | |||
|
|||
|
|||
def upload_file_to_strava(client, file_name, data_type, force_to_run=True): | |||
def upload_file_to_strava(client, file_name, data_type, force_to_run=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default force_to_run
shouldn't be changed here, as it will affect features like Garmin, Keep, and Nike.
Just change the param in tcx_to_strava_sync
.
Or just keep this unchanged, since this repo is mainly for running.
I'll change the force_to_run=False
in workouts_page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I see
1、Support not only running but also biking.