Skip to main content

epub-explorer

Epx reads epub files directly from ZIP, with no extraction needed. It auto-discovers a single .epub in the current directory, or you can pass a path explicitly.

Installation

Install latest from the GitHub repository:

$ pip install git+https://github.com/kafkasl/epub-explorer.git

How to use

Use the Epx() class to load a book. By default it will try to grab one in the current folder (if it’s the only one).

You can also pass a path to the book or set the env var EPX_BOOK.

b = Epx() # loads epub in the current folder
b
Chuang Tzu: Mystic, Moralist, and Social Reformer by Zhuangzi (42 sections)
b = Epx(path='chuang-tzu.epub')
b
Chuang Tzu: Mystic, Moralist, and Social Reformer by Zhuangzi (42 sections)

Table of contents

toc() maps spine indices to their TOC labels — these indices are what you pass to section():

b = Epx()
print(b.toc()[:300])
section  name
      0  wrap0000.xhtml
      1  Chuang Tzŭ
      2  CONTENTS.
      3  Introduction.
      4  Note on the Philosophy of Chaps. i-vii.
      5  CHAPTER I.
      6  CHAPTER II.
      7  CHAPTER III.
      8  CHAPTER IV.
      9  CHAPTER V.
     10  CHAPTER VI.
     11  CHAPTER VII.

Reading a section

section() converts any spine section to markdown:

print(b.section(5)[:200])
_Chuang Tzŭ._

![](2384639977200309426_i_decoline.jpg)

## CHAPTER I.

Transcendental Bliss.

_Argument_ :—Space infinite—Time infinite—Relativity of magnitudes, physical and moral—The magnitude absol

Searching

search() finds text anywhere in the book, ignoring case and markdown formatting; it returns section, line, internal path, and text records:

b.search('transcendental bliss')
[{'section': 2, 'line': 7, 'href': '887456179853867412_59709-h-1.htm.xhtml', 'text': 'CHAPTER| I | —Transcendental Bliss | [1](887456179853867412_59709-h-4.htm.xhtml#Page_1)  '}, {'section': 5, 'line': 7, 'href': '887456179853867412_59709-h-4.htm.xhtml', 'text': 'Transcendental Bliss.'}]

Images

Images can be extracted by their epub-internal path:

b.images()
['2384639977200309426_cover.jpg',
 '2384639977200309426_i_title.jpg',
 '2384639977200309426_i_title-image.jpg',
 '2384639977200309426_i_decoline.jpg',
 '2384639977200309426_i_decoline2.jpg']
b.img('2384639977200309426_cover.jpg')

Metadata

Release files for epub-explorer 0.0.2

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

Source distribution (sdist)

Source distribution for epub-explorer 0.0.2
File Size Uploaded
epub_explorer-0.0.2.tar.gz 11.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for epub-explorer 0.0.2
File Interpreter ABI Platform
epub_explorer-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 24.0 kB

Release files / epub_explorer-0.0.2.tar.gz

Download URL epub_explorer-0.0.2.tar.gz
Size 11.4 kB
Tags Source
SHA-256 checksum
How to use checksums
60a871034a0c884e95f7086e9a1e58a5aebd5abf5dce76fc6b5108509667db03
BLAKE2b-256 checksum
How to use checksums
40360139a27a7cc4b5f8a168dfea53edbb00465eb3aa9beee222b26857642297
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / epub_explorer-0.0.2-py3-none-any.whl

Download URL epub_explorer-0.0.2-py3-none-any.whl
Size 12.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2ff07ff3f76a96a588a96807c808932fdb396dc65d21bfb4483cdb17a8e630ca
BLAKE2b-256 checksum
How to use checksums
6266dbb4ecade9bd1a2f344ef66670c1c1d59840bdf980853b7bed499d8c6902
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.0.2 This release

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