isbnx
从 PDF、图片、EPUB、MOBI 和压缩包中智能提取 ISBN 号
安装
pip install isbnx
# 或
uv add isbnx
系统依赖
pyzbar(条形码解码):
- Windows: 需要安装 Visual C++ 运行库
- macOS: 设置环境变量
export DYLD_LIBRARY_PATH=/opt/homebrew/lib:$DYLD_LIBRARY_PATH
pdf-inspector(可选,PDF 类型检测): 参考安装
快速开始
from isbnx import extract
result = extract("cover.png")
if result.success:
print(result.bookinfo.isbn13) # 9787123456789
# 优先从文件名提取(跳过内容扫描,更快)
result = extract("9787123456789_三体.epub", filename=True)
CLI
isbnx cover.png # 提取并打印结果
isbnx --json book.pdf # JSON 格式输出
isbnx --strict 2 book.zip
isbnx --filename 9787123456789.epub # 从文件名提取
支持格式
| 类型 | 格式 | 提取策略 |
|---|---|---|
| 图片 | PNG / JPG / WebP / BMP / PDG | ONNX 检测 → OCR / 条码 |
| 文本搜索 / 渲染检测 | ||
| EPUB | EPUB | OPF 元数据 → XHTML 扫描 |
| MOBI | MOBI | EXTH 元数据 → 文本扫描 |
| 压缩包 | ZIP / RAR / 7Z / UVZ | meta.xml → bookinfo.dat → PDG 图片 |
批量处理
对整个目录进行批量 ISBN 提取与文件整理:
from isbnx.batch import Batch
result = Batch(
source_dir="D:/books",
success_dir="D:/books/done",
failed_dir="D:/books/unrecognized",
).run()
print(result)
也可配合 BatchConfig 自定义行为:
from isbnx.batch import Batch, BatchConfig
config = BatchConfig(
rename_mode=3, # 替换旧标识再追加(默认)
extensions={".epub", ".pdf"},
max_workers=4,
keep_tree=True, # 保留源目录结构
)
result = Batch(
source_dir="D:/books",
success_dir="D:/done",
failed_dir="D:/fail",
config=config,
try_run=True, # 先预览不实际移动
).run()
支持 4 种重命名模式、多线程并行、文件去重、干运行预览、CSV 报告导出、进度回调、优雅终止和源目录结构保留。
详细文档
完整文档、API 参考、提取流程请访问:
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
isbnx-0.0.18.tar.gz
(10.0 MB
view details)
Built Distribution
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
isbnx-0.0.18-py3-none-any.whl
(10.0 MB
view details)
File details
Details for the file isbnx-0.0.18.tar.gz.
File metadata
- Download URL: isbnx-0.0.18.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1a6ca8d299977951a9dfb9ba7e6acef7c83678d6adb42a3a82b9d9737f08dcf
|
|
| MD5 |
69a285d71f983987964aa1c8617421c1
|
|
| BLAKE2b-256 |
eb680c34b89764da491854a0d9494b9dc0f1cd5c5da3543484bca67449403e81
|
File details
Details for the file isbnx-0.0.18-py3-none-any.whl.
File metadata
- Download URL: isbnx-0.0.18-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef7662c5b6e8882e12327bb8f57d36be3d4eb23d5d55011b4442ee3f7a5c1356
|
|
| MD5 |
d5346f5bd1b482118d613f224b7ae4e4
|
|
| BLAKE2b-256 |
125fad0c22d8c30a05053fb2e96d9854220dae8e53c7fd189a4a67f71a052911
|