New feature: Download Strava Routes as Workouts

129 views
Skip to first unread message

mattipee

unread,
Apr 21, 2020, 9:21:07 PM4/21/20
to golden-cheetah-developers
I am an intermittent GC user and currently using to re-ride .gpx routes on an indoor trainer and gather stats to analyse. I have just implemented the ability to download Strava Routes as Workouts. Reading contribution guidelines on github has lead me to post here for comment. Happy to create a PR if you would like to incorporate this change.

Motivation:
Strava has a Routes Builder (https://www.strava.com/athlete/routes) which makes is easy to create and name new routes, which I can then load onto my watch to follow while riding outdoors, or download .gpx and import to GC to ride indoors. The manual download-gpx and import-to-GC process is a minor hassle, particularly at scale, is many mouse clicks, leaves files lying around, etc.


By copy-modifying the TodaysPlanWorkoutDownload.cpp dialog and drawing a little from Cloud/Strava.cpp, I now have this implemented and appears to work well. Note that without read_all pemissions, only public Routes are available via the API.

Couple of points to discuss:
  - Implementation in Train/StravaRoutesDownload.cpp vs Cloud/Strava.cpp - I went with former to isolate my code, and mirror TodaysPlanWorkoutDownload.cpp
  - Translations - not yet done
  - Naming scheme - Strava allows duplicate names, I have proposed "Strava-Route-id-Name", where id is the numeric id of the Route. Eg "Strava-Route-123456-Local_hill_repeats". The numeric id may be ugly, but is required for strict disambiguation.

Pretty slick, though. Thanks for GC, I'll be seeing more of it.
Matt.

mattipee

unread,
Apr 22, 2020, 4:50:58 AM4/22/20
to golden-cheetah-developers

mattipee

unread,
Apr 22, 2020, 5:28:21 AM4/22/20
to golden-cheetah-developers
Related: Strava OAuth

  • read_all - Allows access to view private routes, private segments, and private events. This scope matches the old view_private scope, except that it no longer includes access to private activities.
  • ...
  • activity:read_all - NEW! Allows the same access as activity:read, plus access to read the athlete’s activities that are visible to “Only You.”
Change relating to https://github.com/GoldenCheetah/GoldenCheetah/issues/3199 was to change "view_private,write" -> "activity:read_all,activity:write".

The change successfully recovered access to private activities, but for the purposes of obtaining private Routes as Workouts, I would propose a further change to "read_all,activity:read_all,activity:write".

Ale Martinez - No direct email please

unread,
Apr 22, 2020, 11:50:06 AM4/22/20
to golden-cheetah-developers
El martes, 21 de abril de 2020, 22:21:07 (UTC-3), mattipee escribió:
I am an intermittent GC user and currently using to re-ride .gpx routes on an indoor trainer and gather stats to analyse. I have just implemented the ability to download Strava Routes as Workouts. Reading contribution guidelines on github has lead me to post here for comment. Happy to create a PR if you would like to incorporate this change.

Motivation:
Strava has a Routes Builder (https://www.strava.com/athlete/routes) which makes is easy to create and name new routes, which I can then load onto my watch to follow while riding outdoors, or download .gpx and import to GC to ride indoors. The manual download-gpx and import-to-GC process is a minor hassle, particularly at scale, is many mouse clicks, leaves files lying around, etc.

This partly can be simplified, avoiding the need to name and keep track of files, using a Web chart in Train view pointing to Strava Routes Builder, when you select export GPX the download will be intercepted and import to library offered automatically, there is a Web chart in CloudDB for the same purpose using ErgDB.

mattipee

unread,
Apr 23, 2020, 2:27:37 AM4/23/20
to golden-cheetah-developers
This partly can be simplified, avoiding the need to name and keep track of files, using a Web chart in Train view pointing to Strava Routes Builder, when you select export GPX the download will be intercepted and import to library offered automatically, there is a Web chart in CloudDB for the same purpose using ErgDB.

Thanks, Ale.

I found the "View > Download Chart..." option in V3.5 (build 3991), accepted conditions and tried to download the ErgDB chart to have a look. Nothing appears to have changed. In "View > Add Chart", I can't find anything to add. Am I doing something wrong?

Matt

mattipee

unread,
Apr 23, 2020, 3:12:34 AM4/23/20
to golden-cheetah-developers
After an application restart (or in fact, clicking from Train to Activities and back to Train) the downloaded chart(s) appear. Perhaps a bug? Train view should refresh after chart has been added.

Anyway - yes - a new Web Chart gives me the Routes interface on Strava's website, and ability to import on download. Thanks for the pointer, I would not have found this myself.

While I have made it work, I'm not sure I like it as much as the coded change I have proposed:
 - one still has to log in via the chart, click into and out of each route, download, import.
 - is there a way to make Strava pre-authorisation mean this isn't necessary, or is that just for the API?
 - I accept that a no-code option of a web chart is going to be easier to maintain however. In which case I'm in two minds.
 - The chart approach is almost no easier than just going to the website in a browser, indeed default size of the chart is restrictive, so you have to scroll, enlarge etc.
 - There is no option to select a download location, Downloads is used.
 - In fact, it would be nicer to use a tmp file or delete-on-import as this would be cleaner than leaving files lying around.

On inspection, the default workouts directory is C:\Users\Me\AppData\Local, where I was expecting C:\Users\Me\AppData\Local\GoldenCheetah\Me\workouts. Perhaps a bug?

I guess what I'm saying is that I still personally prefer the "Download Routes from Strava" dialog which presents a list of all activities and checkboxes. From the perspective of maintenance vs number of user likely to use, I don't know.

Interested to hear feedback.
Matt.

Eric Christoffersen

unread,
Apr 24, 2020, 1:27:13 AM4/24/20
to golden-cheetah-developers
Totally agree with matt.

Ale Martinez - No direct email please

unread,
Apr 24, 2020, 10:45:06 AM4/24/20
to golden-cheetah-developers
El jueves, 23 de abril de 2020, 4:12:34 (UTC-3), mattipee escribió:
After an application restart (or in fact, clicking from Train to Activities and back to Train) the downloaded chart(s) appear. Perhaps a bug? Train view should refresh after chart has been added.

Anyway - yes - a new Web Chart gives me the Routes interface on Strava's website, and ability to import on download. Thanks for the pointer, I would not have found this myself.

While I have made it work, I'm not sure I like it as much as the coded change I have proposed:
 - one still has to log in via the chart, click into and out of each route, download, import.
 - is there a way to make Strava pre-authorisation mean this isn't necessary, or is that just for the API?

Only for the API, but in several cases s.t. Garmin Connect the authorization is preserved between sessions.
 
 - I accept that a no-code option of a web chart is going to be easier to maintain however. In which case I'm in two minds.
 - The chart approach is almost no easier than just going to the website in a browser, indeed default size of the chart is restrictive, so you have to scroll, enlarge etc.
 - There is no option to select a download location, Downloads is used.
 - In fact, it would be nicer to use a tmp file or delete-on-import as this would be cleaner than leaving files lying around.

On inspection, the default workouts directory is C:\Users\Me\AppData\Local, where I was expecting C:\Users\Me\AppData\Local\GoldenCheetah\Me\workouts. Perhaps a bug?

The workout library is not athlete specific so GoldenCheetah\Me\workouts is not an option, perhaps GoldenCheetah\.workouts could be a better default
 
I guess what I'm saying is that I still personally prefer the "Download Routes from Strava" dialog which presents a list of all activities and checkboxes. From the perspective of maintenance vs number of user likely to use, I don't know.

Me neither, but since you are already advanced at the issue, please make a Pull Request for better evaluation. 

mattipee

unread,
Apr 24, 2020, 11:29:59 AM4/24/20
to golden-cheetah-developers

Ale Martinez

unread,
Mar 23, 2024, 6:10:30 PM3/23/24
to golden-cheetah-developers
El viernes, 24 de abril de 2020 a la(s) 12:29:59 p.m. UTC-3, mattipee escribió:
Cheers, Ale. Done.

https://github.com/GoldenCheetah/GoldenCheetah/pull/3413

It's been a while but this PR is finally merged.
At the code level is good to have this as an example for other workout downloaders now Today's Plan is deprecated.
For users they can download their Public Routes using existing credentials and Private Routes after re-authorization to add the required permission.
For other platforms this feature will be included in next snapshot builds update.
Cheers, Ale. 
Reply all
Reply to author
Forward
0 new messages