Skip to main content

libbbf-python: Bound Book Format (BBF) Tools & Python Bindings

PyPI License: MIT

[!WARNING] Official Source Notice: Please only download resources from this repository (ef1500/libbbf-python). External mirrors or forks may contain malware.

Project Overview

libbbf-python provides Python bindings and command-line tools for the Bound Book Format (BBF). The Bound Book Format is an archive format designed for digital books and comics. This package allows Python developers to programmatically create and read .bbf files, and provides convenient command-line utilities to convert between common archive formats (like CBZ/CBX) and BBF.

The core of libbbf-python is a pybind11 wrapper around the high-performance C++ libbbf library, ensuring speed and native integration.

Features

  • libbbf Python Bindings: Access the full BBFBuilder (for creating BBF files) and BBFReader (for reading and extracting BBF files) functionality directly in Python.
  • cbx2bbf Command-Line Tool: Convert one or more CBZ/CBX archives (or directories of images) into a single .bbf file. Supports advanced features like custom page ordering, section markers (chapters, volumes), and metadata.
  • bbf2cbx Command-Line Tool: Extract the contents of a .bbf file back into a .cbz archive or an image directory. Supports integrity verification, section-specific extraction, and range extraction using keywords.
  • High Performance: Leverages C++ for core operations (file I/O, hashing, memory mapping) for optimal speed.
  • Integrity Checks: Built-in XXH3 hashing for robust data verification during creation and extraction.

Installation

You can install libbbf-python directly from PyPI:

pip install libbbf

Note on C++ Compiler: For platforms where pre-built binary wheels are not available (e.g., specific Linux distributions or older Python versions), pip will attempt to build the package from source. This requires a C++ compiler (like GCC/Clang on Linux/macOS or MSVC on Windows) to be installed on your system.

Command-Line Tools Usage

Once installed, two command-line tools will be available globally: cbx2bbf and bbf2cbx.

cbx2bbf: Create BBF Files from CBZ/Images

Usage:

cbx2bbf <inputs...> [options] --output <output.bbf>

Inputs: Can be individual image files (.png, .avif, .jpg), directories containing images, or .cbz/.cbx archives.

Options:

  • --output <output.bbf>, -o <output.bbf>: Required. Specifies the output BBF filename.
  • --order <path.txt>: Use a text file to define page order. Format: filename:index (e.g., cover.png:1, credits.png:-1 for last page).
  • --sections <path.txt>: Use a text file to define multiple sections. Format: Name:Target[:Parent].
  • --section "Name:Target[:Parent]": Add a single section marker. Target can be a 1-based page index or a filename. Example: --section "Chapter 1:001.png" or --section "Volume 1:my_comic.cbx:Series".
  • --meta "Key:Value": Add archival metadata (e.g., --meta "Title:Akira").

Examples:

  1. Basic Conversion:

    cbx2bbf my_comic.cbz -o output.bbf
    
  2. Converting Multiple CBZs with Sections and Metadata:

    cbx2bbf vol1.cbz vol2.cbz \
        --section "Volume 1:vol1.cbz" \
        --section "Volume 2:vol2.cbz" \
        --meta "Title:My Awesome Series" \
        --meta "Author:Me" \
        -o series.bbf
    

    (Note: vol1.cbz and vol2.cbz as targets will automatically map to the first page of those archives after sorting)

  3. Converting a Directory of Images with a Custom Order File:

    # pages.txt content:
    # cover.png:1
    # page001.png:2
    # ...
    # credits.png:-1
    
    cbx2bbf ./my_pages_folder/ --order pages.txt -o my_book.bbf
    

bbf2cbx: Extract BBF Files

Usage:

bbf2cbx <input.bbf> [options] --output <output.cbz_or_dir>

Options:

  • --output <output_path>, -o <output_path>: Required. Output .cbz file or directory name.
  • --dir: Extract to a directory instead of a .cbz archive.
  • --section "Name": Extract only a specific section defined in the BBF.
  • --rangekey "String": When extracting a section, find the end of extraction by matching this string against the next section's title. Useful for extracting "Vol 1" until "Vol 2" begins.
  • --verify: Perform a full XXH3 integrity check on all assets and the directory hash before extraction.
  • --info: Display book structure and metadata without extracting.

