Skip to main content

Bound Book Format (BBF) tools and bindings

Project description

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.


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

libbbf-0.3.0.tar.gz (88.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

libbbf-0.3.0-cp312-cp312-win_amd64.whl (129.2 kB view details)

Uploaded CPython 3.12Windows x86-64

libbbf-0.3.0-cp312-cp312-win32.whl (121.7 kB view details)

Uploaded CPython 3.12Windows x86

libbbf-0.3.0-cp312-cp312-musllinux_1_1_x86_64.whl (697.2 kB view details)

Uploaded CPython 3.12musllinux: musl 1.1+ x86-64

libbbf-0.3.0-cp312-cp312-musllinux_1_1_i686.whl (778.9 kB view details)

Uploaded CPython 3.12musllinux: musl 1.1+ i686

libbbf-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (187.5 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

libbbf-0.3.0-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl (218.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ i686

libbbf-0.3.0-cp312-cp312-macosx_11_0_arm64.whl (133.9 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

libbbf-0.3.0-cp312-cp312-macosx_10_9_x86_64.whl (142.1 kB view details)

Uploaded CPython 3.12macOS 10.9+ x86-64

libbbf-0.3.0-cp311-cp311-win_amd64.whl (127.8 kB view details)

Uploaded CPython 3.11Windows x86-64

libbbf-0.3.0-cp311-cp311-win32.whl (121.2 kB view details)

Uploaded CPython 3.11Windows x86

libbbf-0.3.0-cp311-cp311-musllinux_1_1_x86_64.whl (698.3 kB view details)

Uploaded CPython 3.11musllinux: musl 1.1+ x86-64

libbbf-0.3.0-cp311-cp311-musllinux_1_1_i686.whl (779.4 kB view details)

Uploaded CPython 3.11musllinux: musl 1.1+ i686

libbbf-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (188.1 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

libbbf-0.3.0-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl (218.6 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ i686

libbbf-0.3.0-cp311-cp311-macosx_11_0_arm64.whl (133.5 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

libbbf-0.3.0-cp311-cp311-macosx_10_9_x86_64.whl (140.8 kB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

File details

Details for the file libbbf-0.3.0.tar.gz.

File metadata

  • Download URL: libbbf-0.3.0.tar.gz
  • Upload date:
  • Size: 88.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.12

File hashes

Hashes for libbbf-0.3.0.tar.gz
Algorithm Hash digest
SHA256 494fecb74ecd1d6fe3ac693ac75aa706ee36f0d1eda6a974a1e2d90751499bfc
MD5 3852008e125c941590dd5d440abe39db
BLAKE2b-256 f82dd61ee955a3db550bc1cdd4c4efa6a4af432248e837dde30e9338ee6bd658

See more details on using hashes here.

File details

Details for the file libbbf-0.3.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: libbbf-0.3.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 129.2 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

Hashes for libbbf-0.3.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 9505f190af26d8fbb7e02cfba7a40c13f23c8cb09d4cd67efdf162ffce0aa217
MD5 f157b2f3f8fe84312ed69b32e65c5b80
BLAKE2b-256 69eeed982b529530ff689502c0920643badd29a89eb06a426c8be9e0ba10ff8a

See more details on using hashes here.

File details

Details for the file libbbf-0.3.0-cp312-cp312-win32.whl.

File metadata

  • Download URL: libbbf-0.3.0-cp312-cp312-win32.whl
  • Upload date:
  • Size: 121.7 kB
  • Tags: CPython 3.12, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.12

File hashes

Hashes for libbbf-0.3.0-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 9b393d06b6738ed2d2e8fb101355a2dedd456016458bd4fa50e04f7ce81e1f0c
MD5 a0ce72a03819aaeaa5025f3c86ae8db7
BLAKE2b-256 3fff383c8604a4072c1cd08f058c3c2880af4fc3d796ffb38c72c7c218112e96

See more details on using hashes here.

File details

Details for the file libbbf-0.3.0-cp312-cp312-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for libbbf-0.3.0-cp312-cp312-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 b708a772394e8606f28f99ca8a58985e4825e0c9161f8510cbf1aafe3189c1ef
MD5 c6f315814989d39343c719bcceb76eb3
BLAKE2b-256 450279f8fb38ec5e824c4cac5976ca946e7fdb311b00f529592899f1eca53983

See more details on using hashes here.

File details

Details for the file libbbf-0.3.0-cp312-cp312-musllinux_1_1_i686.whl.

File metadata

File hashes

Hashes for libbbf-0.3.0-cp312-cp312-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 aeac07d9b6f63b8175dfe57cb60246a2731b67f60824fc6e0486d0a8d905c04b
MD5 286a0e4473587f0b1d64049033314bce
BLAKE2b-256 085d007f28298128464a7d8d5ab4e52c148e467bd2f01dc1f66c0dbfa6d876be

See more details on using hashes here.

File details

Details for the file libbbf-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for libbbf-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 482ac5d53549b44a5453a110db038e3c5f2e5064bedcc863e6e21737d1a1866d
MD5 f9dbf8265f11d3556396a8448d846ae4
BLAKE2b-256 35da88cc589542ed2c49ec92ef63dcb9e5e49a22ededc8a66739ebaf7296946a

See more details on using hashes here.

File details

Details for the file libbbf-0.3.0-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for libbbf-0.3.0-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 622e8e5e0d2fd31d2c1d130ddb09aaeb4d70a3554a5da76f1091843c099e8eec
MD5 8bfaba028ae78916f8d05fc42db57d7a
BLAKE2b-256 96a324c364cb9473676893108199ad8fb29db72b80c5e50bfee58abead214feb

See more details on using hashes here.

File details

Details for the file libbbf-0.3.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for libbbf-0.3.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c9ccea179c7f01275540fb39769b05a776d9290ad9c41d41c278a3b3852b60af
MD5 3e7e300703b447689f4f0866afe2c7c1
BLAKE2b-256 40a7e86b8984e2f5bb144dac311530d510027b8b4b44b8bb10479b84a03e9720

See more details on using hashes here.

File details

Details for the file libbbf-0.3.0-cp312-cp312-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for libbbf-0.3.0-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f0231aa5a7378841bcdf64b43ec48de64817fb07326fbb280826febbd5025fe0
MD5 fc4aa9a62b4c480a36e8483e9d093d43
BLAKE2b-256 37d6799bfb9c8bf554c09d60aa7b0aa3849cc96e6757c17608dc107d0ccae989

See more details on using hashes here.

File details

Details for the file libbbf-0.3.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: libbbf-0.3.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 127.8 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

Hashes for libbbf-0.3.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 dd280d258550a8a34d5d5e180695993efe0526a54c0e2bb17f9b5dd814613adf
MD5 dfe9c42f8895224afd977018b85fc8d1
BLAKE2b-256 392ea060641999e2fd3055c202440c1da2d1d414ed1ad57a54bee7378b3fa275

See more details on using hashes here.

File details

Details for the file libbbf-0.3.0-cp311-cp311-win32.whl.

File metadata

  • Download URL: libbbf-0.3.0-cp311-cp311-win32.whl
  • Upload date:
  • Size: 121.2 kB
  • Tags: CPython 3.11, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.12

File hashes

Hashes for libbbf-0.3.0-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 00b3f911af506876bd789cf1806ac1b3d7d1c6aed3fdd0bffb22a8d56ff8fd88
MD5 30ea1ffc69294164330daf93c15739df
BLAKE2b-256 403e745248f212dca7ea6e2f6ac508fe7ec0b9f192f1bd1e381d1cad687f7922

See more details on using hashes here.

File details

Details for the file libbbf-0.3.0-cp311-cp311-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for libbbf-0.3.0-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 475bbfe8c69e0b9a7bf55221e0a951ab92f931fbc3b50f2cbd19db0c1e4ab635
MD5 628939cae85d68a34a77cfdb5329bd86
BLAKE2b-256 5f2c2207c5ccaa67f1a99e0335221113a3cf344ef170ba9ae046c70dedf70e14

See more details on using hashes here.

File details

Details for the file libbbf-0.3.0-cp311-cp311-musllinux_1_1_i686.whl.

File metadata

File hashes

Hashes for libbbf-0.3.0-cp311-cp311-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 58a1fa03f11f4be4615a893a981eaafa5e30fa31c1516250c7069ab17535d45f
MD5 45211aea576dd5eecd93771f776709c3
BLAKE2b-256 79554b489d23f3a47e7f9ccc099eae3d5a4e2af4e8645b004bf9c5785329fe74

See more details on using hashes here.

File details

Details for the file libbbf-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for libbbf-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e1a5b75b72cb2989da83ba4edec633b5df5d39b166670ffb0de7c3f10fd52da1
MD5 30b3a8ace6256f9c5d402f9e29dd666b
BLAKE2b-256 930f4701cf10fc9660012c783c2207e8fd67b8fa8dcd292fa00944fa7a9cbb62

See more details on using hashes here.

File details

Details for the file libbbf-0.3.0-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for libbbf-0.3.0-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 9b6eb82fbff660868a1b5f9d412252bc69a2c63f2d37735bc6f8bc7283ce0f52
MD5 2c63d4c8b8f9e41dbb234cc2f20c0378
BLAKE2b-256 c442a8e0e7daa291fea2e82df5b3f6b20ca220603db1aadd522e4136b22d28ea

See more details on using hashes here.

File details

Details for the file libbbf-0.3.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for libbbf-0.3.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c44267679bd45d6145d93f86ee78b01ef19dc2b94d4b4be2b6ff5fd5e58951a6
MD5 e0a338d4b3f505c99818ed3494cdff6f
BLAKE2b-256 db6ba60d261753789c28a1ab9b1fd8419705c3568c8edf768d371e06b0be806b

See more details on using hashes here.

File details

Details for the file libbbf-0.3.0-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for libbbf-0.3.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 83d17ff316a183f161ec0bdd741434f9b954281b79353fdc0c0816058f83f20e
MD5 bd241eaa5342465ef1a5d415cfed9897
BLAKE2b-256 b4376b50a9b482614004cbc9d67b028b87ab7cd90ecd7cb4d4e3fc6cffa4f839

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page