Beispiel #1
0
def next():
    global activity_counter, club_activities

    if not club_activities:
        access_token = Athlete.select()[0].access_token
        club_activities = requests.get(
            'https://www.strava.com/api/v3/clubs/198580/activities?access_token='
            + access_token).json()

    current_activity = club_activities[activity_counter]
    # if current_activity['type'] != "Run" and current_activity['type'] != "Ride":
    # 	app.logger.debug('Stumbled upon an activity of type: %s, moving on to the next!' % current_activity['type'])
    # 	activity_counter += 1
    # 	if activity_counter == len(club_activities): activity_counter = 0
    # 	next()

    access_token = Athlete.get(
        Athlete.user_id == current_activity['athlete']['id']).access_token
    r = requests.get(
        'https://www.strava.com/api/v3/activities/%s/streams/latlng,time?access_token=%s'
        % (current_activity['id'], access_token))

    activity_counter += 1
    if activity_counter == len(club_activities): activity_counter = 0

    app.logger.debug('Activity counter: %s' % activity_counter)

    data = current_activity
    data['streams'] = r.json()

    return json.dumps(data)
Beispiel #2
0
def hello():
    if len(Athlete.select()) > 0:
        return render_template('index.html')
    else:
        return render_template('strava_auth.html',
                               strava_auth_url=strava_auth_url)