Skip to main content

mokuro-bridge

mokuro-bridge is where all three dokuha projects converge. It is a small local service that runs mokuro OCR on finished pages and uploads the result, producing the .cbz / .mokuro / .webp trio that reader.mokuro.app reads.

The three projects

  • dokuha-cli is the engine and the batch downloader. A Node CLI that downloads manga volumes from five stores (BookWalker, CMOA, ebookjapan, Kindle and k-manga) at full resolution, unscrambles them offline, and owns series downloads: give it a series URL and it finds the free volumes and previews itself.
  • dokuha-userscript is the in-browser companion. What you can install today is the earlier userscript release, bookwalker-ebookjapan-cmoa-native-downloader, which covers BookWalker, CMOA and ebookjapan: it downloads the single volume you already have open, with no install beyond a userscript manager. The rewrite that adds Kindle and k-manga is in development and not published yet.
  • mokuro-bridge (this repository) is where all three converge. A small local service that runs mokuro OCR on finished pages and uploads the result to MEGA, Google Drive, OneDrive or a local folder, producing the .cbz / .mokuro / .webp trio that reader.mokuro.app reads. Both downloaders hand finished volumes to it, so OCR and upload are identical no matter which one produced the pages. It is also useful on its own for any client that can produce page images.

dokuha-cli is the batch downloader, dokuha-userscript is the browser companion, and this repository is the shared OCR and delivery service. Both downloaders call the same HTTP API here, so a volume captured headlessly and a volume captured in a browser are processed by exactly the same code.

What this service is responsible for

The bridge owns one half of the capture pipeline and only that half: it never touches a storefront and holds no store account, cookie or store protocol. A client gets the images out however it likes and hands them over, which is why the bridge does not break when a store changes and why anything that can produce a page image can use it.

What it is A local FastAPI service: pages in, .cbz + .mokuro + .webp + series.json out
Runs on macOS, Windows and Linux, Python 3.10 or newer
Needs Any mokuro plus PyTorch for OCR; the fetch accelerator is in the base install
Delivery A local folder by default; MEGA, Google Drive and OneDrive opt in
Exposure Loopback only, unauthenticated, and meant to stay that way

The output is always the same files, under a per-series folder:

<output>/<series>/
  series.json        the reader's per-series index, one per series folder
  <volume>.cbz       page images
  <volume>.mokuro    OCR text and block data
  <volume>.webp      cover

series.json is what keeps a library uploaded by a script visible in reader.mokuro.app, which only builds that index itself for series it already knows locally. The bridge writes it for the first volume and merges each later volume into it. The format is Gnathonic's mokuro-reader (GPL-3.0), pinned by commit rather than vendored: see docs/series-json.md.

A volume folder keeps a clean name unless that name is genuinely taken, in which case the bridge adds a short random suffix (<volume>_a1b2c3) so two different volumes never share a directory.

Where it converges with the other two

dokuha-cli hands over a folder of finished pages with --mokuro. dokuha-userscript streams each captured page to the bridge as it downloads, so OCR overlaps the capture. Both end at the same POST /session/{id}/finalize, which assembles the volume files and the series index, uploads them and reports progress as NDJSON on the same connection.

The three projects are documented together under docs/clients.md, which gives the exact request sequence each client uses.

Key advantages

  • Store-agnostic. The bridge knows nothing about any store, so a storefront redesign cannot break OCR or delivery.
  • OCR runs as pages arrive, in chunks of 8 with an idle flush after 1.5 s, so a long volume is not a capture followed by a separate wait.
  • Twelve HTTP routes cover capture, resume, status, queue, health and destination checks; the full table is in docs/endpoints.md.
  • Named destinations. Each provider can hold several accounts (mega, mega:work, drive:personal), each with its own remote root and credentials. See docs/destinations.md.
  • A sticky default. Once any client names a destination explicitly, that choice becomes the default for every later request, including from other clients, until another explicit choice replaces it.
  • A page-fetch accelerator for the browser companion. A browser allows six connections per origin, and the port is part of the origin, so the bridge opens 48 extra localhost ports by default and lists them on /health. Each is worth six more sockets, so the userscript gets 288 extra lanes with nothing to configure.
  • Safe by default. It binds to 127.0.0.1, refuses to read outside your home and the system temp locations, and stages uploads inside the work volume.

Use cases

  • Headless batch capture. Run dokuha-cli over a series with --mokuro and come back to a finished library with OCR text, covers and cloud copies.
  • One volume from the browser. Use the userscript on a page you already have open; the bridge supplies the extra fetch lanes, the OCR and the upload.
  • OCR a folder you already have. mokuro-bridge-ocr ./my-volume/ --title "Volume title" drives a running bridge over HTTP.
  • Any other client. Anything that can POST page images can use the bridge; there is no store-specific code to satisfy.

Install

Install with pipx or uv tool install, which keeps the bridge in its own environment:

pipx install mokuro-bridge
mokuro-bridge

Or from a checkout:

git clone https://github.com/GolyBidoof/mokuro-bridge && cd mokuro-bridge
python3 -m venv .venv && source .venv/bin/activate    # Windows: .venv\Scripts\activate
pip install -r requirements.txt
./run.sh

