### Copy example fixtures.json for manual editing Source: https://github.com/ajslater/comicbox/blob/main/tests/calibration/README.md Manual mode setup: copy the example fixture file to create your own. The file is gitignored and specific to your library. ```sh cp tests/calibration/fixtures.example.json tests/calibration/fixtures.json ``` -------------------------------- ### Install comicbox with pip Source: https://github.com/ajslater/comicbox/blob/main/README.md Basic installation command for the comicbox package. ```sh pip install comicbox ``` -------------------------------- ### Install comicbox with PDF extra on ARM (AARCH64) Source: https://github.com/ajslater/comicbox/blob/main/README.md Sets PYMUPDF_SETUP_PY_LIMITED_API=0 to work around build failures on some Python versions when installing the PDF extra on ARM. Requires build-essential and python3-dev packages. ```sh PYMUPDF_SETUP_PY_LIMITED_API=0 pip install comicbox[pdf] ``` -------------------------------- ### Install comicbox with PDF extra Source: https://github.com/ajslater/comicbox/blob/main/README.md Installs comicbox with the optional PDF extra, which pulls in pymupdf for PDF support. ```sh pip install comicbox[pdf] ``` -------------------------------- ### Set Comicbox config keys via environment variables Source: https://github.com/ajslater/comicbox/blob/main/README.md Environment variables are prefixed with COMICBOX_ and use __ between config levels. Values are parsed as YAML scalars, so true, 0.9, and 24h get the types the config file would give them. A value that doesn't fit its key is an error rather than being silently ignored. ```sh COMICBOX_GENERAL__RECURSE=true COMICBOX_ONLINE__AUTH__METRON__KEY=your-token COMICBOX_ONLINE__TUNING__AUTO_THRESHOLD=0.9 ``` -------------------------------- ### Set log level with LOGLEVEL environment variable Source: https://github.com/ajslater/comicbox/blob/main/README.md The LOGLEVEL environment variable sets the log level for a comicbox command. This example runs comicbox with ERROR logging on a comic file. ```sh LOGLEVEL=ERROR comicbox -p "comic.cbz" ``` -------------------------------- ### Show comicbox CLI help Source: https://github.com/ajslater/comicbox/blob/main/README.md Displays the complete CLI reference, including metadata format keys, --print phases, and online tagging tables. ```sh comicbox -h ``` -------------------------------- ### Bootstrap fixtures.json from tagged library Source: https://github.com/ajslater/comicbox/blob/main/tests/calibration/README.md Commands to generate fixtures.json by walking a directory and extracting existing Metron/ComicVine tags. Use --cover-quality thumbnail for slimlib, --require-both for cross-source calibration. See make calibrate-bootstrap for default invocation. ```sh # Walk a directory, extract existing tags, write fixtures.json: uv run python -m tests.calibration.bootstrap ~/Milliways/Comics/Test ``` ```sh # Mark all entries as thumbnail-quality (e.g. for slimlib): uv run python -m tests.calibration.bootstrap ~/Milliways/slimlib \ --cover-quality thumbnail \ --output tests/calibration/fixtures-slim.json ``` ```sh # Cross-source calibration only — both ids required: uv run python -m tests.calibration.bootstrap \ ~/Milliways/Comics/Test --require-both ``` -------------------------------- ### Run with --filter REGEX Source: https://github.com/ajslater/comicbox/blob/main/tests/calibration/README.md Run only fixtures whose filename matches a regex. Combines with --sources and --limit. Writes to .partial.json. ```sh # Verify the smoking-gun cases after a scoring fix: uv run python -m tests.calibration.run --filter 'Lois Lane|Watchmen \(1987\)' # Just the AfterShock indie titles: uv run python -m tests.calibration.run --filter 'Wrong Earth|Penultiman|Snow Angels' ``` -------------------------------- ### Run comicbox doctor with various options Source: https://github.com/ajslater/comicbox/blob/main/README.md comicbox doctor checks everything comicbox depends on outside its own code. Each row says OK, WARN, OFF, MISSING, WRONG VERSION, MISCONFIGURED or ERROR, with a one-line fix. The -q option shows problems only and exits non-zero if something is broken, working as a Docker or CI health check. The --online all option also verifies each configured online source's credentials with one API request per source. ```sh comicbox doctor # The config a run with -c would load. comicbox doctor -c tagging.yaml # Problems only. Exits non-zero if something comicbox needs is broken, so it # works as a Docker or CI health check. comicbox doctor -q # Also verify each configured online source's credentials, with one API # request per source. comicbox doctor --online all ``` -------------------------------- ### Representative comicbox CLI commands Source: https://github.com/ajslater/comicbox/blob/main/README.md Shows common CLI usage: printing merged metadata, setting and writing a field, recursive library updates, and exporting/importing metadata via file. ```sh # Print the merged metadata comicbox reads from a comic. comicbox -p "comic.cbz" # Set a field and write it as ComicInfo.xml inside the archive. comicbox -m "{publisher: SmallComics}" -w cix "comic.cbz" # Recursively set a field across an entire library. comicbox --recurse -m "{publisher: 'SC Comics'}" -w cix ./comics/ # Export and re-import metadata as a file. comicbox -e cix "comic.cbz" comicbox -i ComicInfo.xml -w cix "comic.cbz" ``` -------------------------------- ### Configuration YAML for online sources Source: https://github.com/ajslater/comicbox/blob/main/tests/stress/README.md YAML configuration file at ~/.config/comicbox/config.yaml specifying Metron and ComicVine credentials. Required for stress tests to access online sources. ```yaml # ~/.config/comicbox/config.yaml comicbox: online: metron: username: your_metron_user password: your_metron_password comicvine: api_key: your_cv_api_key ``` -------------------------------- ### Configure Metron and ComicVine credentials in config.yaml Source: https://github.com/ajslater/comicbox/blob/main/tests/calibration/README.md YAML configuration for the calibration harness. Requires Metron username/password and/or ComicVine api_key. Place in ~/.config/comicbox/config.yaml or set corresponding environment variables. ```yaml comicbox: online: metron: username: your_metron_user password: your_metron_password comicvine: api_key: your_cv_api_key ``` -------------------------------- ### Online Tagging with Metron and ComicVine Source: https://github.com/ajslater/comicbox/blob/main/README.md Shows interactive, exact-ID, and unattended batch tagging commands. `--match` controls write confidence, `--effort` trades accuracy for API calls (Metron ignores effort), and credentials come from `--auth`, `COMICBOX_*` env vars, config, or keyring. ```sh # Interactive: prompts only when the match isn't clear. comicbox -o metron "GI Joe #007 (1952).cbz" ``` ```sh # Tag by an exact database id (skips searching). comicbox -I metron:42 "comic.cbz" ``` ```sh # Unattended batch run: never prompts, 4 files at a time. comicbox --online all --recurse --prompts never -j 4 ./comics/ ``` -------------------------------- ### Run calibration harness Source: https://github.com/ajslater/comicbox/blob/main/tests/calibration/README.md Commands to execute the calibration. 'make calibrate' runs both sources on the full set; the direct command runs only Metron with a limit of 30. Each full run writes outcomes to fixtures.outcomes.json for --retry-misses. ```sh make calibrate # both sources, full set ``` ```sh uv run python -m tests.calibration.run --sources metron --limit 30 ``` -------------------------------- ### Round-trip metadata editing workflow Source: https://github.com/ajslater/comicbox/blob/main/README.md Exports metadata to a file, edits it, previews the re-import, then wipes old tags and writes the edited file back. Use with caution because the delete-all-tags step is destructive. ```sh # 1. Export the current metadata to an editable file. comicbox --export cix "My Overtagged Comic.cbz" # 2. Edit it. nvim ComicInfo.xml # 3. Preview the re-import. comicbox --import ComicInfo.xml -p "My Overtagged Comic.cbz" # 4. Wipe the old tags, then write the edited file back (careful!). comicbox --delete-all-tags "My Overtagged Comic.cbz" comicbox --import ComicInfo.xml -w cix "My Overtagged Comic.cbz" ``` -------------------------------- ### Read metadata with Comicbox class Source: https://github.com/ajslater/comicbox/blob/main/README.md Use the Comicbox class to open a comic archive and access its metadata, file type, modification time, and cover page. The with statement ensures proper resource handling. ```python from comicbox.box import Comicbox with Comicbox("comic.cbz") as cb: metadata = cb.to_dict() # merged, normalized metadata file_type = cb.get_file_type() # "CBZ", "PDF", ... mtime = cb.get_metadata_mtime() # last metadata modification time cover = cb.get_cover_page() # cover image bytes ``` -------------------------------- ### Pages, Covers & Conversion Commands Source: https://github.com/ajslater/comicbox/blob/main/README.md CLI commands for extracting covers or page ranges, converting CBR to CBZ, converting PDF pages to CBZ without re-encoding, and renaming to canonical format. ```sh # Extract the cover image. comicbox -X --dest-path ./out "comic.cbz" ``` ```sh # Extract a range of pages (zero-based) by index. comicbox -x 0:5 --dest-path ./out "comic.cbz" ``` ```sh # Convert a CBR to a CBZ, carrying metadata across. comicbox -z "comic.cbr" ``` ```sh # Convert a single-image-per-page comic PDF to CBZ without re-encoding. comicbox --cbz --pdf-pages image "comic.pdf" ``` ```sh # Rename a file to comicbox's canonical filename format. comicbox --rename "comic.cbz" ``` -------------------------------- ### Stress test run commands Source: https://github.com/ajslater/comicbox/blob/main/tests/stress/README.md Shell commands to run various stress tests with rate-limiter compliance, prompt-UX, and jobs-accuracy. Includes options for limits, jobs, cache wiping, and think-time. ```sh # Rate-limiter compliance: 10 fixtures, warm cache, jobs=4 uv run python -m tests.stress.run ~/Milliways/Comics/Test \ --limit 10 --jobs 4 --no-wipe-cache # Rate-limiter compliance: ~50 fixtures, cold cache, jobs=8 (the M7 spec'd test) uv run python -m tests.stress.run /path/to/fixtures --limit 50 --jobs 8 # Single source only (cheap iteration) uv run python -m tests.stress.run /path/to/fixtures --sources metron --limit 50 # Prompt-UX: 16 fixtures, jobs=8, 0.5s think-time per prompt uv run python -m tests.stress.prompt_ux /path/to/fixtures \ --limit 16 --jobs 8 --think-time 0.5 # Jobs-accuracy: 50 fixtures × jobs=1,4,8 cold cache, threshold 0.50 uv run python -m tests.stress.jobs_accuracy \ tests/calibration/fixtures-jobs.json \ --jobs 1,4,8 --limit 50 --threshold 0.5 ``` -------------------------------- ### Run with --sources metron Source: https://github.com/ajslater/comicbox/blob/main/tests/calibration/README.md Calibrate only Metron source, which has a more forgiving rate limit (20/min vs CV's 200/hr). ```sh uv run python -m tests.calibration.run --sources metron ``` -------------------------------- ### make calibrate-retry-sampled Source: https://github.com/ajslater/comicbox/blob/main/tests/calibration/README.md Faster than calibrate-retry; uses one representative fixture per series. Composes with --retry-misses and --filter. ```sh make calibrate-retry-sampled ``` -------------------------------- ### make calibrate-retry Source: https://github.com/ajslater/comicbox/blob/main/tests/calibration/README.md Re-runs only previously failed fixtures. Prefers fixtures.outcomes.json, falls back to fixtures.outcomes.partial.json. Writes to .partial.json, does not overwrite main outcomes. ```sh make calibrate-retry ``` -------------------------------- ### Write metadata with write_metadata helper Source: https://github.com/ajslater/comicbox/blob/main/README.md Use write_metadata to write metadata to a single comic file. The patch is the contents under the "comicbox" root tag; the root-wrapped dict from Comicbox.to_dict() is also accepted. Specify formats using MetadataFormats names like COMIC_INFO or METRON_INFO. ```python from comicbox.write import write_metadata result = write_metadata( "comic.cbz", # The patch is the contents under the "comicbox" root tag. The # root-wrapped dict Comicbox.to_dict() returns is also accepted. {"publisher": {"name": "SmallComics"}, "genres": ["Science Fiction"]}, formats=["COMIC_INFO"], # MetadataFormats names; e.g. COMIC_INFO, METRON_INFO ) print(result.written) ``` -------------------------------- ### bulk_write Source: https://github.com/ajslater/comicbox/blob/main/README.md Writes metadata to multiple comic files in a batched operation. ```APIDOC ## bulk_write ### Description Writes metadata to multiple comic files in a batched operation. This is a public helper for batch writing. ### Parameters - **paths** (list) - Required - List of paths to comic files. - **patch** (dict) - Required - Metadata patch. - **formats** (list) - Optional - List of `MetadataFormats` names. ### Returns - **results** (list) - List of result objects, each with a `written` attribute. ### Usage Example ```python from comicbox.write import bulk_write results = bulk_write( ["comic1.cbz", "comic2.cbz"], {"publisher": {"name": "SmallComics"}}, formats=["COMIC_INFO"], ) for result in results: print(result.written) ``` ``` -------------------------------- ### Predict write destination with predict_write_destination Source: https://github.com/ajslater/comicbox/blob/main/README.md Use predict_write_destination to determine where a write would land without opening the archive or reading metadata. It reports the destination path, whether the archive converts to CBZ, and if the destination is already occupied. ```python from comicbox.predict import predict_write_destination dest = predict_write_destination("comic.cbr") print(dest.destination, dest.converts, dest.occupied) ``` -------------------------------- ### Comicbox Class Source: https://github.com/ajslater/comicbox/blob/main/README.md The main read interface for Comicbox. Provides methods to access metadata, file type, metadata modification time, and cover page. ```APIDOC ## Comicbox Class ### Description The `Comicbox` class in `comicbox.box` is the main read interface for Comicbox. It provides methods to access metadata, file type, metadata modification time, and cover page. ### Methods #### `to_dict()` - **Description**: Returns merged, normalized metadata as a dictionary. - **Returns**: `dict` - Merged, normalized metadata. #### `get_file_type()` - **Description**: Returns the file type of the comic. - **Returns**: `str` - File type (e.g., "CBZ", "PDF"). #### `get_metadata_mtime()` - **Description**: Returns the last metadata modification time. - **Returns**: `float` - Last metadata modification time. #### `get_cover_page()` - **Description**: Returns the cover image bytes. - **Returns**: `bytes` - Cover image bytes. ### Usage Example ```python from comicbox.box import Comicbox with Comicbox("comic.cbz") as cb: metadata = cb.to_dict() # merged, normalized metadata file_type = cb.get_file_type() # "CBZ", "PDF", ... mtime = cb.get_metadata_mtime() # last metadata modification time cover = cb.get_cover_page() # cover image bytes ``` ``` -------------------------------- ### write_metadata Source: https://github.com/ajslater/comicbox/blob/main/README.md Writes metadata to a single comic file. Accepts a metadata patch and optional formats. ```APIDOC ## write_metadata ### Description Writes metadata to a single comic file. Accepts a metadata patch and optional formats. ### Parameters - **path** (str) - Required - Path to the comic file. - **patch** (dict) - Required - Metadata patch. The contents under the "comicbox" root tag. The root-wrapped dict from `Comicbox.to_dict()` is also accepted. - **formats** (list) - Optional - List of `MetadataFormats` names (e.g., `COMIC_INFO`, `METRON_INFO`). ### Returns - **result** (object) - An object with a `written` attribute indicating whether the write was successful. ### Usage Example ```python from comicbox.write import write_metadata result = write_metadata( "comic.cbz", {"publisher": {"name": "SmallComics"}, "genres": ["Science Fiction"]}, formats=["COMIC_INFO"], ) print(result.written) ``` ``` -------------------------------- ### predict_write_destination Source: https://github.com/ajslater/comicbox/blob/main/README.md Predicts where a write would land without opening the archive or reading metadata. ```APIDOC ## predict_write_destination ### Description Predicts where a write would land — in place, or the CBZ an unwritable archive repacks to — and whether that path is already taken, without opening the archive or reading any metadata. ### Parameters - **path** (str) - Required - Path to the comic file. ### Returns - **dest** (object) - An object with attributes: - `destination` (str) - The predicted destination path. - `converts` (bool) - Whether the file will be converted (e.g., to CBZ). - `occupied` (bool) - Whether the destination path is already taken. ### Usage Example ```python from comicbox.predict import predict_write_destination dest = predict_write_destination("comic.cbr") print(dest.destination, dest.converts, dest.occupied) ``` ```