lncrawl-sourcelib
Interpreter for declarative light-novel source definitions.
A source definition describes how to read one website as data rather than as code: one YAML document per host, validated against a published schema and interpreted at runtime. RFC-0001 is the normative definition of the format, and it lives here: one grammar version covers the model, the step registry and the hook points together, so an errata and the code honouring it are a single change. Where this package and the RFC disagree, the RFC wins and the package has a bug.
The definitions themselves live in lncrawl/sources, which also carries the guides for writing one.
pip install lncrawl-sourcelib # validate, resolve and transform
pip install lncrawl-sourcelib[fetch] # ...and reach a site
Fetching is an extra. Validating a spec needs no HTTP stack, and the definitions repository's CI and anyone only writing YAML should not have to install a TLS impersonation library.
What it does
Offline, on a checkout of the definitions repository:
sourcelib check # resolve and validate every document
sourcelib check --fixtures # replay recorded pages
sourcelib resolve specs/example.com.yaml # what a spec actually says once merged
sourcelib schema -o schema.json # the JSON Schema editors read
Against a live site, which is what the fetch extra is for:
sourcelib explain <url> # a structural digest, for writing a spec
sourcelib try specs/example.com.yaml <novel-url> # run one spec, field by field
sourcelib record specs/example.com.yaml <novel-url> # save the pages as a fixture
try reports each field and exits non-zero on a failure, so an agent loop needs no output
parsing. --json emits the same thing structurally.
from sourcelib.spec.checks import check_resolved
from sourcelib.spec.resolve import resolve_file
spec = resolve_file("specs/example.com.yaml", root=".")
for problem in check_resolved(spec):
print(problem)
resolve matters more than it looks. A spec can inherit through a chain of bases, so
"what am I actually running" has to be answerable in one command or a deep chain becomes
undebuggable.
Development
uv sync
uv run poe test
uv run poe lint # ruff, then pyright
uv run poe lint-fix
[tool.poe.tasks] in pyproject.toml is the full list.
The CLI runs from the checkout the same way, with the extra when a command reaches a site:
uv run sourcelib check <path-to-sources-checkout>/specs --strict
uv run --extra fetch sourcelib try <path>/specs/example.com.yaml <novel-url>
To work on a spec and the interpreter together, run the CLI from the definitions checkout against this one, so an edit here takes effect without reinstalling:
uv run --with-editable <path-to-this-checkout> --with lncrawl-scraper \
sourcelib try specs/example.com.yaml <novel-url>
The crawler resolves this package as an ordinary dependency. To point it at a checkout instead,
install it into the crawler's environment and then use uv run --no-sync there, because a
plain uv run re-syncs from the lock file and drops the override:
uv pip install -e <path-to-this-checkout>
uv run --no-sync python -m lncrawl ...
Why it is its own package
It is not a feature of the crawler; it is the crawler's next core. Built inside the crawler it would grow references into the code it replaces, and swapping it in would become a rewrite instead of a dependency bump.
This package never imports the crawler, and its CI asserts that. It also means the definitions repository can validate itself with no application in the loop.
Licence
Apache-2.0. The crawler is GPL-3.0-or-later, and Apache-2.0 feeds a GPL-3 application without friction. Nothing here is copied or adapted from the crawler's sources.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lncrawl_sourcelib-0.1.11.tar.gz.
File metadata
- Download URL: lncrawl_sourcelib-0.1.11.tar.gz
- Upload date:
- Size: 325.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dcffba74004d24dc8dde23be3ed796c611869c1bdd3de0743907f3e3bf6a599a
|
|
| MD5 |
8d09df0fb5e97f9ef9458170c69aaf67
|
|
| BLAKE2b-256 |
a0b2a5ebdd4a1f689e13ec5ebaafbfba8e4890bf00a36b40d4d462493652cb24
|
Provenance
The following attestation bundles were made for lncrawl_sourcelib-0.1.11.tar.gz:
Publisher:
publish.yml on lncrawl/sourcelib
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lncrawl_sourcelib-0.1.11.tar.gz -
Subject digest:
dcffba74004d24dc8dde23be3ed796c611869c1bdd3de0743907f3e3bf6a599a - Sigstore transparency entry: 2432333990
- Sigstore integration time:
-
Permalink:
lncrawl/sourcelib@8f3afd1ab5d2536c80bf99c575b3e140546637bb -
Branch / Tag:
refs/heads/main - Owner: https://github.com/lncrawl
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8f3afd1ab5d2536c80bf99c575b3e140546637bb -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file lncrawl_sourcelib-0.1.11-py3-none-any.whl.
File metadata
- Download URL: lncrawl_sourcelib-0.1.11-py3-none-any.whl
- Upload date:
- Size: 97.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c24b144fc5fb898ba2f7207b6a8e55e52103f0bc4c3fab542bed6cd63c6e3ac
|
|
| MD5 |
09bbbc03a81680bf9e599497014cd370
|
|
| BLAKE2b-256 |
3964295d106301e32dc9256416f505ca19c2e55d479ac9f4929098e7b33fccfa
|
Provenance
The following attestation bundles were made for lncrawl_sourcelib-0.1.11-py3-none-any.whl:
Publisher:
publish.yml on lncrawl/sourcelib
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lncrawl_sourcelib-0.1.11-py3-none-any.whl -
Subject digest:
7c24b144fc5fb898ba2f7207b6a8e55e52103f0bc4c3fab542bed6cd63c6e3ac - Sigstore transparency entry: 2432334020
- Sigstore integration time:
-
Permalink:
lncrawl/sourcelib@8f3afd1ab5d2536c80bf99c575b3e140546637bb -
Branch / Tag:
refs/heads/main - Owner: https://github.com/lncrawl
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8f3afd1ab5d2536c80bf99c575b3e140546637bb -
Trigger Event:
workflow_dispatch
-
Statement type: