gazpachoking / trainaspower

Convert TrainAsOne training plans from pace to power, and upload them to FinalSurge for use in Stryd workouts.
21 stars 5 forks source link

Use TAO provided JSON for workout generation #19

Closed jahofmann closed 2 years ago

jahofmann commented 2 years ago

This pull request replaces the parsing of workout data from the TAO website. TAO now provides workout data in a convenient JSON format that is simpler to parse.

Caveats right now:

gazpachoking commented 2 years ago

Awesome, thanks for this. I'll try to have a closer peek and test it out for some different kinds of workouts. As for other points:

Distance and total time is still taken from the workout html as those values are not part of the JSON.

Seems fine. This data doesn't even make it all the way into the stryd workout, so I'm not sure how important it is. I originally thought this project might expand to allow for different input and output services.

Power adjustments are not included as there is no direct mapping between the JSON and pace steps as shown by TAO.

Maybe we switch this to just have adjustments for warmup cooldown and active, rather than the finer grained approach I had before. Not sure the best way, I just like a wider margin on some steps so my watch isn't constantly beeping at me for going out of the range.

The cloudflare fix is not included anymore. I am unsure if this issue could also appear using this approach.

Nope, we should be fine on that. I'm not even sure why, but my workout IDs started having an @ symbol after them. I think that's what was triggering cloudflare to obfuscate them. Perhaps we should make sure to strip that from the end of the workout IDs, not sure why it shows up, and who it will show up for. (Does anyone else have this? e.g. W1430A@ Economy 55℉)

Some other stuff:

gazpachoking commented 2 years ago

It was an encoding problem with the temperature. Not sure if we want that in the title at all, but to fix the loading all we have to do is force it to recognize as utf-8.

r.encoding = 'utf-8'
workout_json = r.json()
jahofmann commented 2 years ago

This works fine for me for the last couple of weeks, so I'll remove the WIP tag.

@gazpachoking Anything you'd like to be addressed?

gazpachoking commented 2 years ago

I guess we should go with this. I wish we could tell the difference between the 'easy' runs and other active bits though. The only reason I've been holding off is because I use the power adjustments per step type at the moment.

gazpachoking commented 2 years ago

I was also trying to mitm the android app, to see if there was a nice json format available that way with more info, but so far haven't had success

jahofmann commented 2 years ago

I was also trying to mitm the android app, to see if there was a nice json format available that way with more info, but so far haven't had success

That's a good idea... I'll see if I can help with that.

gazpachoking commented 2 years ago

Thanks for all the work on this! I decided to go with it now. I'd like to restore the power range adjustment in some form or another at some point, but that's less important than reliable workout conversion. I'd still like to see what sort of json is being provided to the app, but was having quite a bit of trouble getting a mitm to see the app traffic.

jahofmann commented 2 years ago

You could ask Sean if he'd be willing to provide you documentation or add the relevant information in the description field of the Garmin JSON workout steps.