Fix API ban error handling and add session token auth#80
Open
pkhamchuai wants to merge 2 commits into
Open
Conversation
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
|
works like a charm! thanks a lot! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The MangaPlus API now requires a
Session-Tokenheader. Without it, theserver returns an "Account Banned" protobuf error in response field 2 —
undocumented and outside the generated schema — so it was silently dropped,
causing a confusing
IndexErroronviewer.pages[-1].Changes (
mloader/loader.py)Session-Tokenfromtoken.txtat startupso the token can be renewed without touching source code
_parse_api_error()— manually decodes the failure protobuf field andsurfaces a clear
RuntimeError(e.g."Account Banned: ...") instead ofcrashing with an
IndexErrorthe API returns an empty viewer response
Test plan
token.txtand confirm chapters downloadRuntimeErroris raisedinstead of
IndexError