Skip to main content

cipx

从 PDF、图片、压缩包和 EPUB 中提取 CIP 图书信息的 Python 工具。

Python License Documentation

安装

项目要求 Python 3.11 或更高版本。

pip install cipx

快速开始

from cipx import CIPX, extract

cipx = CIPX()

# 根据文件后缀自动分发到最合适的提取入口
result = cipx.extract("book.pdf")
print(result.success)
print(result.bookinfo.title)
print(result.bookinfo.isbn)

# 也可以直接调用顶层函数
result = extract("book.epub")
print(result.bookinfo.isbn)

如果你已经明确知道文件类型,也可以直接调用对应方法:

from cipx import CIPX

cipx = CIPX()

image_result = cipx.from_image("cover.jpg")
pdf_result = cipx.from_pdf("book.pdf")
epub_result = cipx.from_epub("book.epub")
archive_result = cipx.from_archive("book.uvz")

返回结果

提取结果是一个 ExtractResult 对象,常用字段包括:

  • success:是否提取成功
  • bookinfo:书目信息,包含 titleauthorpublisherpubdateisbncip
  • meta:源文件信息
  • locate:检测定位信息(图片、PDF、压缩包场景)
  • ocr:OCR 识别结果
  • elapsed:处理耗时
  • error:失败时的错误信息

bookinfo 还提供 isbn_validisbn13isbn10 等便捷属性。

配置

全局配置

from cipx.config import configure

configure(log_level="DEBUG", strict=3)

自定义 Settings

from cipx import CIPX
from cipx.config import Settings

settings = Settings(
	log_level="DEBUG",
	strict=4,
	detector={"conf_threshold": 0.5},
	ocr={"ocr_model": "medium"},
)

cipx = CIPX(config=settings)

支持格式

  • 图片:.jpg.jpeg.png
  • PDF:.pdf
  • EPUB:.epub
  • 压缩包:.zip.rar.uvz

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cipx-0.0.5.tar.gz (10.0 MB view details)

Uploaded Source

Built Distribution

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

cipx-0.0.5-py3-none-any.whl (10.0 MB view details)

Uploaded Python 3

File details

Details for the file cipx-0.0.5.tar.gz.

File metadata

  • Download URL: cipx-0.0.5.tar.gz
  • Upload date:
  • Size: 10.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for cipx-0.0.5.tar.gz
Algorithm Hash digest
SHA256 08202bd35eed2a011c0500b901c366f7748d6b1a2f9cbd240726238ac2113509
MD5 7c5a0839136dc3158bc5c2c015765fd1
BLAKE2b-256 a36255cb021aa2c8f15fdb352f61206d7a9d69891acd28a281b6881768c222b5

See more details on using hashes here.

File details

Details for the file cipx-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: cipx-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 10.0 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for cipx-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 cb1cbfb4d182a2d1488dd495c7a3dadf904ca67921475b68910e9923cbc57de5
MD5 12bde33ca0642bc84cd666e294681ae8
BLAKE2b-256 c2a46bfc3da7ab93ec30aed01a3fcb42eb2c5733d024500389cd1d6dd3864774

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.5 This release

2 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