mangalib API reference
mangalib-python-sdk (import mangalib): the SDK for mangalib.me, on
the same libsocial-core as ranobelib. Chapters are page images rather than text. What
the API returns for MangaLib is in API notes.
Entry point
mangalib.MangaLib
classMangaLib(
url: str,
*,
cache_dir: str | Path | None = None,
cache_ttl: float | None = None,
verbosity: Verbosity = False,
headers: Mapping[str, str] | None = None,
) TitleClient[Title, Chapter, Volume]
Entry point for interacting with a single mangalib.me title.
Closed chapters (paid, or in early access) can't be read without an account, which the
SDK doesn't support: get_chapter() raises AuthRequiredError for one, while
download_title() and estimate_title_size() leave out every translation the
chapter list marks as closed (ChapterBranch.is_open) — a chapter with only closed
ones is skipped, and translation_index counts the open translations only.
slug_url
attributepropertyslug_url: strThe title's {id}--{slug} identifier.
aclose
methodasyncaclose() -> NoneClose the underlying HTTP clients.
SOURCE ↗chapter_size
methodasyncchapter_size(
chapter: Chapter,
*,
server: str | None = None,
concurrency: int = DEFAULT_IMAGE_CONCURRENCY,
) -> intThe exact size in bytes of a fetched chapter's page images, without downloading them.
One HEAD request per page: the image servers answer it with the file's exact
Content-Length (see docs/api-notes.md, "MangaLib"), so this costs requests, not
image traffic. Servers are tried, paced and retried as in download_page().
| Name | Type | Description | Default |
|---|---|---|---|
chapter | Chapter | A chapter fetched with | |
server | str | None | The | None |
concurrency | int | How many pages to ask about at once. | DEFAULT_IMAGE_CONCURRENCY |
| Type | Description |
|---|---|
ValueError | If |
PageDownloadError | If no server gave a page's size. |
download_page
methodasyncdownload_page(page: Page, *, server: str | None = None) -> bytesDownload one page image.
Tries server first, if given, then images.DEFAULT_SERVER_ORDER (compress,
download, main, secondary). compress comes first because it's the one
that served full-size pages when checked; main/secondary sit behind a
DDoS-Guard check scripts don't pass (see docs/api-notes.md, "MangaLib"). Requests to
an image host are paced across the process (images.DEFAULT_IMAGE_REQUEST_DELAY),
and a 429, a 5xx or a network error is retried with backoff on the same server before
moving on to the next one; a refusal (another 4xx, a response that isn't an image)
moves on at once.
| Name | Type | Description | Default |
|---|---|---|---|
page | Page | The page, from a fetched chapter's | |
server | str | None | The | None |
| Type | Description |
|---|---|
bytes | The image file's bytes, as the server sent them. |
| Type | Description |
|---|---|
ValueError | If |
PageDownloadError | If no server served the image. |
download_pages
methodasyncdownload_pages(
chapter: Chapter,
*,
server: str | None = None,
concurrency: int = DEFAULT_IMAGE_CONCURRENCY,
) -> list[bytes]Download every page image of a fetched chapter, in reading order.
Each page as download_page() does it, up to concurrency at a time.
| Name | Type | Description | Default |
|---|---|---|---|
chapter | Chapter | A chapter fetched with | |
server | str | None | The | None |
concurrency | int | How many pages to download at once. The pacing per image host applies on top, so more than a few mostly adds waiting. | DEFAULT_IMAGE_CONCURRENCY |
| Type | Description |
|---|---|
ValueError | If |
PageDownloadError | If a page couldn't be downloaded from any server; the other downloads still in flight are cancelled. |
download_title
methodasyncdownload_title(
*,
branch_id: int | None = None,
translation_index: int | None = None,
chapter_delay: float = 0.0,
on_chapter: Callable[[int, int], None] | None = None,
max_rate_limit_retries: int = DEFAULT_RATE_LIMIT_RETRIES,
) -> list[VolumeT]Download every chapter of the title, across all its volumes.
Fetches the chapter list once, then every chapter's content, sequentially, in the
API's own order — same pacing/retry/backoff as any other chapter fetch (see
ApiClient), plus chapter_delay on top if given.
Resolving translations is checked for the whole title up front, not chapter by
chapter: if any chapters have more than one translation, this fetches nothing and
raises MultipleTitleTranslationsError listing all of them at once (unless
branch_id or translation_index resolves every one of them), rather than
failing partway through a long download on the first ambiguous chapter.
A long title's sequential download can outlast ApiClient's own retry budget for
429s (tuned for a single one-off request, not hundreds/thousands of sequential
fetches — see docs/api-notes.md). On top of that, each chapter fetch that still comes
back rate-limited is retried again here, up to max_rate_limit_retries times, with
its own (coarser) backoff. If a chapter fetch still fails after that — from rate
limiting or anything else — the chapters already downloaded are not discarded: they're
attached to a raised DownloadTitleInterruptedError instead of being lost.
| Name | Type | Description | Default |
|---|---|---|---|
branch_id | int | None | Translation to use for every chapter that has more than one — same
meaning as | None |
translation_index | int | None | Alternative to | None |
chapter_delay | float | Extra delay, in seconds, after fetching each chapter, on top of
| 0.0 |
on_chapter | Callable[[int, int], None] | None | Called with | None |
max_rate_limit_retries | int | How many extra times to retry a single chapter fetch that
comes back rate-limited, on top of | DEFAULT_RATE_LIMIT_RETRIES |
| Type | Description |
|---|---|
ValueError | If both |
MultipleTitleTranslationsError | If the title has one or more chapters with more
than one translation that |
DownloadTitleInterruptedError | If fetching a chapter fails unrecoverably partway through the download — carries every chapter already fetched. |
estimate_title_size
methodasyncestimate_title_size(
*,
sample_size: int = DEFAULT_SAMPLE_SIZE,
branch_id: int | None = None,
translation_index: int | None = None,
server: str | None = None,
concurrency: int = DEFAULT_IMAGE_CONCURRENCY,
) -> intEstimate the whole title's page images in bytes, from a sample of its chapters.
Fetches the chapter list, then up to sample_size chapters spread evenly across
the title (their page lists, cached like any chapter fetch), sizes their pages
exactly with chapter_size() — HEAD requests, no image traffic — and
extrapolates the sample's average across every chapter download_title() would
download. The chapter list has no page counts, so the sample is what both the page
count and the page weight are estimated from.
| Name | Type | Description | Default |
|---|---|---|---|
sample_size | int | How many chapters to sample — clamped to how many there are. | DEFAULT_SAMPLE_SIZE |
branch_id | int | None | Same as | None |
translation_index | int | None | Same as | None |
server | str | None | The | None |
concurrency | int | How many pages to ask about at once. | DEFAULT_IMAGE_CONCURRENCY |
| Type | Description |
|---|---|
int | The estimated size in bytes, or |
int | translation that |
| Type | Description |
|---|---|
ValueError | If both |
export
methodasyncexport(
chapters: Chapter | Volume | Sequence[Chapter | Volume],
*,
fmt: str,
path: str | Path,
server: str | None = None,
concurrency: int = DEFAULT_IMAGE_CONCURRENCY,
on_chapter: Callable[[int, int], None] | None = None,
) -> PathExport fetched chapters to one file, downloading their page images as it goes.
One chapter, several, a volume, several, or a whole title — download_title()'s
result — all go in: volumes are expanded into their chapters, in order. Pages are
downloaded chapter by chapter (as download_pages() does it) and written into the
file, which only appears at path once complete.
| Name | Type | Description | Default |
|---|---|---|---|
chapters | Chapter | Volume | Sequence[Chapter | Volume] | Fetched chapters and/or volumes, in the order they should appear. | |
fmt | str | Export format — a key of | |
path | str | Path | Where to write the exported file. | |
server | str | None | The | None |
concurrency | int | How many pages to download at once. | DEFAULT_IMAGE_CONCURRENCY |
on_chapter | Callable[[int, int], None] | None | Called with | None |
| Type | Description |
|---|---|
ValueError | If |
PageDownloadError | If a page couldn't be downloaded from any server. Nothing is
written to |
get_chapter
methodasyncget_chapter(
volume: int,
number: str,
*,
branch_id: int | None = None,
refresh: bool = False,
) -> ChapterTFetch a single chapter, including its content.
When a chapter has more than one team's translation and branch_id isn't given,
this raises MultipleTranslationsError rather than guessing — see
get_translations() and docs/api-notes.md for why the API's own default (when
branch_id is omitted) isn't relied on. Doing this check costs an extra request
to fetch the chapter list, only when branch_id isn't already given.
| Name | Type | Description | Default |
|---|---|---|---|
volume | int | The chapter's volume number. | |
number | str | The chapter number, as returned by the API — may contain a decimal
(e.g. | |
branch_id | int | None | Which translation to fetch, as returned by | None |
refresh | bool | Bypass the disk cache and re-fetch from the API even if a cached response is on hand. | False |
| Type | Description |
|---|---|
MultipleTranslationsError | If the chapter has more than one translation and
|
get_chapters
methodasyncget_chapters(chapters: list[tuple[int, str]]) -> list[ChapterT]Fetch several chapters, including their content.
Fetches the chapter list once, shared across all requested chapters (also used to
detect chapters with more than one translation — see get_chapter), then each
chapter individually and sequentially, in the order given.
| Name | Type | Description |
|---|---|---|
chapters | list[tuple[int, str]] | A list of |
| Type | Description |
|---|---|
ChapterNotFoundError | If any requested chapter doesn't exist. |
MultipleTranslationsError | If any requested chapter has more than one translation. |
get_info
methodasyncget_info(*, refresh: bool = False) -> TitleTFetch title metadata: names, cover, summary, genres, tags, authors, teams.
| Name | Type | Description | Default |
|---|---|---|---|
refresh | bool | Bypass the disk cache and re-fetch from the API even if a cached response is on hand. | False |
get_table_of_contents
methodasyncget_table_of_contents(*, refresh: bool = False) -> list[VolumeT]Fetch the title's volumes and chapter names/numbers, without chapter content.
| Name | Type | Description | Default |
|---|---|---|---|
refresh | bool | Bypass the disk cache and re-fetch from the API even if a cached response is on hand — needed to pick up newly published chapters, since otherwise the cached chapter list would keep being reused. | False |
get_translations
methodasyncget_translations(volume: int, number: str) -> list[ChapterBranch]Fetch the available translations (branches) for a chapter.
Each one says whether it's open to read without an account (ChapterBranch.is_open).
| Name | Type | Description |
|---|---|---|
volume | int | The chapter's volume number. |
number | str | The chapter number. |
| Type | Description |
|---|---|
ChapterNotFoundError | If no chapter exists for this volume/number. |
get_volume
methodasyncget_volume(volume: int) -> VolumeTFetch a whole volume: all its chapters, each including content.
The API has no bulk "volume content" endpoint (see docs/api-notes.md), so this fetches the chapter list once to find which numbers belong to the volume, then fetches each of those chapters individually and sequentially.
| Name | Type | Description |
|---|---|---|
volume | int | The volume number. |
| Type | Description |
|---|---|
VolumeNotFoundError | If the title has no chapters for this volume. |
MultipleTranslationsError | If any of the volume's chapters has more than one translation. |
get_volumes
methodasyncget_volumes(volumes: list[int]) -> list[VolumeT]Fetch several whole volumes, each including chapter content.
Fetches the chapter list once, shared across all requested volumes, then each
chapter individually and sequentially — same approach as get_volume, applied
to more than one volume without re-fetching the chapter list per volume.
| Name | Type | Description |
|---|---|---|
volumes | list[int] | The volume numbers to fetch. |
| Type | Description |
|---|---|
VolumeNotFoundError | If the title has no chapters for one of the volumes. |
MultipleTranslationsError | If any of the volumes' chapters has more than one translation. |
list_image_servers
methodasynclist_image_servers(*, refresh: bool = False) -> list[ImageServer]List the servers mangalib.me serves page images from.
Not every one serves pages to a script: see download_page() for which are tried.
| Name | Type | Description | Default |
|---|---|---|---|
refresh | bool | Bypass the disk cache and re-fetch from the API. | False |
volume_size
methodasyncvolume_size(
volume: Volume,
*,
server: str | None = None,
concurrency: int = DEFAULT_IMAGE_CONCURRENCY,
) -> intThe exact size in bytes of a fetched volume's page images — chapter_size() summed.
| Name | Type | Description | Default |
|---|---|---|---|
volume | Volume | A volume fetched with | |
server | str | None | The | None |
concurrency | int | How many pages to ask about at once. | DEFAULT_IMAGE_CONCURRENCY |
| Type | Description |
|---|---|
ValueError | See |
PageDownloadError | If no server gave a page's size. |
mangalib.Catalog
classCatalog(
*,
cache_dir: str | Path | None = None,
cache_ttl: float | None = None,
headers: Mapping[str, str] | None = None,
)Entry point for listing/searching the mangalib.me catalog.
Lists titles (list_titles()) and the filter options for them (list_genres(),
list_countries() — on mangalib.me these are the title types: manga, manhwa, manhua,
... — and list_statuses()), each filtered to mangalib.me.
aclose
methodasyncaclose() -> NoneClose the underlying HTTP client.
SOURCE ↗list_countries
methodasynclist_countries(*, refresh: bool = False) -> list[Country]Fetch the full list of catalog countries (id → name), for use as filter options
with list_titles(countries=...).
Mirrors list_genres() exactly, down to the network-wide, not-site-scoped shape
of the underlying endpoint (GET /api/constants?fields[]=types — the API's own
name for what this SDK calls "country" is "type", see docs/api-notes.md and
Country's docstring). This filters that down to entries tagged for site before
returning, same as list_genres() does for genres.
| Name | Type | Description | Default |
|---|---|---|---|
refresh | bool | Bypass the disk cache and re-fetch from the API even if the country list was already cached. | False |
| Type | Description |
|---|---|
list[Country] | Every |
list_genres
methodasynclist_genres(*, refresh: bool = False) -> list[Genre]Fetch the full list of catalog genres (id → name), for use as filter options
with list_titles(genres=[...]).
The underlying endpoint (GET /api/constants?fields[]=genres) has no site-scoping
parameter — it returns the full genre list shared across the whole lib.social
network in one shot, each tagged with the site ids it applies to (see
docs/api-notes.md). This filters that down to genres tagged for site before
returning, so callers don't get filter options that could never match any of the
site's titles (e.g. "Детское", tagged only for site 5, on ranobelib.me).
| Name | Type | Description | Default |
|---|---|---|---|
refresh | bool | Bypass the disk cache and re-fetch from the API even if the genre list was already cached. | False |
| Type | Description |
|---|---|
list[Genre] | Every |
list_statuses
methodasynclist_statuses(*, refresh: bool = False) -> list[Label]Fetch the full list of title statuses (id → label), for use as filter options
with list_titles(statuses=...).
Mirrors list_genres()/list_countries(): the underlying endpoint
(GET /api/constants?fields[]=status) isn't site-scoped, so entries not tagged for
site are dropped before returning (see docs/api-notes.md). Returns the same
Label model as Title.status, so a title's status can be compared against
these directly.
| Name | Type | Description | Default |
|---|---|---|---|
refresh | bool | Bypass the disk cache and re-fetch from the API even if the status list was already cached. | False |
| Type | Description |
|---|---|
list[Label] | Every status ( |
list_titles
methodasynclist_titles(
*,
page: int = 1,
per_page: int = 30,
query: str | None = None,
genres: list[int] | None = None,
tags: list[int] | None = None,
statuses: list[int] | None = None,
countries: list[int] | None = None,
min_chapters: int | None = None,
max_chapters: int | None = None,
sort: str = DEFAULT_SORT,
refresh: bool = False,
) -> CatalogPage[TitleT]Fetch one page of catalog listing/search results.
| Name | Type | Description | Default |
|---|---|---|---|
page | int | 1-based page number. | 1 |
per_page | int | How many titles per page. Must be between | 30 |
query | str | None | Free-text search term, matched against name/rus_name/eng_name. | None |
genres | list[int] | None | Genre ids to filter by. A title must have all of them, not just one
(AND, not OR — see docs/api-notes.md). Not validated against | None |
tags | list[int] | None |
| None |
statuses | list[int] | None |
| None |
countries | list[int] | None |
| None |
min_chapters | int | None | Only titles with at least this many chapters (inclusive). Counts
the same number as | None |
max_chapters | int | None | Only titles with at most this many chapters (inclusive). | None |
sort | str | Sort order. Despite the name, this is sent as the API's | DEFAULT_SORT |
refresh | bool | Bypass the disk cache and re-fetch from the API even if this exact combination of parameters was already cached. | False |
| Type | Description |
|---|---|
CatalogPage[TitleT] | A |
| Type | Description |
|---|---|
ValueError | If |
Models
mangalib.CatalogPage
classCatalogPage() _core.CatalogPage[Title]
One page of catalog listing/search results, as returned by Catalog.list_titles().
items reuses Title as-is: the fields a listing doesn't send (genres,
summary, chapter_count, last_chapter_at, ...) come back at their defaults.
mangalib.Title
classTitle() _core.Title
Metadata for a single title (manga, manhwa, manhua, comic, ...).
SOURCE ↗base_names
attributepropertybase_names: list[str]The title's names without a trailing format marker.
rus_name, eng_name, name and other_names, in that order, each with a
bare format marker at the end removed — "Return of the Runebound Professor (webtoon)" → "Return of the Runebound Professor", likewise (Manhwa),
(Манга), [Вебтун], (Комикс), ... Unlike ranobelib.me's (Новелла),
mangalib.me doesn't append one itself: only a few dozen names have one, typed by
hand. Other bracketed tails — (Doujinshi), (Colored), (перезапуск), a
year, (манга-версия) — tell titles apart and are kept. Whitespace is trimmed;
empty names and duplicates (keeping the first) are dropped. Nothing else is
normalized (case, punctuation): that's up to whatever compares the names.
The original fields are left as they are. On Catalog.list_titles() items
other_names is empty (the listing doesn't return it), so it contributes nothing.
chapter_count
attributechapter_count: int | None = NoneNumber of uploaded chapters. Only TitleClient.get_info() fills it in: the catalog
listing endpoint doesn't return it (see docs/api-notes.md), so it's None on
Catalog.list_titles() items.
last_chapter_at
attributelast_chapter_at: datetime | None = Field(default=None, alias='last_item_at')When the most recent chapter was published — the value the catalog's
sort="last_chapter_at" orders by. Only TitleClient.get_info() fills it in: the
catalog listing endpoint doesn't return it (see docs/api-notes.md), so it's None on
Catalog.list_titles() items, and on a title with no chapters yet.
mangalib.Chapter
classChapter() _core.Chapter
A chapter: volume, number, name, available translations, and optionally its pages.
index/item_number/branches_count/branches come from the chapter-list
endpoint (see MangaLib.get_table_of_contents()) and are None/empty when a
Chapter instead comes from fetching a single chapter, which has a different response
shape. pages is the reverse: only filled in by fetching the chapter
(MangaLib.get_chapter() and friends), in reading order.
restricted_view
attributerestricted_view: RestrictedView | None = NoneSet on a fetched chapter whose translation is (or was) paid or in early access.
SOURCE ↗teams
attributeteams: list[Team] = Field(default_factory=list)The teams credited for the fetched translation (empty on the chapter list's entries,
where each of branches has its own).
mangalib.Page
classPage() BaseModel
One page image of a chapter.
url is relative to an image server (see ImageServer and mangalib.page_url()):
the API doesn't say which server a page is on, every server serves every page.
image
attributeimage: strThe image's file name. Its extension isn't reliable as a format: the compress
server sends a JPEG for a .png name (see docs/api-notes.md).
number
attributenumber: int = Field(alias='slug')1-based position in the chapter — the API's slug.
url
attributeurl: strPath of the image on an image server, e.g. "//manga/{slug}/chapters/1-1/00.jpg".
mangalib.ChapterBranch
classChapterBranch()A single team's (or solo uploader's) translation of a chapter.
A chapter has more than one branch when several teams have translated it
independently; see Chapter.branches_count.
is_open
attributepropertyis_open: boolWhether this translation can be read without an account.
False means MangaLib.get_chapter() raises AuthRequiredError for it.
restricted_view
attributerestricted_view: RestrictedView | None = NoneSet when this translation is paid or in early access — see is_open.
mangalib.RestrictedView
classRestrictedView() BaseModel
Access to a paid or early-access chapter translation.
Present only on translations that are (or were) restricted. Logging in isn't supported
by the SDK, so a closed one can't be read through it — see ChapterBranch.is_open.
expired_at
attributeexpired_at: datetime | None = NoneWhen early access ends and the chapter opens for everyone; None for a chapter
that stays paid.
is_open
attributeis_open: boolWhether anyone can read it now, without an account.
SOURCE ↗price
attributeprice: int | None = NoneThe price the site asks, in its own currency. The chapter list leaves it None;
fetching the chapter fills it in.
mangalib.ImageServer
classImageServer() BaseModel
A server page images are downloaded from (GET /constants?fields[]=imageServers).
A page's full URL is the server's url followed by Page.url.
id
attributeid: strThe API's name for it: "main", "secondary", "compress", "download",
"crop" (see docs/api-notes.md for which of them actually serve pages).
mangalib.Volume
classVolume()A volume: its number and the chapters it contains, in title order.
SOURCE ↗Page images
mangalib.page_url
functionpage_url(page: Page, server: ImageServer) -> strThe full URL of page's image on server.
Page.url starts with //; the slashes are collapsed to one (both forms serve the
same image, checked on every server).
mangalib.images.DEFAULT_SERVER_ORDER
attributeDEFAULT_SERVER_ORDER = ('compress', 'download', 'main', 'secondary')Image servers tried, in this order, when no server is chosen. crop isn't one of
them: it serves 310×450 previews, not the page itself — choose it explicitly if that's what
you want.
mangalib.images.DEFAULT_IMAGE_CONCURRENCY
attributeDEFAULT_IMAGE_CONCURRENCY = 5Page requests in flight at once by default (download_pages(), export(), size
methods).
mangalib.images.DEFAULT_IMAGE_REQUEST_DELAY
attributeDEFAULT_IMAGE_REQUEST_DELAY = 0.2Minimum time, in seconds, between the starts of two requests to the same image host, across every client in the process. With five at once, 300 full-size pages went through without a single 429 when checked; much denser request rates got DDoS-Guard's 429.
SOURCE ↗Exporters
Not re-exported from the top-level mangalib package — import from mangalib.exporters.
A new format is a new module in mangalib/exporters/ implementing Exporter, decorated
with @register. "pdf" is registered only when the pdf extra (img2pdf) is installed.
mangalib.exporters.Exporter
classExporter() Protocol
Renders a title's chapters, as page images, to a single file in some format.
SOURCE ↗format
attributeformat: strThe registry key this exporter is selected by, e.g. "cbz".
export
methodasyncexport(
title: Title,
chapters: list[Chapter],
output_path: Path,
*,
fetch_pages: FetchPages,
on_chapter: Callable[[], None] | None = None,
) -> PathWrite chapters (in the given order) to output_path.
| Name | Type | Description | Default |
|---|---|---|---|
title | Title | The chapters' parent title, for metadata (name, authors, ...). | |
chapters | list[Chapter] | The chapters to include, in the order they should appear — fetched
ones, with | |
output_path | Path | Where to write the exported file. | |
fetch_pages | FetchPages | Downloads one chapter's page images. The exporter calls it once per chapter, in order, so it never holds more than it has to in memory. | |
on_chapter | Callable[[], None] | None | Called once per chapter written, if given — drives
| None |
| Type | Description |
|---|---|
Path |
|
mangalib.exporters.register
functionregister(exporter: ExporterT) -> ExporterTClass decorator: register exporter under its format key.
Registered exporters, keyed by Exporter.format.
mangalib.exporters.cbz.CbzExporter
classCbzExporter()Writes chapters as one CBZ: every page image in reading order, plus ComicInfo.xml.
Pages are stored without recompression (they're JPEGs already), named by their position
in the book with zero padding (0001.jpg, 0002.jpg, ...) so every reader sorts
them right, with the extension taken from the image's bytes. Where each chapter starts is
recorded as a Bookmark on its first page in ComicInfo.xml (schema 2.1, as read by
Komga, Kavita, ComicRack and others), which also carries the title's metadata.
mangalib.exporters.pdf.PdfExporter
classPdfExporter()Writes chapters as one PDF: a page per page image, an outline entry per chapter.
JPEGs are embedded as they are, without recompression (img2pdf), so the file is about
the size of the images. Each PDF page is the image's own size; a tall webtoon strip
beyond the PDF page-size limit is scaled with /UserUnit rather than cut. The PDF is
assembled in memory, so for a whole long title CBZ is the lighter choice.
Exceptions
MangaLibError is the base class of every error the SDK raises, the same class as
ranobelib.RanobeLibError; the others are shared with ranobelib too, except
PageDownloadError.
mangalib.PageDownloadError
classPageDownloadError(failures: list[tuple[str, str]])Raised when a page image couldn't be downloaded from any image server.
Each server is tried in turn (see MangaLib.download_page()); this is raised only
after the last one failed too.
| Name | Type | Description |
|---|---|---|
failures |
|
mangalib.AuthRequiredError
classAuthRequiredError(url: str)Raised when the requested content requires authorization (paid or early access).
| Name | Type | Description |
|---|---|---|
url | The request URL that returned 403. |
mangalib.ChapterNotFoundError
classChapterNotFoundError(slug_url: str, *, volume: str, number: str)Raised when a chapter cannot be found for a given volume/number.
| Name | Type | Description |
|---|---|---|
slug_url | The title's | |
volume | The volume number that was requested. | |
number | The chapter number that was requested. |
mangalib.VolumeNotFoundError
classVolumeNotFoundError(slug_url: str, *, volume: str)Raised when a title has no chapters for a given volume number.
| Name | Type | Description |
|---|---|---|
slug_url | The title's | |
volume | The volume number that was requested. |
mangalib.MultipleTranslationsError
classMultipleTranslationsError(
slug_url: str,
*,
volume: str,
number: str,
branches: list[ChapterBranch],
)Raised when a chapter has more than one team's translation and none was selected.
The SDK does not guess a default: the API's own default when branch_id is omitted
is not simply the first branch listed, and the actual rule it uses isn't documented
(see docs/api-notes.md) — returning it silently would be unpredictable. Call
TitleClient.get_translations() to list the available branches, then pass one's
branch_id explicitly.
| Name | Type | Description |
|---|---|---|
slug_url | The title's | |
volume | The chapter's volume number. | |
number | The chapter number. | |
branches | The chapter's available translations, as returned by
|
mangalib.MultipleTitleTranslationsError
classMultipleTitleTranslationsError(
slug_url: str,
*,
chapters: list[AmbiguousChapter],
)Raised by download_title() when one or more chapters have an unresolved translation.
Unlike MultipleTranslationsError (one chapter), this can list several: a title-wide
bulk download checks every chapter up front rather than stopping at the first ambiguous
one, so a caller doesn't have to fix one chapter, rerun, hit the next, and rerun again.
Pass branch_id or translation_index to download_title() to resolve them, or
fetch the listed chapters individually with get_chapter(..., branch_id=...).
| Name | Type | Description |
|---|---|---|
slug_url | The title's | |
chapters | The ambiguous chapters and their available translations. |
mangalib.DownloadTitleInterruptedError
classDownloadTitleInterruptedError(
slug_url: str,
*,
volumes: Sequence[Volume[Any]],
completed: int,
total: int,
)Raised by download_title() when a chapter fetch fails unrecoverably partway through.
download_title() fetches hundreds-to-thousands of chapters sequentially for a long
title, which can outlast even the extra, bulk-specific rate-limit retry budget described
in download_title()'s max_rate_limit_retries — or hit some other unrecoverable
error (e.g. AuthRequiredError on a chapter that turns out to need a paywall/auth
token). Rather than letting that error propagate on its own and silently discard every
chapter already fetched, it's wrapped in this exception instead, carrying what was
already downloaded — so a caller can keep that partial result, or simply call
download_title() again: the SDK's disk cache means already-fetched chapters aren't
re-requested, so a retry resumes close to where this one stopped rather than restarting
the whole title. See docs/api-notes.md's "Rate limiting и retry" section and issue #41.
| Name | Type | Description |
|---|---|---|
slug_url | The title's | |
volumes | list[Volume[Any]] | Chapters fetched before the failure, grouped into volumes the same way a
successful |
completed | How many chapters were fetched before the failure. | |
total | How many chapters |
Cache maintenance
mangalib.cache_stats
functioncache_stats(cache_dir: str | Path = DEFAULT_CACHE_DIR) -> CacheStatsCount the entries in an SDK disk cache and their total size on disk.
| Name | Type | Description | Default |
|---|---|---|---|
cache_dir | str | Path | The cache directory — the same | DEFAULT_CACHE_DIR |
| Type | Description |
|---|---|
CacheStats | The number of entries and their total size in bytes. A missing directory is an empty |
CacheStats | cache, |
mangalib.clear_cache
functionclear_cache(
cache_dir: str | Path = DEFAULT_CACHE_DIR,
*,
older_than: float | None = None,
) -> CacheStatsRemove entries from an SDK disk cache.
Only files the cache itself writes are removed — anything else in the directory, and the directory itself, is left alone.
| Name | Type | Description | Default |
|---|---|---|---|
cache_dir | str | Path | The cache directory — see | DEFAULT_CACHE_DIR |
older_than | float | None | If given, only remove entries written more than this many seconds ago,
plus any corrupted entry. | None |
| Type | Description |
|---|---|
CacheStats | The number of entries removed and the bytes they took. |
| Type | Description |
|---|---|
ValueError | If |
mangalib.CacheStats
classCacheStats(entries: int, bytes: int)How many cache entries there are (or were removed), and their total size on disk.
SOURCE ↗