-
Notifications
You must be signed in to change notification settings - Fork 235
Home
Aleksandar Erkalović edited this page May 7, 2013
·
35 revisions
EbookLib is a Python library for managing EPUB2/EPUB3 and Kindle files. It's capable of reading and writing EPUB files programmatically (Kindle support is under development).
The API is designed to be as simple as possible, while at the same time making complex things possible too. Check sample code. It has support for covers, table of contents, spine, guide, metadata and etc.
from ebooklib import epub
book = epub.EpubBook()
# add metadata
book.set_identifier('sample123456')
book.set_title('Sample book')
book.set_language('en')
book.add_author('Aleksandar Erkalovic')
# intro chapter
c1 = epub.EpubHtml(title='Introduction', file_name='intro.xhtml', lang='en')
c1.content=u'<h1>Introduction</h1><p>Introduction paragraph.</p>
book.add_item(c1)
book.toc = (epub.Link('intro.xhtml', 'Introduction', 'intro'),
(epub.Section('Languages'),
(c1, ))
)
# add navigation files
book.add_item(epub.EpubNcx())
book.add_item(epub.EpubNav())
style = 'BODY { color: black; }
nav_css = epub.EpubItem(uid="style_nav", file_name="style/nav.css", media_type="text/css", content=style)
book.add_item(nav_css)
# create spine
book.spine = ['nav', c1]
# create epub file
epub.writeEPUB('test.epub', book, {})
- Roadmap
- FAQ
EbookLib is licensed under the AGPL license.