Skip to main content

H2HDB-Komga

Description

H2HDB-Komga synchronizes a Komga library from the published catalog projection in H2HDB. It matches Komga book names to catalog publications and maps publication title, summary, release date, every non-empty H2H gallery tag pair, and GID into Komga metadata. Gallery tag pairs retain their original role/value meaning as Komga authors. OPDS contributors, including the upload account, are not copied to Komga, and this adapter does not patch Komga's tags field. When the original gallery title is blank, the title field is also omitted so Komga keeps its existing display title.

Published friendly artifact names are matched directly through the public lookup, whether Komga includes the .cbz suffix or not; lookup candidates are queried in batches of at most 128 against one pinned revision. When direct lookup does not match, a physical gid-sha256.cbz storage name, a pure GID, or a friendly name ending in [gid] is resolved against that same pinned revision through public catalog pagination. A revision change resets the stability window, and completion performs a final revision check. This adapter never reads CatalogArtifact.location or any core repository internals. Books with no published match are left unchanged.

The H2HDB database is always opened in read-only mode. Startup performs the exact epoch-2 READY audit through H2HDB's public database opener but never initializes or migrates schema; schema ownership stays with H2HDB core.


Installation and Usage

  1. Install Python 3.14 or higher from python.org.

  2. Install the required packages.

    pip install h2hdb-komga
    
  3. Run the script.

    python -m h2hdb_komga \
      --komgaconfig [komga-config.json] \
      --h2hdbconfig [h2hdb-config.json]
    

Config

komga-config.json

{
    "base_url": "https://komga.example",
    "api_username": "${KOMGA_API_USERNAME}",
    "api_password": "${KOMGA_API_PASSWORD}",
    "library_id": "library-id",
    "trigger_scan": true
}

Set both credential variables in the process environment before starting the command:

export KOMGA_API_USERNAME="admin@example.com"
export KOMGA_API_PASSWORD="secret"

${ENV_NAME} is resolved only when it is the complete JSON string value; it is not substring interpolation. Resolution is recursive, missing variables fail startup without exposing credential values, and resolved credentials must both be non-empty strings. Literal api_username and api_password values remain supported, but placeholders keep deployment secrets out of the JSON file. Credential fields are also omitted from KomgaConfig's representation so ordinary diagnostic output does not reveal them.

trigger_scan defaults to true. Set it to false to skip requesting a Komga scan/analyze and only reconcile metadata already visible in the library. Afterward, the command polls every five seconds and rechecks every current book. It exits only after book/series IDs and metadata remain stable for 30 seconds; the default timeout is one hour and can be changed with --timeout-seconds. This observation window allows Komga's asynchronous scan/analyze jobs and transient book fetch failures to become visible before completion. Every catalog lookup in one pass is pinned to the same current H2HDB head. If publication advances during a batched lookup or pagination, the partial pass is discarded before metadata is patched and the next poll starts again from the new head. Each HTTP request, PATCH verification, retry, and retry delay uses the remaining cooperative budget. The CLI also runs the complete operation in a disposable worker process and kills it at the wall-clock deadline, so a slow-drip socket, blocked database gate, or executor shutdown cannot extend the documented hard timeout indefinitely.

h2hdb-config.json

Use an H2HDB core configuration compatible with h2hdb>=0.24.0,<0.25. Any configured database access mode is overridden to read-only by this CLI. The core loader supports the same exact ${ENV_NAME} placeholders, including for a dedicated read-only database account and password.

Local Development

Rebuild the repository-local environment and run its canonical gates with:

./scripts/rebuild-env.sh
./scripts/check-fast.sh
./scripts/check-full.sh

The rebuild script installs this project in editable mode and resolves the published compatible H2HDB core. It uses uv only for .venv and pip-style installation, never reads uv.lock, and never assumes an adjacent checkout.


Q & A

  • How to use Komga? See Rainie's article.

  • Why is a CBZ file not updated?

    The CBZ must be present in Komga and in a successfully published H2HDB catalog revision. Enable trigger_scan, scan the library in Komga, or run the command again after ingest has published the artifact. Both the current content-addressed filename and a current friendly projection name ending in [gid] are supported.


Credits

The project was created by Kuan-Lun Wang.


License

This project is distributed under the terms of the GNU General Public License version 3 (GPLv3). See the included LICENSE file for the complete terms.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

h2hdb_komga-0.6.0.tar.gz (47.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

h2hdb_komga-0.6.0-py3-none-any.whl (27.3 kB view details)

Uploaded Python 3

File details

Details for the file h2hdb_komga-0.6.0.tar.gz.

File metadata

  • Download URL: h2hdb_komga-0.6.0.tar.gz
  • Upload date:
  • Size: 47.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for h2hdb_komga-0.6.0.tar.gz
Algorithm Hash digest
SHA256 f151d9469393a947263968ced3d166e45b19e79d6e6fd33167fb401841ab64be
MD5 d147d838d9ef29d80a2929b6e3e42d3e
BLAKE2b-256 ebe0d6cbb888855a4d4410f09c9eff39a946e9380797a3e2b2f005784bead928

See more details on using hashes here.

Provenance

The following attestation bundles were made for h2hdb_komga-0.6.0.tar.gz:

Publisher: publish.yml on Kuan-Lun/h2hdb-komga

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file h2hdb_komga-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: h2hdb_komga-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 27.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for h2hdb_komga-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 01d361e04641639675eef644752dfb3585921981f14eacba7c0fc52b3027a666
MD5 3b5af410998a0d58c2127d5e99cdb3dd
BLAKE2b-256 3de8dcea8a78193853bcaafc8f99a22190d9a07697076b93cd846ee6130614fa

See more details on using hashes here.

Provenance

The following attestation bundles were made for h2hdb_komga-0.6.0-py3-none-any.whl:

Publisher: publish.yml on Kuan-Lun/h2hdb-komga

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.10.0

2 files

0.9.0

2 files

0.8.1

2 files

This release

0.6.0 This release

2 files

0.5.6

2 files

0.5.4

2 files

0.5.3

2 files

0.5.2

2 files

0.5.1

2 files

0.5.0

2 files

0.4.6

2 files

0.4.5

2 files

0.4.4

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

0.3.0

2 files

0.2.9

2 files

0.2.8

2 files

0.2.7

2 files

0.2.6

2 files

0.2.5

2 files

0.2.3

2 files

0.2.2

2 files

0.2.0

2 files

0.1.0

2 files

0.0.1

2 files

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