Parse an ebook based on its TOC into a tree-like structure
Project description
ebook-tree-parser
use ebooklib to parse a tree-like structure from ebooks from the TOC
Usage
from ebooklib import epub
from ebook_tree_parser.toctree import TocTree
file = "../data/frankenstein.epub"
book = epub.read_epub(file, options={'ignore_ncx': False})
estimator = lambda string: len(string)*4
tree = TocTree(book, token_estimator=estimator)
print(tree)
for node in tree3:
print("----")
print(f"{node.title}|{node.content_token_count}\n{node.content[:50]}")
print("----")
Development
- Create a virtual environment
- pip install -e .
- Make sure to update pyproject.toml with the correct dependencies
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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
File details
Details for the file ebook_tree_parser-0.1.2.tar.gz.
File metadata
- Download URL: ebook_tree_parser-0.1.2.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
866443cbb0c6331ec0eaa0078b7465ab1585fc472bcf839c5caba087da674bf9
|
|
| MD5 |
28a26b126cbc1dd85963eb4f25064098
|
|
| BLAKE2b-256 |
66dadd0c06c4323059d92f8b45c3162746ecbfac568c96e0b39675090c22cfc6
|
File details
Details for the file ebook_tree_parser-0.1.2-py3-none-any.whl.
File metadata
- Download URL: ebook_tree_parser-0.1.2-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
26643dd1443d34a927c9bfd503a15401afc2ee38f40379ed49fab334339ad970
|
|
| MD5 |
f71273994873889742b22b742bbea3a8
|
|
| BLAKE2b-256 |
4cdf21e4c5a0a31975fc09013443d5fb2892fe8581dd4c54ddec4bd097e9afab
|