Bound Book Format (BBF) tools and bindings
Project description
libbbf-python: Bound Book Format (BBF) Tools & Python Bindings
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
libbbfPython Bindings: Access the fullBBFBuilder(for creating BBF files) andBBFReader(for reading and extracting BBF files) functionality directly in Python.cbx2bbfCommand-Line Tool: Convert one or more CBZ/CBX archives (or directories of images) into a single.bbffile. Supports advanced features like custom page ordering, section markers (chapters, volumes), and metadata.bbf2cbxCommand-Line Tool: Extract the contents of a.bbffile back into a.cbzarchive 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:-1for 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:
-
Basic Conversion:
cbx2bbf my_comic.cbz -o output.bbf
-
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.cbzandvol2.cbzas targets will automatically map to the first page of those archives after sorting) -
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.cbzfile or directory name.--dir: Extract to a directory instead of a.cbzarchive.--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:
-
Extract entire BBF to CBZ with Verification:
bbf2cbx my_book.bbf -o my_book_extracted.cbz --verify
-
Extract a specific section to a folder:
bbf2cbx series.bbf --section "Volume 1" --dir -o ./output/vol1/
-
Extract a range using
rangekey:bbf2cbx series.bbf --section "Volume 1" --rangekey "Volume 2" -o vol1_only.cbz
-
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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
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 libbbf-0.2.10.tar.gz.
File metadata
- Download URL: libbbf-0.2.10.tar.gz
- Upload date:
- Size: 86.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
170b667138b29a6a0ac14fdee4f1f5c25aeca6e5bfb179b69ddf797e05f0ce9d
|
|
| MD5 |
9ae90f5aca99d082e686b5c9d319fa4d
|
|
| BLAKE2b-256 |
635e632e1f731fc6cd9c01475cdc2bb8e3c90e17f1ecec5f376a174f53c7664d
|
File details
Details for the file libbbf-0.2.10-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: libbbf-0.2.10-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 128.9 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
507c8f5f4171910076aeb00511245ae9a6d2fbdff7b8bfcdb2adcae76d324eeb
|
|
| MD5 |
056e76730d372500850d6e3e39c0f2ff
|
|
| BLAKE2b-256 |
96cd184df0017bf1dbeffe6e7d647575e9a79ce177a0ac6aef7851cad5280d8b
|
File details
Details for the file libbbf-0.2.10-cp312-cp312-win32.whl.
File metadata
- Download URL: libbbf-0.2.10-cp312-cp312-win32.whl
- Upload date:
- Size: 120.8 kB
- Tags: CPython 3.12, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dada5e581e0cc800e2caed30e95021633cc7e19753e81eb61f23a40377ffdd1d
|
|
| MD5 |
6206b4ccbbe81fed6f992ce77f70bc19
|
|
| BLAKE2b-256 |
09e90e8492a1a6a9166c058bb2d85654d70e8359a8b8fbf3fc42964832ffb751
|
File details
Details for the file libbbf-0.2.10-cp312-cp312-musllinux_1_1_x86_64.whl.
File metadata
- Download URL: libbbf-0.2.10-cp312-cp312-musllinux_1_1_x86_64.whl
- Upload date:
- Size: 688.0 kB
- Tags: CPython 3.12, musllinux: musl 1.1+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f97c3f889b17929300034ef7f54b4bb27d67875f23c5e2a7203e46f4cca26a78
|
|
| MD5 |
28c2b677eea438718fac7be677cb769d
|
|
| BLAKE2b-256 |
b978592056d558a1166cf74ed28c295a4168e84ba807c55e358659a72dd8144b
|
File details
Details for the file libbbf-0.2.10-cp312-cp312-musllinux_1_1_i686.whl.
File metadata
- Download URL: libbbf-0.2.10-cp312-cp312-musllinux_1_1_i686.whl
- Upload date:
- Size: 761.6 kB
- Tags: CPython 3.12, musllinux: musl 1.1+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eccb117aeeb5345c8614bdf57a5203d58df36609ee8aa8749d3712ce71cfe64c
|
|
| MD5 |
c4aba98b06452394d16967a21a4d5d0a
|
|
| BLAKE2b-256 |
da4e9a85da5ed6af0c7209d370c8def67b61b4459642b649e23e945c6af7e1a9
|
File details
Details for the file libbbf-0.2.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: libbbf-0.2.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 178.5 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b2a524966f18e127fff5388a02263eeb646ee2ba3d3ccab37d705991eaf2b7bf
|
|
| MD5 |
547ab8ac97d0baeee164e0bedffd1f8a
|
|
| BLAKE2b-256 |
e666bb4c6f661a0a2e693d59f95d38b416c2d0487d8adbf22d7335fad03f8719
|
File details
Details for the file libbbf-0.2.10-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl.
File metadata
- Download URL: libbbf-0.2.10-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 198.2 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ebefaf349fafdf88ac79867ae2222cdfd63808dd1aa6b077f26b19707900bd11
|
|
| MD5 |
88dcf6c9fd224660ef081ecbaec40c3c
|
|
| BLAKE2b-256 |
04ab7cf800435174cde152424b74808cf4f65a02063b5bceb502b85ee4cde641
|
File details
Details for the file libbbf-0.2.10-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: libbbf-0.2.10-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 121.7 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c53779c018bb08fe3aee2ccc4665d93b75971f5d027ab018dd002c65a8f37410
|
|
| MD5 |
2440b995c24371cb27171282a6c5e660
|
|
| BLAKE2b-256 |
e64afbac01298223f41fd9791c721571ab82f5d8cd4856fdfcb373570ffe7e2a
|
File details
Details for the file libbbf-0.2.10-cp312-cp312-macosx_10_9_x86_64.whl.
File metadata
- Download URL: libbbf-0.2.10-cp312-cp312-macosx_10_9_x86_64.whl
- Upload date:
- Size: 129.0 kB
- Tags: CPython 3.12, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9cc1bdb4a3e7a53846a91bd95eecdd20b27a90b3b08e2fef384f10bfeb85d94a
|
|
| MD5 |
b83ec04eca8a42ed8c7f80729c842431
|
|
| BLAKE2b-256 |
e492d989f278ac6cb310dea88613f48a6dd2e6bbf23ca3c5e725e8c9eb33eaac
|
File details
Details for the file libbbf-0.2.10-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: libbbf-0.2.10-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 127.5 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
376eb6f54b1eb9d236b4f8e702e098a6e866aadae75462fab40cac65a8543f5c
|
|
| MD5 |
c238a0f8eb46761ebf2b43a8dc825ea6
|
|
| BLAKE2b-256 |
784ef2eac282de51b4340c835d4bb1d478ba7df39bdc95a216cf2eea7d4a8219
|
File details
Details for the file libbbf-0.2.10-cp311-cp311-win32.whl.
File metadata
- Download URL: libbbf-0.2.10-cp311-cp311-win32.whl
- Upload date:
- Size: 120.3 kB
- Tags: CPython 3.11, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27642a1f90466e03bcaabef15faaa149bdaf9e26e28c18117bece2cdbcc02196
|
|
| MD5 |
52d82b74907b9d64d308472c93bff3da
|
|
| BLAKE2b-256 |
8c1f1908f935d7c2eed83f74415abbef331faf1c6fdc2c78fbc581fa74c45f76
|
File details
Details for the file libbbf-0.2.10-cp311-cp311-musllinux_1_1_x86_64.whl.
File metadata
- Download URL: libbbf-0.2.10-cp311-cp311-musllinux_1_1_x86_64.whl
- Upload date:
- Size: 688.3 kB
- Tags: CPython 3.11, musllinux: musl 1.1+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64311de786b7b2fd606f6239dab7548469ac3ad03ca370672d05a2b425888682
|
|
| MD5 |
7374eeae86da04ddb73a857cc16fd157
|
|
| BLAKE2b-256 |
f13f6f8fc0eade634f47a85a52a89215388c25ead1785b7a0c7e033f5dd3c4c2
|
File details
Details for the file libbbf-0.2.10-cp311-cp311-musllinux_1_1_i686.whl.
File metadata
- Download URL: libbbf-0.2.10-cp311-cp311-musllinux_1_1_i686.whl
- Upload date:
- Size: 762.3 kB
- Tags: CPython 3.11, musllinux: musl 1.1+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bad900e73c0a80f7fc3979f46b633415e4163a67d239119b78d279f02a6e3320
|
|
| MD5 |
fd3d044049ae8330766973b294b3cd44
|
|
| BLAKE2b-256 |
560cbed9f29d6a06c24d263ad21e51873477d826f237e2b4995ae2c92bd388b5
|
File details
Details for the file libbbf-0.2.10-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: libbbf-0.2.10-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 180.2 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
80e9d11e77be4870ec67574f3f43a99c1572bfafcb88052c7c1ba9906673eae7
|
|
| MD5 |
b4195ef5c501fdebc2c11875c133b528
|
|
| BLAKE2b-256 |
c2b9d145eacf2f0428a364d081f0aa31e5ec0e8ef52ac6d3d7104e0f5b591869
|
File details
Details for the file libbbf-0.2.10-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl.
File metadata
- Download URL: libbbf-0.2.10-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 199.1 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef1c19611bf737e8b3e00b4e8ffde6cd29aa0c332b29b64e995b6cb839949e53
|
|
| MD5 |
dac35c90141344c12492ae76bc48c8c6
|
|
| BLAKE2b-256 |
0448bf336061f76b64114e3309d4d484687e17af4351b2d76b306ff907a69a5a
|
File details
Details for the file libbbf-0.2.10-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: libbbf-0.2.10-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 121.1 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e499afe9c8fc4de670897536f4a8569e1ec0c150f8faf6cd2e7c0f3268dff500
|
|
| MD5 |
b28a36eb73c3b00f474d9df1e692b7d4
|
|
| BLAKE2b-256 |
2fb9cd3f9b61959d5aec0f6de8fd51501526cc6a89dff7dc6c9625744293ddb3
|
File details
Details for the file libbbf-0.2.10-cp311-cp311-macosx_10_9_x86_64.whl.
File metadata
- Download URL: libbbf-0.2.10-cp311-cp311-macosx_10_9_x86_64.whl
- Upload date:
- Size: 127.9 kB
- Tags: CPython 3.11, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7df4d393f79c2cf2a72deb1afa13ca695e37e1924728089cfa906f61dad04cec
|
|
| MD5 |
b92b96b1f5c2171ebff402a8975e0223
|
|
| BLAKE2b-256 |
83f3c8314e5d380a1b8321b28e85b417950bfb8100ae71507a7c19b0c9458de5
|