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.
Install latest from the GitHub repository:
$ pip install git+https://github.com/AnswerDotAI/epub-explorer.gitUse 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
bChuang Tzu: Mystic, Moralist, and Social Reformer by Zhuangzi (42 sections)
b = Epx(path='chuang-tzu.epub')
bChuang Tzu: Mystic, Moralist, and Social Reformer by Zhuangzi (42 sections)
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.
section() converts any spine section to markdown:
print(b.section(5)[:200])_Chuang Tzŭ._

## CHAPTER I.
Transcendental Bliss.
_Argument_ :—Space infinite—Time infinite—Relativity of magnitudes, physical and moral—The magnitude absol
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 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')