Examples:

  1. Extract entire BBF to CBZ with Verification:

    bbf2cbx my_book.bbf -o my_book_extracted.cbz --verify
    
  2. Extract a specific section to a folder:

    bbf2cbx series.bbf --section "Volume 1" --dir -o ./output/vol1/
    
  3. Extract a range using rangekey:

    bbf2cbx series.bbf --section "Volume 1" --rangekey "Volume 2" -o vol1_only.cbz
    
  4. Display BBF Information:

    bbf2cbx series.bbf --info
    

Using libbbf

You can also interface libbbf directly from python.

Example 1: Creating a .bbf file

from libbbf import BBFBuilder
import os

# Create a new Bound Book
builder = BBFBuilder("my_comic.bbf")

# Add Metadata
builder.add_metadata("Title", "Solo Leveling")
builder.add_metadata("Author", "Chugong")

# Add Pages (Assets are automatically deduplicated by hash!)
page_files = sorted(os.listdir("./chapter_images"))
for i, filename in enumerate(page_files):
    full_path = os.path.join("./chapter_images", filename)
    
    # Flags: 0 = Standard
    builder.add_page(full_path, type=1, flags=0) 

    # Define a Chapter every 20 pages
    if i % 20 == 0:
        builder.add_section(f"Chapter {i // 20 + 1}", start_page=i)

# Finalize writes the footer and optimized tables
builder.finalize()
print("BBF created successfully.")

Example 2: Verifying a .bbf file

import libbbf
import time

reader = libbbf.BBFReader("massive_archive.bbf")

print("Verifying file integrity...")
start = time.time()

# This releases the GIL, so it's thread-safe and incredibly fast
is_valid = reader.verify()

end = time.time()

if is_valid:
    print(f"SUCCESS: Integrity verified in {end - start:.4f}s")
else:
    print("ERROR: Corruption detected!")

Contributing

