-
-
Save JasonSanford/ddbe06832e5d17061b8a to your computer and use it in GitHub Desktop.
mapmyfitness-python pagination
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
from mapmyfitness import MapMyFitness | |
api_key = 'abc123' | |
access_token = 'xyz789' | |
mmf = MapMyFitness(api_key=api_key, access_token=access_token, cache_finds=True) | |
start_datetime = datetime.datetime(2014, 1, 1, 0, 0, 0) | |
end_datetime = datetime.datetime(2015, 1, 1, 0, 0, 0) | |
workouts_paginator = mmf.workout.search(user=9118466, per_page=40, started_after=start_datetime, started_before=end_datetime) | |
page_count = workouts_paginator.num_pages | |
page_range = workouts_paginator.page_range | |
total_count = workouts_paginator.count | |
print('Page count: {}'.format(page_count)) | |
print('Page range: {}'.format(page_range)) | |
print('Total count: {}'.format(total_count)) | |
for page_num in page_range: | |
the_page = workouts_paginator.page(page_num) | |
print(the_page) | |
for workout in the_page: | |
print(workout.start_datetime) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Page count: 2 | |
Page range: [1, 2] | |
Total count: 58 | |
<Page 1 of 2> | |
2014-01-02 02:59:53+00:00 | |
2014-01-02 14:42:30+00:00 | |
2014-01-02 21:35:34+00:00 | |
2014-01-03 17:57:35+00:00 | |
2014-01-04 16:27:15+00:00 | |
2014-01-05 20:22:45+00:00 | |
2014-01-06 18:01:55+00:00 | |
2014-01-07 19:46:48+00:00 | |
2014-01-09 22:30:07+00:00 | |
2014-01-09 22:30:07+00:00 | |
2014-01-09 22:30:07+00:00 | |
2014-01-09 18:11:43+00:00 | |
2014-01-10 23:58:07+00:00 | |
2014-01-15 17:43:31+00:00 | |
2014-01-16 00:00:46+00:00 | |
2014-01-16 22:00:05+00:00 | |
2014-01-21 20:37:24+00:00 | |
2014-01-26 19:41:50+00:00 | |
2014-01-29 19:15:50+00:00 | |
2014-01-29 19:45:41+00:00 | |
2014-01-29 21:09:39+00:00 | |
2014-01-29 23:56:50+00:00 | |
2014-01-30 13:59:16+00:00 | |
2014-01-30 16:30:58+00:00 | |
2014-01-30 16:46:22+00:00 | |
2014-02-08 21:22:44+00:00 | |
2014-02-11 00:57:42+00:00 | |
2014-02-13 21:44:30+00:00 | |
2014-02-16 19:57:08+00:00 | |
2014-02-16 22:15:36+00:00 | |
2014-02-18 19:31:00+00:00 | |
2014-02-20 19:32:29+00:00 | |
2014-02-23 21:22:38+00:00 | |
2014-02-25 17:44:00+00:00 | |
2014-03-04 21:15:45+00:00 | |
2014-03-06 19:02:59+00:00 | |
2014-03-11 16:12:27+00:00 | |
2014-03-15 14:46:00+00:00 | |
2014-03-19 21:44:26+00:00 | |
2014-03-21 17:58:44+00:00 | |
<Page 2 of 2> | |
2014-03-22 18:38:48+00:00 | |
2014-03-24 23:24:13+00:00 | |
2014-03-26 18:53:00+00:00 | |
2014-03-28 19:16:00+00:00 | |
2014-04-02 16:56:52+00:00 | |
2014-04-02 22:57:00+00:00 | |
2014-04-03 23:25:42+00:00 | |
2014-04-05 14:02:35+00:00 | |
2014-04-11 17:07:10+00:00 | |
2014-04-13 23:50:00+00:00 | |
2014-04-20 15:15:00+00:00 | |
2014-04-22 11:34:28+00:00 | |
2014-04-27 16:35:15+00:00 | |
2014-04-28 04:00:00+00:00 | |
2014-04-29 23:13:00+00:00 | |
2014-05-04 16:31:30+00:00 | |
2014-05-07 21:17:54+00:00 | |
2014-05-09 12:23:00+00:00 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment