Skip to main content

Shortbox

PyPI - Python PyPI - Status PyPI - Version PyPI - License

prek Ruff ty

status-badge

An extensible library to manage comic archives and their embedded files and metadata.

Supported Formats

More can be added by extending the respective base class and adding to the registry.

Archives

Archive Extra Required
.cbz, .zip builtin
.cbt, .tar builtin
.cbr, .rar cbr
.cb7, .7z cb7
.pdf pdf

Compability Table

Format Read Update Create
cbz ✅ ✅ ✅
cbt ❌ ❌ ✅
cbr ✅ ❌ ❌
cb7 ✅ ❌ ✅
pdf ✅ ✅ ❌

If something is marked as in-compatible the library will try extracting and making the change via the local system and re-archive (if it has the create capability).

Metadata

Installation

pdm add shortbox

Optional extras can be added as needed:

pdm add shortbox[cbr,cb7,pdf]

Usage

from pathlib import Path

from shortbox import Comic
from shortbox.metadata import MetronInfo

my_comic = Path("MyComic.cbz")
with Comic.open(my_comic) as comic:
    print(comic.list_filenames())
    print(comic.read_file(filename="page-1.jpg").decode("UTF-8"))
    print(comic.metadata)  # Dict of registered metadata in archive

    metron_info = comic.get_metadata(metadata_type=MetronInfo)
    print(metron_info.series)

Writing files and metadata (support depends on the archive format, see table above):

with Comic.open(my_comic) as comic:
    comic.write_file(filename="page-99.jpg", data=b"...", override=True)
    comic.remove_file(filename="page-01.jpg")

    metron_info = comic.get_metadata(metadata_type=MetronInfo)
    metron_info.series.name = "Updated Title"
    comic.set_metadata(metron_info)

You can also convert between different archives (as long as the destination archive has create capability)

from shortbox.archives import ZipArchive

rar_comic = Path("MyComic.cbr")
with Comic.open(rar_comic) as comic:
    print(comic.file)  # MyComic.cbr
    comic.convert(
        ZipArchive, delete_original=True
    )  # All future comic interactions will be on the new archive
    print(comic.file)  # MyComic.cbz

Socials

Social - Matrix

Release files for shortbox 0.4.1

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

Source distribution (sdist)

Source distribution for shortbox 0.4.1
File Size Uploaded
shortbox-0.4.1.tar.gz 221.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for shortbox 0.4.1
File Interpreter ABI Platform
shortbox-0.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 241.6 kB

Release files / shortbox-0.4.1.tar.gz

Download URL shortbox-0.4.1.tar.gz
Size 221.5 kB
Tags Source
SHA-256 checksum
How to use checksums
3a4675af5ba611fcde807e5c513def34acdec5e3f1804954b8a00a46bafe09ae
BLAKE2b-256 checksum
How to use checksums
846f4a3471c28b09a3ee0edb0f180b7aa119a3f2fabe4e5f2594404ef92183d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.18 {"installer":{"name":"uv","version":"0.12.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / shortbox-0.4.1-py3-none-any.whl

Download URL shortbox-0.4.1-py3-none-any.whl
Size 20.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
259f40014a8207968619205bf449aaf380db9eb033653608f4bb351e67263aef
BLAKE2b-256 checksum
How to use checksums
cc912c18f7e1bcdd41aba9290c01189a3b0d077332ef22f80e0c75a81f4e9f7b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.18 {"installer":{"name":"uv","version":"0.12.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.4.1 This release

2 release files

0.4.0

2 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