Contributions, issues, and feature requests are welcome! For libbbf, free to check the issues page (or create one if it doesn't exist yet).

License

This project is licensed under the MIT License - see the LICENSE file for details.


Metadata

Release files for libbbf 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for libbbf 0.3.0
File Size Uploaded
libbbf-0.3.0.tar.gz 88.0 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for libbbf 0.3.0
File
libbbf-0.3.0-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
libbbf-0.3.0-cp312-cp312-win32.whl CPython 3.12 CPython 3.12 Windows x86-32 Details
libbbf-0.3.0-cp312-cp312-musllinux_1_1_x86_64.whl CPython 3.12 CPython 3.12 Linux musl 1.1+ x86-64 Details
libbbf-0.3.0-cp312-cp312-musllinux_1_1_i686.whl CPython 3.12 CPython 3.12 Linux musl 1.1+ x86-32 Details
libbbf-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64 Details
libbbf-0.3.0-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-32 Details
libbbf-0.3.0-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
libbbf-0.3.0-cp312-cp312-macosx_10_9_x86_64.whl CPython 3.12 CPython 3.12 macOS 10.9+ x86-64 Details
libbbf-0.3.0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
libbbf-0.3.0-cp311-cp311-win32.whl CPython 3.11 CPython 3.11 Windows x86-32 Details
libbbf-0.3.0-cp311-cp311-musllinux_1_1_x86_64.whl CPython 3.11 CPython 3.11 Linux musl 1.1+ x86-64 Details
libbbf-0.3.0-cp311-cp311-musllinux_1_1_i686.whl CPython 3.11 CPython 3.11 Linux musl 1.1+ x86-32 Details
libbbf-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64 Details
libbbf-0.3.0-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-32 Details
libbbf-0.3.0-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details
libbbf-0.3.0-cp311-cp311-macosx_10_9_x86_64.whl CPython 3.11 CPython 3.11 macOS 10.9+ x86-64 Details

Total release size: 4.9 MB

Release files / libbbf-0.3.0.tar.gz

Download URL libbbf-0.3.0.tar.gz
Size 88.0 kB
Tags Source
SHA-256 checksum
How to use checksums
494fecb74ecd1d6fe3ac693ac75aa706ee36f0d1eda6a974a1e2d90751499bfc
BLAKE2b-256 checksum
How to use checksums
f82dd61ee955a3db550bc1cdd4c4efa6a4af432248e837dde30e9338ee6bd658
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.12

Release files / libbbf-0.3.0-cp312-cp312-win_amd64.whl

Download URL libbbf-0.3.0-cp312-cp312-win_amd64.whl
Size 129.2 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
9505f190af26d8fbb7e02cfba7a40c13f23c8cb09d4cd67efdf162ffce0aa217
BLAKE2b-256 checksum
How to use checksums
69eeed982b529530ff689502c0920643badd29a89eb06a426c8be9e0ba10ff8a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.12

Release files / libbbf-0.3.0-cp312-cp312-win32.whl

Download URL libbbf-0.3.0-cp312-cp312-win32.whl
Size 121.7 kB
Tags CPython 3.12 Windows x86-32
SHA-256 checksum
How to use checksums
9b393d06b6738ed2d2e8fb101355a2dedd456016458bd4fa50e04f7ce81e1f0c
BLAKE2b-256 checksum
How to use checksums
3fff383c8604a4072c1cd08f058c3c2880af4fc3d796ffb38c72c7c218112e96
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.12

Release files / libbbf-0.3.0-cp312-cp312-musllinux_1_1_x86_64.whl

Download URL libbbf-0.3.0-cp312-cp312-musllinux_1_1_x86_64.whl
Size 697.2 kB
Tags CPython 3.12 Linux musl 1.1+ x86-64
SHA-256 checksum
How to use checksums
b708a772394e8606f28f99ca8a58985e4825e0c9161f8510cbf1aafe3189c1ef
BLAKE2b-256 checksum
How to use checksums
450279f8fb38ec5e824c4cac5976ca946e7fdb311b00f529592899f1eca53983
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.12

Release files / libbbf-0.3.0-cp312-cp312-musllinux_1_1_i686.whl

Download URL libbbf-0.3.0-cp312-cp312-musllinux_1_1_i686.whl
Size 778.9 kB
Tags CPython 3.12 Linux musl 1.1+ x86-32
SHA-256 checksum
How to use checksums
aeac07d9b6f63b8175dfe57cb60246a2731b67f60824fc6e0486d0a8d905c04b
BLAKE2b-256 checksum
How to use checksums
085d007f28298128464a7d8d5ab4e52c148e467bd2f01dc1f66c0dbfa6d876be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.12

Release files / libbbf-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL libbbf-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 187.5 kB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
482ac5d53549b44a5453a110db038e3c5f2e5064bedcc863e6e21737d1a1866d
BLAKE2b-256 checksum
How to use checksums
35da88cc589542ed2c49ec92ef63dcb9e5e49a22ededc8a66739ebaf7296946a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.12

Release files / libbbf-0.3.0-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl

Download URL libbbf-0.3.0-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl
Size 218.0 kB
Tags CPython 3.12 Linux glibc 2.17+ x86-32
SHA-256 checksum
How to use checksums
622e8e5e0d2fd31d2c1d130ddb09aaeb4d70a3554a5da76f1091843c099e8eec
BLAKE2b-256 checksum
How to use checksums
96a324c364cb9473676893108199ad8fb29db72b80c5e50bfee58abead214feb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.12

Release files / libbbf-0.3.0-cp312-cp312-macosx_11_0_arm64.whl

Download URL libbbf-0.3.0-cp312-cp312-macosx_11_0_arm64.whl
Size 133.9 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
c9ccea179c7f01275540fb39769b05a776d9290ad9c41d41c278a3b3852b60af
BLAKE2b-256 checksum
How to use checksums
40a7e86b8984e2f5bb144dac311530d510027b8b4b44b8bb10479b84a03e9720
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.12

Release files / libbbf-0.3.0-cp312-cp312-macosx_10_9_x86_64.whl

Download URL libbbf-0.3.0-cp312-cp312-macosx_10_9_x86_64.whl
Size 142.1 kB
Tags CPython 3.12 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
f0231aa5a7378841bcdf64b43ec48de64817fb07326fbb280826febbd5025fe0
BLAKE2b-256 checksum
How to use checksums
37d6799bfb9c8bf554c09d60aa7b0aa3849cc96e6757c17608dc107d0ccae989
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.12

Release files / libbbf-0.3.0-cp311-cp311-win_amd64.whl

Download URL libbbf-0.3.0-cp311-cp311-win_amd64.whl
Size 127.8 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
dd280d258550a8a34d5d5e180695993efe0526a54c0e2bb17f9b5dd814613adf
BLAKE2b-256 checksum
How to use checksums
392ea060641999e2fd3055c202440c1da2d1d414ed1ad57a54bee7378b3fa275
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.12

Release files / libbbf-0.3.0-cp311-cp311-win32.whl

Download URL libbbf-0.3.0-cp311-cp311-win32.whl
Size 121.2 kB
Tags CPython 3.11 Windows x86-32
SHA-256 checksum
How to use checksums
00b3f911af506876bd789cf1806ac1b3d7d1c6aed3fdd0bffb22a8d56ff8fd88
BLAKE2b-256 checksum
How to use checksums
403e745248f212dca7ea6e2f6ac508fe7ec0b9f192f1bd1e381d1cad687f7922
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.12

Release files / libbbf-0.3.0-cp311-cp311-musllinux_1_1_x86_64.whl

Download URL libbbf-0.3.0-cp311-cp311-musllinux_1_1_x86_64.whl
Size 698.3 kB
Tags CPython 3.11 Linux musl 1.1+ x86-64
SHA-256 checksum
How to use checksums
475bbfe8c69e0b9a7bf55221e0a951ab92f931fbc3b50f2cbd19db0c1e4ab635
BLAKE2b-256 checksum
How to use checksums
5f2c2207c5ccaa67f1a99e0335221113a3cf344ef170ba9ae046c70dedf70e14
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.12

Release files / libbbf-0.3.0-cp311-cp311-musllinux_1_1_i686.whl

Download URL libbbf-0.3.0-cp311-cp311-musllinux_1_1_i686.whl
Size 779.4 kB
Tags CPython 3.11 Linux musl 1.1+ x86-32
SHA-256 checksum
How to use checksums
58a1fa03f11f4be4615a893a981eaafa5e30fa31c1516250c7069ab17535d45f
BLAKE2b-256 checksum
How to use checksums
79554b489d23f3a47e7f9ccc099eae3d5a4e2af4e8645b004bf9c5785329fe74
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.12

Release files / libbbf-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL libbbf-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 188.1 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
e1a5b75b72cb2989da83ba4edec633b5df5d39b166670ffb0de7c3f10fd52da1
BLAKE2b-256 checksum
How to use checksums
930f4701cf10fc9660012c783c2207e8fd67b8fa8dcd292fa00944fa7a9cbb62
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.12

Release files / libbbf-0.3.0-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl

Download URL libbbf-0.3.0-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl
Size 218.6 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-32
SHA-256 checksum
How to use checksums
9b6eb82fbff660868a1b5f9d412252bc69a2c63f2d37735bc6f8bc7283ce0f52
BLAKE2b-256 checksum
How to use checksums
c442a8e0e7daa291fea2e82df5b3f6b20ca220603db1aadd522e4136b22d28ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.12

Release files / libbbf-0.3.0-cp311-cp311-macosx_11_0_arm64.whl

Download URL libbbf-0.3.0-cp311-cp311-macosx_11_0_arm64.whl
Size 133.5 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
c44267679bd45d6145d93f86ee78b01ef19dc2b94d4b4be2b6ff5fd5e58951a6
BLAKE2b-256 checksum
How to use checksums
db6ba60d261753789c28a1ab9b1fd8419705c3568c8edf768d371e06b0be806b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.12

Release files / libbbf-0.3.0-cp311-cp311-macosx_10_9_x86_64.whl

Download URL libbbf-0.3.0-cp311-cp311-macosx_10_9_x86_64.whl
Size 140.8 kB
Tags CPython 3.11 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
83d17ff316a183f161ec0bdd741434f9b954281b79353fdc0c0816058f83f20e
BLAKE2b-256 checksum
How to use checksums
b4376b50a9b482614004cbc9d67b028b87ab7cd90ecd7cb4d4e3fc6cffa4f839
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.12

Release history Release notifications | RSS feed

This release

0.3.0 This release

17 release files

0.2.4

17 release 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