soimort/you-get · error · AssertionError
got the page failed: %s
Error message
got the page failed: %s
What it means
During lrts chapter enumeration the extractor POSTs to http://www.lrts.me/ajax/book/<book>/<page>/<pageSize> and expects JSON with status 'success'. Any other status (failure, auth, rate-limit) triggers AssertionError("got the page failed: %s") with the failing page URL — the chapter list for that page cannot be trusted, so the run aborts.
Source
Thrown at src/you_get/extractors/lrts.py:47
first_page = int(args.first)
page_size = 10
if ('page_size' in args and args.page_size != None):
page_size = int(args.page_size)
last_page = (total_count // page_size) + 1
if ('last' in args and args.last != None):
last_page = int(args.last)
log.i('page size is %s, page from %s to %s' % (page_size, first_page, last_page))
headers = {
'Referer': url
}
items = []
for page in range(first_page, last_page):
page_url = 'http://www.lrts.me/ajax/book/%s/%s/%s' % (book_no, page, page_size)
response_content = json.loads(post_content(page_url, headers))
if response_content['status'] != 'success':
raise AssertionError("got the page failed: %s" % (page_url))
data = response_content['data']['data']
if data:
for i in data:
i['resName'] = parse.unquote(i['resName'])
items.extend(data)
else:
break
headers = {
'Referer': 'http://www.lrts.me/playlist'
}
for item in items:
i_url = 'http://www.lrts.me/ajax/path/4/%s/%s' % (item['fatherResId'], item['resId'])
response_content = json.loads(post_content(i_url, headers))
if response_content['status'] == 'success' and response_content['data']:
item['ok'] = True
item['url'] = response_content['data']
logging.debug('ok')View on GitHub (pinned to 049548f3f3)
Solutions
- Retry after a short delay — transient rate-limit responses commonly clear
- Check the raw POST response (curl -X POST the page_url) to see the actual status/message returned
- Ensure --first/--last/--page_size values stay within the book's page count derived from totalCount
- If the endpoint moved or requires headers, update post_content call (URL/headers) in src/you_get/extractors/lrts.py:47
Example fix
# before
response_content = json.loads(post_content(page_url, headers))
if response_content['status'] != 'success':
raise AssertionError("got the page failed: %s" % (page_url))
# after (break instead of aborting when an out-of-range page comes back empty/failed)
response_content = json.loads(post_content(page_url, headers))
if response_content['status'] != 'success':
if page > 0:
break # past the last page
raise AssertionError("got the page failed: %s" % (page_url)) Defensive patterns
Strategy: retry
Validate before calling
import json
def lrts_page_ok(post_fn, page_url, headers):
return json.loads(post_fn(page_url, headers)).get('status') == 'success' Try / catch
for attempt in range(3):
try:
lrts_download(url, ...)
break
except AssertionError as e:
if 'got the page failed' in str(e) and attempt < 2:
time.sleep(2 ** attempt)
continue
raise Prevention
- Throttle pagination requests to avoid tripping rate limits on lrts.me/ajax
- Keep --first/--last within the computed page range
- Treat a failed page 0 as fatal but a failed later page as end-of-list signal
When it happens
Trigger: Requesting a page index beyond the book's real range (custom --last too large), the server rate-limiting burst POSTs, session/cookie requirements, or the AJAX endpoint schema changing so status is no longer the literal 'success'.
Common situations: User-supplied page_size mismatching the site's expected 10 causing out-of-range pages; hammering pagination in a loop; site adding CSRF/auth to ajax routes.
Related errors
- Server refused to provide download link! (Errno:%s)
- Failed
- not found book number: %s
- not found total count in html
AI-assisted analysis of soimort/you-get@049548f3f3 (2026-08-15).
Data as JSON: /api/errors/2b6246b702a2306b.
Report an issue: GitHub.