The base install is only fastapi, uvicorn, python-multipart, httpx and keyring. The OCR engine is optional because it pulls in PyTorch, which is several GB. Either engine works:

pip install "mokuro @ git+https://github.com/GolyBidoof/mokuro"   # the fork, batched, about 1.8x
pip install -r requirements-ocr.txt                               # stock mokuro, slower

Without an engine the bridge still runs, /health reports mokuro_installed: false, and only OCR is unavailable. An upload provider's SDK also stays out of the base install, and its setup wizard offers to install the right requirements file when one is missing. pip install "mokuro-bridge[cloud]" adds both Google Drive and OneDrive without PyTorch.

The fork is the faster engine, and mokuro-bridge --install-mokuro replaces whichever mokuro is installed in the environment that runs the service, then verifies the import. /health reports which engine is loaded as mokuro_flavor. The exact commands, how to go back to upstream, and the per-environment caveat are in docs/mokuro.md.

Quick start

Start the bridge, then OCR a folder of pages you already have:

mokuro-bridge-ocr ./my-volume/ --title "Volume title"

Or let a client drive the whole pipeline, folder hand-off first and streaming capture second:

dokuha --mokuro 'https://bookwalker.jp/de00000000-0000-4000-8000-000000000001/'

Configure a cloud destination once and it stays the default:

mokuro-bridge --setup-upload mega
mokuro-bridge --list-uploads

On macOS, ./install-launchd.sh installs a launchd agent that starts the bridge at login. When a newer release exists, the service logs one line about it at startup, and mokuro-bridge --check-update reports it without changing anything (exit 0 up to date, 1 update available, 2 check failed). mokuro-bridge --update is the one command that acts: it detects whether this copy came from pipx, uv tool, a plain pip install or a git checkout, prints the exact upgrade command, runs it and prints how to restart the service. Nothing restarts by itself, because a restart mid-OCR loses work.

The series.json format is upstream's, so the bridge pins it. mokuro-bridge --check-series-reference re-fetches the pinned files and reports whether they still match (exit 0 matching and current, 1 upstream moved, 2 check failed), and mokuro-bridge --refresh-series-reference re-pins them.

The bridge is unauthenticated and binds to 127.0.0.1, which is the whole access control. A library outside your home directory needs MOKURO_BRIDGE_INGEST_ROOTS. CORS, the fetch allowlist and the file-descriptor cost of 48 proxy ports are covered in docs/architecture.md.

Docs

docs/series-json.md The series.json sidecar: its format, why the uploader writes it, and the pin on upstream
docs/endpoints.md Every HTTP route: method, path, form fields, response shape, error codes and test coverage
docs/destinations.md Upload targets, named accounts, credential stores and the sticky default
docs/clients.md How dokuha-cli and dokuha-userscript drive the bridge, with the exact request sequence
docs/architecture.md Request lifecycle, sessions, scheduling, the fetch proxy and the security posture
docs/troubleshooting.md Install failures, missing OCR, file-descriptor limits, 403s
docs/mokuro.md The faster mokuro fork: why it is faster, the one install command, going back to upstream
CHANGELOG.md What changed, release by release
Releases The prebuilt wheel and sdist

Development

pip install -r requirements-dev.txt
python3 -m pytest        # 364 tests, about 10s, hermetic
python3 -m ruff check .

Credits and licence

MIT, see LICENSE.

OCR runs on the mokuro fork, which adds batched recognition and is the recommended engine. It forks kha-white's original mokuro, still supported as the slower fallback under its own licence. Cloud delivery uses the MEGA, Google Drive and OneDrive clients, each under its own terms.

The series.json format is defined by Gnathonic's mokuro-reader (GPL-3.0) and implemented a second time by mokuro-bunko (MPL-2.0). Neither codebase is copied here: this project pins the upstream files and ports the contract.

The code was written by DeepSeek V4.1 Flash.

Metadata

Release files for mokuro-bridge 0.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mokuro-bridge 0.9.0
File Size Uploaded Provenance
mokuro_bridge-0.9.0.tar.gz 217.7 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for mokuro-bridge 0.9.0
File Interpreter ABI Platform
mokuro_bridge-0.9.0-py3-none-any.whl Python 3 none any Details

Total release size: 366.2 kB

Release files / mokuro_bridge-0.9.0.tar.gz

Download URL mokuro_bridge-0.9.0.tar.gz
Size 217.7 kB
Tags Source
SHA-256 checksum
How to use checksums
a8261a5c1ffc9542e5ab87cf1cbb1a68aa067c2022788ea2f321ea931e1c96ea
BLAKE2b-256 checksum
How to use checksums
28b9d15fa0aa52dd5d5aae1b4cf32beb38db2760d2022ed6e51e468bd608e4e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release files / mokuro_bridge-0.9.0-py3-none-any.whl

Download URL mokuro_bridge-0.9.0-py3-none-any.whl
Size 148.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
804adcce7af44401f646ed6fbac25d7965abe9e3698f3685ad860ce14a9dc833
BLAKE2b-256 checksum
How to use checksums
77b338b0d1d8a01764affff0a6a1bab07baf3efbb2182e5eee4c24105d29e7e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Security for mokuro-bridge 0.9.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mokuro_bridge-0.9.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page