ranobelib-python-sdk 0.4.1__tar.gz → 0.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (21) hide show
  1. {ranobelib_python_sdk-0.4.1 → ranobelib_python_sdk-0.5.0}/PKG-INFO +1 -1
  2. {ranobelib_python_sdk-0.4.1 → ranobelib_python_sdk-0.5.0}/pyproject.toml +1 -1
  3. {ranobelib_python_sdk-0.4.1 → ranobelib_python_sdk-0.5.0}/pyproject.toml.orig +1 -1
  4. {ranobelib_python_sdk-0.4.1 → ranobelib_python_sdk-0.5.0}/src/ranobelib/sdk.py +13 -2
  5. {ranobelib_python_sdk-0.4.1 → ranobelib_python_sdk-0.5.0}/README.md +0 -0
  6. {ranobelib_python_sdk-0.4.1 → ranobelib_python_sdk-0.5.0}/src/ranobelib/__init__.py +0 -0
  7. {ranobelib_python_sdk-0.4.1 → ranobelib_python_sdk-0.5.0}/src/ranobelib/cache.py +0 -0
  8. {ranobelib_python_sdk-0.4.1 → ranobelib_python_sdk-0.5.0}/src/ranobelib/client.py +0 -0
  9. {ranobelib_python_sdk-0.4.1 → ranobelib_python_sdk-0.5.0}/src/ranobelib/console.py +0 -0
  10. {ranobelib_python_sdk-0.4.1 → ranobelib_python_sdk-0.5.0}/src/ranobelib/exceptions.py +0 -0
  11. {ranobelib_python_sdk-0.4.1 → ranobelib_python_sdk-0.5.0}/src/ranobelib/exporters/__init__.py +0 -0
  12. {ranobelib_python_sdk-0.4.1 → ranobelib_python_sdk-0.5.0}/src/ranobelib/exporters/_illustrations.py +0 -0
  13. {ranobelib_python_sdk-0.4.1 → ranobelib_python_sdk-0.5.0}/src/ranobelib/exporters/_shared.py +0 -0
  14. {ranobelib_python_sdk-0.4.1 → ranobelib_python_sdk-0.5.0}/src/ranobelib/exporters/epub.py +0 -0
  15. {ranobelib_python_sdk-0.4.1 → ranobelib_python_sdk-0.5.0}/src/ranobelib/exporters/fb2.py +0 -0
  16. {ranobelib_python_sdk-0.4.1 → ranobelib_python_sdk-0.5.0}/src/ranobelib/exporters/pdf.py +0 -0
  17. {ranobelib_python_sdk-0.4.1 → ranobelib_python_sdk-0.5.0}/src/ranobelib/exporters/txt.py +0 -0
  18. {ranobelib_python_sdk-0.4.1 → ranobelib_python_sdk-0.5.0}/src/ranobelib/models.py +0 -0
  19. {ranobelib_python_sdk-0.4.1 → ranobelib_python_sdk-0.5.0}/src/ranobelib/numbering.py +0 -0
  20. {ranobelib_python_sdk-0.4.1 → ranobelib_python_sdk-0.5.0}/src/ranobelib/py.typed +0 -0
  21. {ranobelib_python_sdk-0.4.1 → ranobelib_python_sdk-0.5.0}/src/ranobelib/sizing.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ranobelib-python-sdk
3
- Version: 0.4.1
3
+ Version: 0.5.0
4
4
  Summary: Async Python SDK for ranobelib.me: title metadata, chapter/volume downloads, and export to epub/fb2/txt/pdf
5
5
  Keywords: ranobelib,ranobe,novel,webnovel,epub,fb2,sdk
6
6
  Author: LLIJIYAPNIK
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "ranobelib-python-sdk"
3
- version = "0.4.1"
3
+ version = "0.5.0"
4
4
  description = "Async Python SDK for ranobelib.me: title metadata, chapter/volume downloads, and export to epub/fb2/txt/pdf"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "ranobelib-python-sdk"
3
- version = "0.4.1"
3
+ version = "0.5.0"
4
4
  description = "Async Python SDK for ranobelib.me: title metadata, chapter/volume downloads, and export to epub/fb2/txt/pdf"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -3,6 +3,7 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import asyncio
6
+ from collections.abc import Callable
6
7
  from pathlib import Path
7
8
  from types import TracebackType
8
9
  from typing import Any, Self
@@ -233,6 +234,7 @@ class RanobeLib:
233
234
  branch_id: int | None = None,
234
235
  translation_index: int | None = None,
235
236
  chapter_delay: float = 0.0,
237
+ on_chapter: Callable[[int, int], None] | None = None,
236
238
  ) -> list[Volume]:
237
239
  """Download every chapter of the title, across all its volumes.
238
240
 
@@ -258,6 +260,12 @@ class RanobeLib:
258
260
  chapter_delay: Extra delay, in seconds, after fetching each chapter, on top of
259
261
  ``ApiClient``'s own per-request pacing — to be gentler on the API during a
260
262
  large bulk download. Defaults to no extra delay.
263
+ on_chapter: Called with ``(completed, total)`` after each chapter is fetched, if
264
+ given — a programmatic progress hook for callers that aren't printing to a
265
+ console (e.g. a web app polling/streaming download progress to a browser),
266
+ who would otherwise have no way to observe anything before this whole
267
+ ``await`` returns. Independent of ``verbosity``: both can be set at once,
268
+ each drives its own output.
261
269
 
262
270
  Raises:
263
271
  ValueError: If both ``branch_id`` and ``translation_index`` are given.
@@ -297,11 +305,14 @@ class RanobeLib:
297
305
  raise MultipleTitleTranslationsError(self._slug_url, chapters=unresolved)
298
306
 
299
307
  chapters = []
300
- with self._reporter.progress(f"Downloading {self._slug_url}", len(planned)) as advance:
308
+ total = len(planned)
309
+ with self._reporter.progress(f"Downloading {self._slug_url}", total) as advance:
301
310
  for index, (volume_str, number, selected_branch_id) in enumerate(planned):
302
311
  chapters.append(await self._fetch_chapter(volume_str, number, selected_branch_id))
303
312
  advance()
304
- if chapter_delay and index < len(planned) - 1:
313
+ if on_chapter is not None:
314
+ on_chapter(index + 1, total)
315
+ if chapter_delay and index < total - 1:
305
316
  await asyncio.sleep(chapter_delay)
306
317
  return _group_into_volumes(chapters)
307
318