gvellut / jncep

Command-line tool to generate EPUB files for J-Novel Club pre-pub novels
GNU General Public License v3.0
43 stars 11 forks source link

Recent Nina API update causes an unrecoverable error when trying to download parts #51

Closed AkiroGS closed 1 month ago

AkiroGS commented 1 month ago

Describe the bug When using the epub command to download content from JNC Nina, an unrecoverable error occurs.

Expected behavior The specified parts should be downloaded

To Reproduce jncep epub --email REDACTED --password REDACTED --byvolume SERIES-LINK (using the Nina branch)

Debug trace Relevant extract:

      | Traceback (most recent call last):
      |   File "C:\Python312\Lib\site-packages\jncep\core.py", line 632, in fetch_content_and_images_for_part
      |     content = await session.api.fetch_content(part_id, "data.xhtml")
      |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      |   File "C:\Python312\Lib\site-packages\jncep\jnclabs.py", line 62, in wrapper
      |     response = await f(*args, **kwargs)
      |                ^^^^^^^^^^^^^^^^^^^^^^^^
      |   File "C:\Python312\Lib\site-packages\jncep\jnclabs.py", line 176, in fetch_content
      |     r = await self._call_labs_api_authenticated("GET", path)
      |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      |   File "C:\Python312\Lib\site-packages\jncep\jnclabs.py", line 216, in _call_labs_api_authenticated
      |     r = await self._call_authenticated(
      |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      |   File "C:\Python312\Lib\site-packages\jncep\jnclabs.py", line 251, in _call_authenticated
      |     r.raise_for_status()
      |   File "C:\Python312\Lib\site-packages\asks\response_objects.py", line 47, in raise_for_status
      |     raise BadStatus(
      | asks.errors.BadStatus: 404 Client Error: Not Found for url: https://api.jnc-nina.eu/embed/REDACTED-SLUG-ID/data.xhtml

Environment (please complete the following information):

Proposed fix This bug is most likely caused by a recent API change for Nina (not sure about the "main" JNC API), adding a /v2 to certain API calls, at the very list the one used in the debug trace above.

Adding /v2 to the path variable of the fetch_content() method of the JNCLabsAPI class fixes the issue.

Senshi00 commented 1 month ago

I can confirm that the proposed fix resolved the issue.

gvellut commented 1 month ago

Thank you both. @AkiroGS I have merged your pull request. I will make a release at some point (in September hopefully).