aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'mastodon')
-rw-r--r--mastodon/Mastodon.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py
index 37e35b7..98cebab 100644
--- a/mastodon/Mastodon.py
+++ b/mastodon/Mastodon.py
@@ -2275,13 +2275,17 @@ class Mastodon:
2275 if url['rel'] == 'next': 2275 if url['rel'] == 'next':
2276 # Be paranoid and extract max_id specifically 2276 # Be paranoid and extract max_id specifically
2277 next_url = url['url'] 2277 next_url = url['url']
2278 matchgroups = re.search(r"max_id=([0-9]*)", next_url) 2278 matchgroups = re.search(r"[?&]max_id=([^&]+)", next_url)
2279 2279
2280 if matchgroups: 2280 if matchgroups:
2281 next_params = copy.deepcopy(params) 2281 next_params = copy.deepcopy(params)
2282 next_params['_pagination_method'] = method 2282 next_params['_pagination_method'] = method
2283 next_params['_pagination_endpoint'] = endpoint 2283 next_params['_pagination_endpoint'] = endpoint
2284 next_params['max_id'] = int(matchgroups.group(1)) 2284 max_id = matchgroups.group(1)
2285 if max_id.isdigit():
2286 next_params['max_id'] = int(max_id)
2287 else:
2288 next_params['max_id'] = max_id
2285 if "since_id" in next_params: 2289 if "since_id" in next_params:
2286 del next_params['since_id'] 2290 del next_params['since_id']
2287 response[-1]._pagination_next = next_params 2291 response[-1]._pagination_next = next_params
@@ -2289,13 +2293,17 @@ class Mastodon:
2289 if url['rel'] == 'prev': 2293 if url['rel'] == 'prev':
2290 # Be paranoid and extract since_id specifically 2294 # Be paranoid and extract since_id specifically
2291 prev_url = url['url'] 2295 prev_url = url['url']
2292 matchgroups = re.search(r"since_id=([0-9]*)", prev_url) 2296 matchgroups = re.search(r"[?&]since_id=([^&]+)", prev_url)
2293 2297
2294 if matchgroups: 2298 if matchgroups:
2295 prev_params = copy.deepcopy(params) 2299 prev_params = copy.deepcopy(params)
2296 prev_params['_pagination_method'] = method 2300 prev_params['_pagination_method'] = method
2297 prev_params['_pagination_endpoint'] = endpoint 2301 prev_params['_pagination_endpoint'] = endpoint
2298 prev_params['since_id'] = int(matchgroups.group(1)) 2302 since_id = matchgroups.group(1)
2303 if since_id.isdigit():
2304 prev_params['since_id'] = int(since_id)
2305 else:
2306 prev_params['since_id'] = since_id
2299 if "max_id" in prev_params: 2307 if "max_id" in prev_params:
2300 del prev_params['max_id'] 2308 del prev_params['max_id']
2301 response[0]._pagination_prev = prev_params 2309 response[0]._pagination_prev = prev_params
Powered by cgit v1.2.3 (git 2.41.0)