#10: activity json summary endpoint is retired
This commit is contained in:
parent
c8bb336d42
commit
16c8a74790
@ -115,6 +115,7 @@ def download(client, activity, backup_dir, export_formats=None):
|
|||||||
id = activity[0]
|
id = activity[0]
|
||||||
|
|
||||||
if 'json_summary' in export_formats:
|
if 'json_summary' in export_formats:
|
||||||
|
log.debug("getting json summary for %s", id)
|
||||||
activity_summary = client.get_activity_summary(id)
|
activity_summary = client.get_activity_summary(id)
|
||||||
dest = os.path.join(
|
dest = os.path.join(
|
||||||
backup_dir, export_filename(activity, 'json_summary'))
|
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))
|
activity_summary, ensure_ascii=False, indent=4))
|
||||||
|
|
||||||
if 'json_details' in export_formats:
|
if 'json_details' in export_formats:
|
||||||
|
log.debug("getting json details for %s", id)
|
||||||
activity_details = client.get_activity_details(id)
|
activity_details = client.get_activity_details(id)
|
||||||
dest = os.path.join(
|
dest = os.path.join(
|
||||||
backup_dir, export_filename(activity, 'json_details'))
|
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)
|
not_found_path = os.path.join(backup_dir, not_found_file)
|
||||||
with open(not_found_path, mode="a") as not_found:
|
with open(not_found_path, mode="a") as not_found:
|
||||||
if 'gpx' in export_formats:
|
if 'gpx' in export_formats:
|
||||||
|
log.debug("getting gpx for %s", id)
|
||||||
activity_gpx = client.get_activity_gpx(id)
|
activity_gpx = client.get_activity_gpx(id)
|
||||||
dest = os.path.join(
|
dest = os.path.join(
|
||||||
backup_dir, export_filename(activity, 'gpx'))
|
backup_dir, export_filename(activity, 'gpx'))
|
||||||
@ -143,6 +146,7 @@ def download(client, activity, backup_dir, export_formats=None):
|
|||||||
f.write(activity_gpx)
|
f.write(activity_gpx)
|
||||||
|
|
||||||
if 'tcx' in export_formats:
|
if 'tcx' in export_formats:
|
||||||
|
log.debug("getting tcx for %s", id)
|
||||||
activity_tcx = client.get_activity_tcx(id)
|
activity_tcx = client.get_activity_tcx(id)
|
||||||
dest = os.path.join(
|
dest = os.path.join(
|
||||||
backup_dir, export_filename(activity, 'tcx'))
|
backup_dir, export_filename(activity, 'tcx'))
|
||||||
@ -153,6 +157,7 @@ def download(client, activity, backup_dir, export_formats=None):
|
|||||||
f.write(activity_tcx)
|
f.write(activity_tcx)
|
||||||
|
|
||||||
if 'fit' in export_formats:
|
if 'fit' in export_formats:
|
||||||
|
log.debug("getting fit for %s", id)
|
||||||
activity_fit = client.get_activity_fit(id)
|
activity_fit = client.get_activity_fit(id)
|
||||||
dest = os.path.join(
|
dest = os.path.join(
|
||||||
backup_dir, export_filename(activity, 'fit'))
|
backup_dir, export_filename(activity, 'fit'))
|
||||||
|
@ -265,9 +265,9 @@ class GarminClient(object):
|
|||||||
:returns: The activity summary as a JSON dict.
|
:returns: The activity summary as a JSON dict.
|
||||||
:rtype: 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:
|
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))
|
activity_id, response.status_code, response.text))
|
||||||
return json.loads(response.text)
|
return json.loads(response.text)
|
||||||
|
|
||||||
@ -285,7 +285,7 @@ class GarminClient(object):
|
|||||||
# mounted at xml or json depending on result encoding
|
# 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))
|
response = self.session.get("https://connect.garmin.com/modern/proxy/activity-service-1.3/json/activityDetails/{}".format(activity_id))
|
||||||
if response.status_code != 200:
|
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))
|
activity_id, response.status_code, response.text))
|
||||||
return json.loads(response.text)
|
return json.loads(response.text)
|
||||||
|
|
||||||
@ -357,7 +357,7 @@ class GarminClient(object):
|
|||||||
return (None,None)
|
return (None,None)
|
||||||
if response.status_code != 200:
|
if response.status_code != 200:
|
||||||
raise Exception(
|
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))
|
activity_id, response.status_code, response.text))
|
||||||
|
|
||||||
# return the first entry from the zip archive where the filename is
|
# return the first entry from the zip archive where the filename is
|
||||||
|
Loading…
Reference in New Issue
Block a user