Metadata-Version: 2.4
Name: libsocial-core
Version: 1.0.0
Summary: Async core shared by the lib.social site SDKs: api.cdnlibs.org client, caching, titles, chapters and catalog
Keywords: lib.social,ranobelib,mangalib,cdnlibs,sdk
Author: LLIJIYAPNIK
Author-email: LLIJIYAPNIK <kas4wot@yandex.ru>
License-Expression: MIT
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Dist: httpx>=0.27
Requires-Dist: pydantic>=2.7
Requires-Dist: rich>=15.0.0
Requires-Python: >=3.11
Project-URL: Homepage, https://github.com/LLIJIYAPNIK/ranobelib-python-sdk
Project-URL: Repository, https://github.com/LLIJIYAPNIK/ranobelib-python-sdk
Project-URL: Issues, https://github.com/LLIJIYAPNIK/ranobelib-python-sdk/issues
Description-Content-Type: text/markdown

# libsocial-core

The site-independent core shared by the async Python SDKs for the lib.social sites
(ranobelib.me, mangalib.me, ...). They all sit on one backend, `api.cdnlibs.org`, and differ
mainly in the `Site-Id` they send and in what a chapter contains.

This package is the shared part:

- `ApiClient`: the `api.cdnlibs.org` client, scoped to a site by a `Site` (id + origin).
  Bounded concurrency, retries with backoff on 429/5xx, and request pacing shared by every
  client in the process that talks to the same host.
- `TitleClient`: one title's metadata, table of contents, translations (branches), chapter
  fetching and whole-title download, with a disk cache.
- `Catalog`: catalog listing/search and the genre/country/status lists, filtered to the site.
- Models (`Title`, `Chapter`, `ChapterBranch`, `Volume`, ...) and exceptions.

It's meant to be used through a site package, which sets the site and its chapter model —
most likely [`ranobelib-python-sdk`](https://pypi.org/project/ranobelib-python-sdk/), not
directly.

```python
from libsocial import Site, TitleClient
from libsocial.models import Chapter, Title, Volume


class MyChapter(Chapter):
    content: str | None = None


class MyVolume(Volume[MyChapter]):
    pass


class MySite(TitleClient[Title, MyChapter, MyVolume]):
    site = Site(id=3, origin="https://ranobelib.me")
    title_model = Title
    chapter_model = MyChapter
    volume_model = MyVolume


async with MySite("https://ranobelib.me/ru/book/6712--high-school-dxd-novel") as client:
    info = await client.get_info()
```

Repository, documentation and the site packages:
<https://github.com/LLIJIYAPNIK/ranobelib-python-sdk>.

MIT licensed.
