diff options
Diffstat (limited to 'mastodon')
-rw-r--r-- | mastodon/Mastodon.py | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index ca7dbd6..0c9d339 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py | |||
@@ -2323,13 +2323,16 @@ class Mastodon: | |||
2323 | next_params['max_id'] = max_id | 2323 | next_params['max_id'] = max_id |
2324 | if "since_id" in next_params: | 2324 | if "since_id" in next_params: |
2325 | del next_params['since_id'] | 2325 | del next_params['since_id'] |
2326 | if "min_id" in next_params: | ||
2327 | del next_params['min_id'] | ||
2326 | response[-1]._pagination_next = next_params | 2328 | response[-1]._pagination_next = next_params |
2327 | 2329 | ||
2328 | if url['rel'] == 'prev': | 2330 | if url['rel'] == 'prev': |
2329 | # Be paranoid and extract since_id specifically | 2331 | # Be paranoid and extract since_id or min_id specifically |
2330 | prev_url = url['url'] | 2332 | prev_url = url['url'] |
2333 | |||
2334 | # Old and busted (pre-2.6.0): since_id pagination | ||
2331 | matchgroups = re.search(r"[?&]since_id=([^&]+)", prev_url) | 2335 | matchgroups = re.search(r"[?&]since_id=([^&]+)", prev_url) |
2332 | |||
2333 | if matchgroups: | 2336 | if matchgroups: |
2334 | prev_params = copy.deepcopy(params) | 2337 | prev_params = copy.deepcopy(params) |
2335 | prev_params['_pagination_method'] = method | 2338 | prev_params['_pagination_method'] = method |
@@ -2342,7 +2345,21 @@ class Mastodon: | |||
2342 | if "max_id" in prev_params: | 2345 | if "max_id" in prev_params: |
2343 | del prev_params['max_id'] | 2346 | del prev_params['max_id'] |
2344 | response[0]._pagination_prev = prev_params | 2347 | response[0]._pagination_prev = prev_params |
2345 | 2348 | ||
2349 | # New and fantastico (post-2.6.0): min_id pagination | ||
2350 | matchgroups = re.search(r"[?&]min_id=([^&]+)", prev_url) | ||
2351 | if matchgroups: | ||
2352 | prev_params = copy.deepcopy(params) | ||
2353 | prev_params['_pagination_method'] = method | ||
2354 | prev_params['_pagination_endpoint'] = endpoint | ||
2355 | min_id = matchgroups.group(1) | ||
2356 | if min_id.isdigit(): | ||
2357 | prev_params['min_id'] = int(min_id) | ||
2358 | else: | ||
2359 | prev_params['min_id'] = min_id | ||
2360 | if "max_id" in prev_params: | ||
2361 | del prev_params['max_id'] | ||
2362 | response[0]._pagination_prev = prev_params | ||
2346 | 2363 | ||
2347 | return response | 2364 | return response |
2348 | 2365 | ||