Esempio n. 1
0
def workout_from_activity(json):
    workout = Workout()

    workout.is_imported = True
    workout.workout_start = json['start_time']  # Parse into date first

    workout.distance = json['total_distance']
    workout.climb = json['climb']
    workout.duration = json['duration']
    workout.calories = json['total_calories']

    workout.tracking_mode = json['tracking_mode']
    workout.equipment_type = json['equipment']
    workout.workout_type = workout_type_from_runkeeper_type(json['type'])

    if json['path'] is not None:
        for path_point in json['path']:
            point = workout_point_from_path_point(path_point)
            workout.points.append(point)

    if json['images'] is not None:
        for image in json['images']:
            point = workout_point_from_image(image)
            workout.points.append(point)

    return workout
Esempio n. 2
0
def workout_from_strava_activity(json):
    workout = Workout()

    workout.is_imported = True
    workout.workout_start = json["start_date"]

    workout.duration = float(json["elapsed_time"])
    workout.distance = json["distance"]
    workout.calories = int(json["calories"])
    workout.climb = json["total_elevation_gain"]

    workout.workout_type = workout_type_from_strava_type(json["type"])

    # Strava does not save each individual path point
    # but encodes them as polylines.
    # Use http://polyline.readthedocs.org/en/v1.1/ to
    # decode the polyline nested under map.

    return workout