Esempio n. 1
0
def getstats(config):
    st = Athlete(config.get('StravaTweet', 'rider'))
    lastride = st.rides()[0]
    if last_tweeted_id(lastride.id, config):
        return None
    else:
        return build_message(lastride, config.get('StravaTweet', 'unit'), 
            config)
Esempio n. 2
0
# http://app.strava.com/athletes/103227

from strava import Athlete

# First, we set up a Strava Object for the Athlete that we want to query
st = Athlete(103227)

# Once we've gotten the Athlete's object, we can then look at various
# statistics - number of rides and total moving time are shown below.
# By default, we only look at the last 7 days.

print('Ridden %d rides' % st.ride_stats()['rides'])
print('Total moving time: %f minutes' %
      (float(st.ride_stats()['moving_time']) / 60.0))

# We can then iterate through the rides, and further through the segments on
# each of those rides, displaying information from each. Ride details are stored
# in metric, so, we need to convert that to get imperial measurements.

for ride in st.rides():
    print('Ride name: %s' % ride.name)
    # convert from m/s to mph
    # m/s * 2.23694 = mph
    print('Average speed: %.1f mph' % (ride.detail.average_speed * 2.23694))
    print('Average watts: %d' % ride.detail.average_watts)
    for segment in ride.segments:
        print('  Segment: %s\n    Moving Time: %f minutes\n    Average '
              'Speed: %f mph' %
              (segment.name, segment.detail.moving_time / 60.0,
               segment.detail.average_speed * 0.000621))
Esempio n. 3
0
Once we've gotten the Athlete's object, we can then look at various
statistics - number of rides and total moving time are shown below.
By default, we only look at the last 7 days.
"""

print('Ridden %d rides' % st.ride_stats()['rides'])
print('Total moving time: %f minutes' % \
    (float(st.ride_stats()['moving_time']) / 60.0))

"""
We can then iterate through the rides, and further through the segments on
each of those rides, displaying information from each. Ride details are stored
in metric, so, we need to convert that to get imperial measurements.
"""

for ride in st.rides():
    print('Ride name: %s' % ride.name)
    for segment in ride.segments:
        print('  Segment: %s\n    Moving Time: %f minutes\n    Average ' \
            'Speed: %f mph' % \
            (segment.name, segment.detail.moving_time / 60.0, \
            segment.detail.average_speed * 0.000621))

"""
We can also get a lot of details data points from a ride.
"""
if len(st.rides()) > 0:
    ride = st.rides()[0]
    
    print 'Max altitude: %sm.' % min(ride.stream.altitude)
    print 'Max altitude: %sm.' % max(ride.stream.altitude)