Skip to content
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

Exercises sets and names? #101

Open
melimelo24 opened this issue Dec 7, 2023 · 1 comment
Open

Exercises sets and names? #101

melimelo24 opened this issue Dec 7, 2023 · 1 comment

Comments

@melimelo24
Copy link

melimelo24 commented Dec 7, 2023

Is there any way to get the exercises sets and names for activities with this script (cardio, yoga, strength training activities)? Those are available on the page of the activity:
Screenshot 2023-12-07 at 8 45 30

I tried to extract it directly from .fit files but unfortunately only the original info from the watch is present, not any modifications done on garmin connect (and I think most people need to update their data after, to correct exercises or reps).
Someone made a browser extension in javascript to get those (https://github.com/labsansis/garmin-workout-downloader) so I think it's possible (it's very nice but does not have all the data and flexibility of this script especially for non gym&fitness activities). I tried coding something myself using that as a template but, hum, I am not that good (although still trying).

The information is stored in https://connect.garmin.com/activity-service/activity/${activityId}/exerciseSets

@melimelo24
Copy link
Author

melimelo24 commented Dec 15, 2023

Answering my own question if anyone is interested too :)
Added this after the def load_zones functions:
def load_sets(activity_id, start_time_seconds, args, http_caller, file_writer): """ :param activity_id: ID of the activity (as string) :param start_time_seconds: if given use as timestamp for the file written (in seconds since 1970-01-01) :param args: command-line arguments (for the file_writer callback) :param http_caller: callback to perform the HTTP call for downloading the device details :param file_writer: callback that saves the device details in a file :return: array with the heart rate sets """ sets = [None] sets_json = http_caller(f'{URL_GC_ACTIVITY}{activity_id}/exerciseSets') sets = json.loads(sets_json) if sets['exerciseSets'] == None: # Warning that there is no sets logging.warning("Sets %s are empty", activity_id) else: # We only write sets if they are not empty file_writer(os.path.join(args.directory, f'activity_{activity_id}_sets.json'), sets_json, 'w', start_time_seconds)

And call it under extract['HRzones'] with this:
load_sets(str(actvty['activityId']), start_time_seconds, args, http_req_as_string, write_to_file)

It will write a separate json with exercises sets if it exists

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant