diff --git a/rowers/stravastuff.py b/rowers/stravastuff.py index 6c0cf8f0..13c20463 100644 --- a/rowers/stravastuff.py +++ b/rowers/stravastuff.py @@ -139,6 +139,7 @@ def get_strava_workout(user,stravaid): else: # ready to fetch. Hurray fetchresolution = 'high' + series_type = 'time' authorizationstring = str('Bearer ' + r.stravatoken) headers = {'Authorization': authorizationstring, 'user-agent': 'sanderroosendaal', @@ -150,17 +151,18 @@ def get_strava_workout(user,stravaid): workoutsummary['timezone'] = "Etc/UTC" startdatetime = workoutsummary['start_date'] - url = "https://www.strava.com/api/v3/activities/"+str(stravaid)+"/streams/cadence?resolution="+fetchresolution + url = "https://www.strava.com/api/v3/activities/"+str(stravaid)+"/streams/cadence?resolution="+fetchresolution+"&series_type="+series_type spmjson = requests.get(url,headers=headers) - url = "https://www.strava.com/api/v3/activities/"+str(stravaid)+"/streams/heartrate?resolution="+fetchresolution + url = "https://www.strava.com/api/v3/activities/"+str(stravaid)+"/streams/heartrate?resolution="+fetchresolution+"&series_type="+series_type hrjson = requests.get(url,headers=headers) - url = "https://www.strava.com/api/v3/activities/"+str(stravaid)+"/streams/time?resolution="+fetchresolution + url = "https://www.strava.com/api/v3/activities/"+str(stravaid)+"/streams/time?resolution="+fetchresolution+"&series_type="+series_type + print url timejson = requests.get(url,headers=headers) - url = "https://www.strava.com/api/v3/activities/"+str(stravaid)+"/streams/velocity_smooth?resolution="+fetchresolution + url = "https://www.strava.com/api/v3/activities/"+str(stravaid)+"/streams/velocity_smooth?resolution="+fetchresolution+"&series_type="+series_type velojson = requests.get(url,headers=headers) - url = "https://www.strava.com/api/v3/activities/"+str(stravaid)+"/streams/distance?resolution="+fetchresolution + url = "https://www.strava.com/api/v3/activities/"+str(stravaid)+"/streams/distance?resolution="+fetchresolution+"&series_type="+series_type distancejson = requests.get(url,headers=headers) - url = "https://www.strava.com/api/v3/activities/"+str(stravaid)+"/streams/latlng?resolution="+fetchresolution + url = "https://www.strava.com/api/v3/activities/"+str(stravaid)+"/streams/latlng?resolution="+fetchresolution+"&series_type="+series_type latlongjson = requests.get(url,headers=headers) try: @@ -173,18 +175,19 @@ def get_strava_workout(user,stravaid): return (0,"something went wrong with the Strava import") try: - spm = np.array( spmjson.json()[1]['data']) - except IndexError: + print spmjson.json() + spm = np.array(spmjson.json()[1]['data']) + except: spm = np.zeros(nr_rows) try: hr = np.array(hrjson.json()[1]['data']) - except IndexError: + except IndexError,KeyError: hr = np.zeros(nr_rows) try: velo = np.array(velojson.json()[1]['data']) - except IndexError: + except IndexError,KeyError: velo = np.zeros(nr_rows) dt = np.diff(t).mean() @@ -195,7 +198,7 @@ def get_strava_workout(user,stravaid): try: lat = coords[:,0] lon = coords[:,1] - except IndexError: + except IndexError,KeyError: lat = np.zeros(len(t)) lon = np.zeros(len(t))