mugiwara-plugin-source-comix
v0.1.0
Published
Comix source plugin for Mugiwara manga reader - imports manga from comix.to
Maintainers
Readme
Comix Source Plugin for Mugiwara
A built-in source plugin for Mugiwara manga reader that enables importing manga from Comix.
Status
This is an internal built-in plugin that comes pre-installed with Mugiwara. It is not published to NPM and is automatically registered when the server starts.
Features
- Search: Search for manga by title with pagination
- Metadata: Automatic fetching of manga metadata including:
- Title and alternative titles
- Description
- Author and artist information
- Cover image
- Genres and tags
- Publication status and type (Manga/Manhwa/Manhua/Webtoon)
- Chapters: Browse and download all chapters with:
- Full chapter listing (all pages fetched, pagination handled internally)
- Deduplication of multi-group duplicate chapter numbers (prefers official scans, then highest votes)
- Page-by-page streaming download
- Automatic retry on failures
Configuration
The plugin can be configured via the Mugiwara server configuration:
interface ComixConfig {
// Base URL for Comix (default: "https://comix.to")
baseUrl?: string;
// Request timeout in milliseconds (default: 30000)
requestTimeout?: number;
// User agent for requests (default: "Mugiwara/1.0.0")
userAgent?: string;
// Number of search results per page (default: 20)
searchLimit?: number;
// Number of chapters fetched per chapter-list page (default: 20)
chapterPageSize?: number;
}Usage
Since this is a built-in plugin, you don't need to install anything. The source is automatically available with the ID "comix".
API Endpoints
Search for Manga
curl "http://localhost:3000/api/library/sources/comix/search?q=One%20Piece"Get Manga Details
curl "http://localhost:3000/api/library/sources/comix/manga/{hid}"Where {hid} is the Comix manga hid (e.g. n8we, returned by search).
Import Manga
curl -X POST "http://localhost:3000/api/library/import" \
-H "Content-Type: application/json" \
-d '{
"sourceId": "comix",
"sourceMangaId": "n8we",
"storageBackendId": "default",
"downloadAll": true
}'Programmatic Usage
import createComixSource from "@mugiwara/source-comix";
const source = createComixSource({ config: {} });
await source.initialize({});
const results = await source.search("Solo Leveling");
const manga = await source.getMangaDetails(results[0].sourceMangaId);
for await (const page of source.downloadChapter(
manga.chapters[0].sourceChapterId,
)) {
// page.data contains the image buffer
// page.pageNumber is the page number
// page.contentType is the MIME type
}Cloudflare & Crypto
Comix is fronted by Cloudflare but does not present an interactive challenge to plain
HTTP fetches. However, the /api/v1/* endpoints enforce an application-layer token:
every GET on a signed path must carry a _ token minted from the request's canonical
form, and encrypted responses are returned as {"e":"..."} envelopes.
This plugin ships a pure-TS port of the reversed frontend protocol
(src/crypto.ts, tables resolved via src/tables.ts):
makeCrypto(tables)buildssignToken(canonical), which reproduces browser-minted_tokens byte-identically (three chained S-box/XOR stages with keysk367/k432/k55, seeds 189/133/32), plusdecryptEnvelope(e)for encrypted responses.
No headless browser is needed at runtime. The S-boxes/keys are baked into a
specific frontend build (tl03m9, asset hash 35595e3de3c99889c1aa70); the
client detects the live build hash from already-fetched page HTML and uses the
pinned src/tables.json while it matches. On-demand derivation from a fresh
secure-*.js bundle is designed but not yet implemented
(handoff/02-crypto-spec.md §7, tryDeriveTables contract in src/tables.ts),
so if Comix redeploys with rotated tables, signed requests will fail with a
ComixTablesStaleError naming both the observed and expected builds — then
re-snapshot (runbook: handoff/05-re-tooling.md) and refresh src/tables.json.
Endpoints
- Search:
GET /api/v1/manga?keyword=...&limit=...&page=...&content_rating[]=...(plaintext, signed) - Manga details:
GET /title/{hid}HTML → embeddedinitial-dataJSON (no token) - Chapter list:
GET /api/v1/manga/{hid}/chapters?page=...&limit=...&order[number]=desc(encrypted, signed) - Chapter pages:
GET /api/v1/chapters/{id}(encrypted, signed) →pages.items[].url - Page images: direct
GETon the per-chapter image host, requiresReferer: https://comix.to/(else403). Hosts vary per chapter — URLs are always taken verbatim from the API payload, never hardcoded.
Retry Logic
The plugin implements the following retry behavior for page downloads:
- 100ms delay between page downloads
- Exponential backoff on retry (1s, 2s, 3s)
- 30-second timeout on API requests
- Maximum 3 retries per page
License
MIT
Disclaimer
This plugin is not affiliated with Comix. Please respect their terms of service when using this plugin.
