Translator
The library provides multiple translation providers that implement the BaseTranslator interface.
NekoTranslator¶
Client for the NekoTranslate API. Supports anonymous mode with automatic proxy rotation.
from nhentai import NekoTranslator, NekoEngine, Language
translator = NekoTranslator(token="YOUR_BEARER_TOKEN") # token is optional
data = translator.translate_file("page.jpg", tgt_lang=Language.INDONESIAN, engine=NekoEngine.DEEPL)
nhentai.translator.NekoTranslator(token: str | None = None, proxy_list_url: str | None = None, proxies: list[str] | None = None)
¶
Bases: BaseTranslator
NekoTranslate API client.
Anonymous (no token): uses free quota per IP, rotates proxies automatically. Authenticated: pass token from nhentai.net localStorage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token
|
str | None
|
Bearer token for authenticated requests (optional). |
None
|
proxy_list_url
|
str | None
|
URL to a plain-text proxy list. Defaults to proxifly socks5 list. |
None
|
proxies
|
list[str] | None
|
Explicit proxy list (overrides proxy_list_url). |
None
|
Source code in nhentai/providers/neko.py
find_proxy_with_quota() -> dict | None
¶
Returns the first proxy with remaining anonymous quota, or None.
Source code in nhentai/providers/neko.py
get_balance() -> dict
¶
Returns {"email", "plan", "level", "quota"}.
Source code in nhentai/providers/neko.py
translate_file(image_path: Path, tgt_lang: Language | str = Language.ENGLISH, engine: NekoEngine | str = NekoEngine.DEEPL) -> bytes
¶
Translate an image file and return the result as bytes.
Source code in nhentai/providers/neko.py
translate_bytes(data: bytes, filename: str, tgt_lang: Language | str = Language.ENGLISH, engine: NekoEngine | str = NekoEngine.DEEPL) -> bytes
¶
Translate raw image bytes. Writes to a temp file, translates, returns result bytes.
Source code in nhentai/providers/neko.py
ComicTranslator¶
Client for the Comic-Translator API. Automatically handles guest registration and supports direct URL translation.
from nhentai import ComicTranslator, ComicEngine, Language
translator = ComicTranslator()
# Direct URL translation (Faster)
data = translator.translate_url("https://i.nhentai.net/...", tgt_lang=Language.ENGLISH, engine=ComicEngine.GEMINI_FLASH)
nhentai.translator.ComicTranslator()
¶
Bases: BaseTranslator
ComicTranslator.com API client. Automatically handles guest registration and credit management.
Source code in nhentai/providers/comic.py
nhentai.translator.TranslationError
¶
Bases: Exception
Raised when the translation server reports a failure.