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 schema compatibility check but never runs migrations; schema ownership stays with H2HDB core.
Installation and Usage
-
Install Python 3.14 or higher from python.org.
-
Install the required packages.
pip install h2hdb-komga
-
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.1,<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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file h2hdb_komga-0.4.2.tar.gz.
File metadata
- Download URL: h2hdb_komga-0.4.2.tar.gz
- Upload date:
- Size: 39.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9daf06e3d2c5353c7102f4e40ad7fab787c3d1368d87b76fb08f4edd9117a39b
|
|
| MD5 |
582267191e0b8c568cf4f5e87cdcc607
|
|
| BLAKE2b-256 |
f655b1a51ed899c45c6d19500aee45762c84ebe925767d25ecff0dcf18f0a24d
|
Provenance
The following attestation bundles were made for h2hdb_komga-0.4.2.tar.gz:
Publisher:
publish.yml on Kuan-Lun/h2hdb-komga
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
h2hdb_komga-0.4.2.tar.gz -
Subject digest:
9daf06e3d2c5353c7102f4e40ad7fab787c3d1368d87b76fb08f4edd9117a39b - Sigstore transparency entry: 2473760890
- Sigstore integration time:
-
Permalink:
Kuan-Lun/h2hdb-komga@5cb6ee7a3102bc544dfb8fdb7252626d47e95768 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/Kuan-Lun
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5cb6ee7a3102bc544dfb8fdb7252626d47e95768 -
Trigger Event:
push
-
Statement type:
File details
Details for the file h2hdb_komga-0.4.2-py3-none-any.whl.
File metadata
- Download URL: h2hdb_komga-0.4.2-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
620cf4249bba7e866f247aac257a15f5ed3ef1f90a1ccf8dba222e624ccf8ef7
|
|
| MD5 |
9e5191b5f8508fe9c263259d56629f5f
|
|
| BLAKE2b-256 |
6606d4aaa7f367184ed7944b62a06c2f40256ea066ded883c6ba1bbfe3976961
|
Provenance
The following attestation bundles were made for h2hdb_komga-0.4.2-py3-none-any.whl:
Publisher:
publish.yml on Kuan-Lun/h2hdb-komga
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
h2hdb_komga-0.4.2-py3-none-any.whl -
Subject digest:
620cf4249bba7e866f247aac257a15f5ed3ef1f90a1ccf8dba222e624ccf8ef7 - Sigstore transparency entry: 2473760952
- Sigstore integration time:
-
Permalink:
Kuan-Lun/h2hdb-komga@5cb6ee7a3102bc544dfb8fdb7252626d47e95768 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/Kuan-Lun
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5cb6ee7a3102bc544dfb8fdb7252626d47e95768 -
Trigger Event:
push
-
Statement type: