Skip to content

Fix API ban error handling and add session token auth#80

Open
pkhamchuai wants to merge 2 commits into
hurlenko:masterfrom
pkhamchuai:fix/api-ban-session-token
Open

Fix API ban error handling and add session token auth#80
pkhamchuai wants to merge 2 commits into
hurlenko:masterfrom
pkhamchuai:fix/api-ban-session-token

Conversation

@pkhamchuai

@pkhamchuai pkhamchuai commented Jun 14, 2026

Copy link
Copy Markdown

Problem

The MangaPlus API now requires a Session-Token header. Without it, the
server returns an "Account Banned" protobuf error in response field 2 —
undocumented and outside the generated schema — so it was silently dropped,
causing a confusing IndexError on viewer.pages[-1].

Changes (mloader/loader.py)

  • Session token auth — reads Session-Token from token.txt at startup
    so the token can be renewed without touching source code
  • _parse_api_error() — manually decodes the failure protobuf field and
    surfaces a clear RuntimeError (e.g. "Account Banned: ...") instead of
    crashing with an IndexError
  • Empty viewer guard — raises immediately with a meaningful message when
    the API returns an empty viewer response

Test plan

  • Place a valid session token in token.txt and confirm chapters download
  • Use an invalid/missing token and confirm a clear RuntimeError is raised
    instead of IndexError

The MangaPlus API now requires a Session-Token header; without it the
server returns an "Account Banned" protobuf error in response field 2
(undocumented, outside the generated schema) which was silently dropped,
causing a confusing IndexError on viewer.pages[-1].

- Read Session-Token from token.txt at startup so the token can be
  renewed without touching source code
- Add _parse_api_error() to manually decode the failure protobuf field
  and surface a clear RuntimeError (e.g. "Account Banned: ...") instead
  of crashing with an IndexError
- Add _load_pages() guard: raise immediately when the viewer is empty
@RhinoDance

Copy link
Copy Markdown

works like a charm! thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants