From 16c8a74790b1420afaed41a9031646f9405eb0b0 Mon Sep 17 00:00:00 2001 From: petergardfjall Date: Mon, 7 Nov 2016 19:21:46 +0100 Subject: [PATCH] #10: activity json summary endpoint is retired --- garminexport/backup.py | 5 +++++ garminexport/garminclient.py | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/garminexport/backup.py b/garminexport/backup.py index 1d0f11b..b053c79 100644 --- a/garminexport/backup.py +++ b/garminexport/backup.py @@ -115,6 +115,7 @@ def download(client, activity, backup_dir, export_formats=None): id = activity[0] if 'json_summary' in export_formats: + log.debug("getting json summary for %s", id) activity_summary = client.get_activity_summary(id) dest = os.path.join( backup_dir, export_filename(activity, 'json_summary')) @@ -123,6 +124,7 @@ def download(client, activity, backup_dir, export_formats=None): activity_summary, ensure_ascii=False, indent=4)) if 'json_details' in export_formats: + log.debug("getting json details for %s", id) activity_details = client.get_activity_details(id) dest = os.path.join( backup_dir, export_filename(activity, 'json_details')) @@ -133,6 +135,7 @@ def download(client, activity, backup_dir, export_formats=None): not_found_path = os.path.join(backup_dir, not_found_file) with open(not_found_path, mode="a") as not_found: if 'gpx' in export_formats: + log.debug("getting gpx for %s", id) activity_gpx = client.get_activity_gpx(id) dest = os.path.join( backup_dir, export_filename(activity, 'gpx')) @@ -143,6 +146,7 @@ def download(client, activity, backup_dir, export_formats=None): f.write(activity_gpx) if 'tcx' in export_formats: + log.debug("getting tcx for %s", id) activity_tcx = client.get_activity_tcx(id) dest = os.path.join( backup_dir, export_filename(activity, 'tcx')) @@ -153,6 +157,7 @@ def download(client, activity, backup_dir, export_formats=None): f.write(activity_tcx) if 'fit' in export_formats: + log.debug("getting fit for %s", id) activity_fit = client.get_activity_fit(id) dest = os.path.join( backup_dir, export_filename(activity, 'fit')) diff --git a/garminexport/garminclient.py b/garminexport/garminclient.py index d9f113b..e1801e7 100755 --- a/garminexport/garminclient.py +++ b/garminexport/garminclient.py @@ -265,9 +265,9 @@ class GarminClient(object): :returns: The activity summary as a JSON dict. :rtype: dict """ - response = self.session.get("https://connect.garmin.com/modern/proxy/activity-service-1.3/json/activity/{}".format(activity_id)) + response = self.session.get("https://connect.garmin.com/modern/proxy/activity-service-1.3/json/activity_embed/{}".format(activity_id)) if response.status_code != 200: - raise Exception(u"failed to fetch activity {}: {}\n{}".format( + raise Exception(u"failed to fetch json summary for activity {}: {}\n{}".format( activity_id, response.status_code, response.text)) return json.loads(response.text) @@ -285,7 +285,7 @@ class GarminClient(object): # mounted at xml or json depending on result encoding response = self.session.get("https://connect.garmin.com/modern/proxy/activity-service-1.3/json/activityDetails/{}".format(activity_id)) if response.status_code != 200: - raise Exception(u"failed to fetch activity details for {}: {}\n{}".format( + raise Exception(u"failed to fetch json activityDetails for {}: {}\n{}".format( activity_id, response.status_code, response.text)) return json.loads(response.text) @@ -357,7 +357,7 @@ class GarminClient(object): return (None,None) if response.status_code != 200: raise Exception( - u"failed to get original activity file {}: {}\n{}".format( + u"failed to get original activity file for {}: {}\n{}".format( activity_id, response.status_code, response.text)) # return the first entry from the zip archive where the filename is