Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

10 Commits

Folders and files

Repository files navigation

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/AnswerDotAI/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')

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages