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 fc585ba..0550d85 100644
--- a/mastodon/Mastodon.py
+++ b/mastodon/Mastodon.py
@@ -2272,13 +2272,17 @@ class Mastodon:
2272 if url['rel'] == 'next': 2272 if url['rel'] == 'next':
2273 # Be paranoid and extract max_id specifically 2273 # Be paranoid and extract max_id specifically
2274 next_url = url['url'] 2274 next_url = url['url']
2275 matchgroups = re.search(r"max_id=([0-9]*)", next_url) 2275 matchgroups = re.search(r"max_id=([^&]+)", next_url)
2276 2276
2277 if matchgroups: 2277 if matchgroups:
2278 next_params = copy.deepcopy(params) 2278 next_params = copy.deepcopy(params)
2279 next_params['_pagination_method'] = method 2279 next_params['_pagination_method'] = method
2280 next_params['_pagination_endpoint'] = endpoint 2280 next_params['_pagination_endpoint'] = endpoint
2281 next_params['max_id'] = int(matchgroups.group(1)) 2281 max_id = matchgroups.group(1)
2282 if max_id.is_digit():
2283 next_params['max_id'] = int(max_id)
2284 else:
2285 next_params['max_id'] = max_id
2282 if "since_id" in next_params: 2286 if "since_id" in next_params:
2283 del next_params['since_id'] 2287 del next_params['since_id']
2284 response[-1]._pagination_next = next_params 2288 response[-1]._pagination_next = next_params
@@ -2286,13 +2290,17 @@ class Mastodon:
2286 if url['rel'] == 'prev': 2290 if url['rel'] == 'prev':
2287 # Be paranoid and extract since_id specifically 2291 # Be paranoid and extract since_id specifically
2288 prev_url = url['url'] 2292 prev_url = url['url']
2289 matchgroups = re.search(r"since_id=([0-9]*)", prev_url) 2293 matchgroups = re.search(r"since_id=([^&]+)", prev_url)
2290 2294
2291 if matchgroups: 2295 if matchgroups:
2292 prev_params = copy.deepcopy(params) 2296 prev_params = copy.deepcopy(params)
2293 prev_params['_pagination_method'] = method 2297 prev_params['_pagination_method'] = method
2294 prev_params['_pagination_endpoint'] = endpoint 2298 prev_params['_pagination_endpoint'] = endpoint
2295 prev_params['since_id'] = int(matchgroups.group(1)) 2299 since_id = matchgroups.group(1)
2300 if since_id.is_digit():
2301 prev_params['since_id'] = int(since_id)
2302 else:
2303 prev_params['since_id'] = since_id
2296 if "max_id" in prev_params: 2304 if "max_id" in prev_params:
2297 del prev_params['max_id'] 2305 del prev_params['max_id']
2298 response[0]._pagination_prev = prev_params 2306 response[0]._pagination_prev = prev_params
Powered by cgit v1.2.3 (git 2.41.0)