soimort/you-get · error · AssertionError

not found book number

Error message

not found book number: %s

What it means

The lrts.me audiobook extractor requires the URL itself to contain '/book/<digits>' — it parses the book number straight out of the URL with re.search(r"/book/(\d+)", url). When that pattern misses, it raises AssertionError('not found book number: %s') because there is no other way to address the book's AJAX pagination API.

Solutions

  1. Navigate to the audiobook's detail page on lrts.me and copy the URL of the form http://www.lrts.me/book/12345
  2. Verify the URL contains '/book/' followed by only digits (no query junk glued to the number)
  3. If the site changed its path scheme, update the regex r"/book/(\d+)" in src/you_get/extractors/lrts.py:15 to the new shape

Example fix

# before
lrts_download('http://www.lrts.me/playlist')  # AssertionError: not found book number

# after
lrts_download('http://www.lrts.me/book/12345')
Defensive patterns

Strategy: validation

Validate before calling

import re

def is_lrts_book_url(url):
    return re.search(r'/book/\d+', url) is not None

Try / catch

try:
    lrts_download(url, ...)
except AssertionError as e:
    if 'not found book number' in str(e):
        print('URL must be http://www.lrts.me/book/<digits>')
    else:
        raise

Prevention

When it happens

Trigger: Calling lrts_download with any URL lacking a /book/NNN path segment, e.g. 'http://www.lrts.me/book/' (no id), 'http://www.lrts.me/playlist', a chapter URL with a different path shape, or a URL where the id is non-numeric.

Common situations: Copying a listing/search URL instead of the book detail page; site restructuring paths (e.g. /audio/book/123) so the regex no longer matches; passing an already-parsed API URL.

Related errors


AI-assisted analysis of soimort/you-get@049548f3f3 (2026-08-15). Data as JSON: /api/errors/c85edf16d2608990. Report an issue: GitHub.

Appendix: source

Thrown at src/you_get/extractors/lrts.py:15

#!/usr/bin/env python

__all__ = ['lrts_download']

import logging
from ..common import *
from ..util import log, term

def lrts_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
    html = get_html(url)
    args = kwargs.get('args')
    if not args: args = {}
    matched = re.search(r"/book/(\d+)", url)
    if not matched:
        raise AssertionError("not found book number: %s" % url)
    book_no = matched.group(1)
    book_title = book_no
    matched = re.search(r"<title>([^-]*)[-](.*)[,](.*)</title>", html)
    if matched:
        book_title = matched.group(1)

    matched = re.search(r"var totalCount='(\d+)'", html)
    if not matched:
        raise AssertionError("not found total count in html")
    total_count = int(matched.group(1))
    log.i('%s total: %s' % (book_title, total_count))
    first_page = 0
    if ('first' in args and args.first!= None):
        first_page = int(args.first)

    page_size = 10
    if ('page_size' in args and args.page_size != None):
        page_size = int(args.page_size)

View on GitHub (pinned to 049548f3f3)