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

Get the activity description (notes) when downloading an activity from Strava #391

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions tapiriik/services/Strava/strava.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,22 @@ def DownloadActivity(self, svcRecord, activity):
return activity
activityID = activity.ServiceData["ActivityID"]

# Get the description (Notes)
activitydata = requests.get("https://www.strava.com/api/v3/activities/" + str(activityID), headers=self._apiHeaders(svcRecord))
if activitydata.status_code == 401:
raise APIException("No authorization to download activity", block=True, user_exception=UserException(UserExceptionType.Authorization, intervention_required=True))

try:
activitydata = activitydata.json()
except:
raise APIException("Activity data returned is not JSON")

if "message" in activitydata and activitydata["message"] == "Record Not Found":
raise APIException("Could not find activity")

if "description" in activitydata:
activity.Notes = activitydata["description"]

streamdata = requests.get("https://www.strava.com/api/v3/activities/" + str(activityID) + "/streams/time,altitude,heartrate,cadence,watts,temp,moving,latlng,distance,velocity_smooth", headers=self._apiHeaders(svcRecord))
if streamdata.status_code == 401:
raise APIException("No authorization to download activity", block=True, user_exception=UserException(UserExceptionType.Authorization, intervention_required=True))
Expand Down