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, whether Komga includes the .cbz suffix or not. A physical gid-sha256.cbz storage name, a pure GID, and a friendly name ending in [gid] are resolved against the same pinned catalog revision through the public CatalogReader. 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 a complete epoch-READY audit through H2HDB core's public database opener but never runs migrations; 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. 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.22.0.2,<0.23. 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

This repository has its own uv virtual environment and intentionally ignores uv.lock; it is not part of an uv workspace. For adjacent local clones:

uv venv
uv pip install -e ../h2hdb.clone
uv pip install -e ".[dev]"
uv run --no-sync pytest

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 Licence (GPL). For detailed licence terms, see the LICENSE file included in this distribution.

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.4.4.tar.gz (39.6 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.4.4-py3-none-any.whl (26.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: h2hdb_komga-0.4.4.tar.gz
  • Upload date:
  • Size: 39.6 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.4.4.tar.gz
Algorithm Hash digest
SHA256 9522000b1d9c89db8153b94cf94434be44d9224722dcf1bb06d937b6aac27bac
MD5 497c9c8655545722203330f179fbf884
BLAKE2b-256 81937bf234124a74b0e7f375e541b796fa29c910c3542d9090bb929d0a05184c

See more details on using hashes here.

Provenance

The following attestation bundles were made for h2hdb_komga-0.4.4.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.4.4-py3-none-any.whl.

File metadata

  • Download URL: h2hdb_komga-0.4.4-py3-none-any.whl
  • Upload date:
  • Size: 26.8 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.4.4-py3-none-any.whl
Algorithm Hash digest
SHA256 4a3cb3a6e107ffe456dbca2bcfc2e887241b6e40a040d7a0c27ffa934517feb5
MD5 ebd34e45a86a0e62a29901c3f88925fd
BLAKE2b-256 91dc953531503bdb85646367ff61d1c47b1fc97de796d7da18270efc9e142854

See more details on using hashes here.

Provenance

The following attestation bundles were made for h2hdb_komga-0.4.4-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

0.6.0

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

This release

0.4.4 This release

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