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.

Canonical h2h-{gid}.cbz artifact names are matched through the public lookup, whether Komga includes the .cbz suffix or not; large libraries are queried in batches of at most 128 against one pinned revision. A physical gid-sha256.cbz storage name, a pure GID, and a friendly name ending in [gid] are 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 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.23.0.2,<0.24. 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.5.tar.gz (40.3 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.5-py3-none-any.whl (27.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: h2hdb_komga-0.4.5.tar.gz
  • Upload date:
  • Size: 40.3 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.5.tar.gz
Algorithm Hash digest
SHA256 9c7c8264516ff9f160fdb836c3ea1055de61155644475b7426be68a6eb1df470
MD5 50deb8e3dbc2b44203b23ab15ea1a9fc
BLAKE2b-256 fa0ffeb7e9022f0ffb0609543b51c318a8ea107136fb97ef5328bcfc40f3bfc8

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: h2hdb_komga-0.4.5-py3-none-any.whl
  • Upload date:
  • Size: 27.1 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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 ee9d35fd7efc910c0444e0b22d286a790a96013f4bc83d964330094f24ab3141
MD5 94a072ca8f96d5b7116bc5cec78696b1
BLAKE2b-256 d056fc9fccee3f698fc3afe70d6070ae5ed5541eabf5b2f8915085df9151ec35

See more details on using hashes here.

Provenance

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

This release

0.4.5 This release

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