Skip to main content

Ebook library which can handle EPUB2/EPUB3 format

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

EbookLib-autoupdate

This is a fork of the popular Ebooklib library that aims to keep a package updated with changes from the original codebase. Any changes to [https://github.com/aerkalov/ebooklib] are merged into this package on a weekly basis.

About EbookLib

EbookLib is a Python library for managing EPUB2/EPUB3 files. It's capable of reading and writing EPUB files programmatically.

We are working on refreshing the project so please check and comment if you have your own ideas what needs to happen with the project.

The API is designed to be as simple as possible, while at the same time making complex things possible too. It has support for covers, table of contents, spine, guide, metadata and etc.

EbookLib is used in Booktype from Sourcefabric, as well as sprits-it!, fanfiction2ebook, viserlalune and Telemeta.

Packages of EbookLib for GNU/Linux are available in Debian and Ubuntu.

Sphinx documentation is generated from the templates in the docs/ directory and made available at http://ebooklib.readthedocs.io

Usage

Reading

import ebooklib
from ebooklib import epub

book = epub.read_epub('test.epub')

for image in book.get_items_of_type(ebooklib.ITEM_IMAGE):
    print(image)

Writing

from ebooklib import epub

book = epub.EpubBook()

# set metadata
book.set_identifier("id123456")
book.set_title("Sample book")
book.set_language("en")

book.add_author("Author Authorowski")
book.add_author(
    "Danko Bananko",
    file_as="Gospodin Danko Bananko",
    role="ill",
    uid="coauthor",
)

# create chapter
c1 = epub.EpubHtml(title="Intro", file_name="chap_01.xhtml", lang="hr")
c1.content = (
    "<h1>Intro heading</h1>"
    "<p>Zaba je skocila u baru.</p>"
    '<p><img alt="[ebook logo]" src="static/ebooklib.gif"/><br/></p>'
)

# create image from the local image
image_content = open("ebooklib.gif", "rb").read()
img = epub.EpubImage(
    uid="image_1",
    file_name="static/ebooklib.gif",
    media_type="image/gif",
    content=image_content,
)

# add chapter
book.add_item(c1)
# add image
book.add_item(img)

# define Table Of Contents
book.toc = (
    epub.Link("chap_01.xhtml", "Introduction", "intro"),
    (epub.Section("Simple book"), (c1,)),
)

# add default NCX and Nav file
book.add_item(epub.EpubNcx())
book.add_item(epub.EpubNav())

# define CSS style
style = "BODY {color: white;}"
nav_css = epub.EpubItem(
    uid="style_nav",
    file_name="style/nav.css",
    media_type="text/css",
    content=style,
)

# add CSS file
book.add_item(nav_css)

# basic spine
book.spine = ["nav", c1]

# write to the file
epub.write_epub("test.epub", book, {})

License

EbookLib is licensed under the AGPL license.

Authors

Full list of authors is in AUTHORS.txt file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ebooklib_autoupdate-0.18.3.tar.gz (117.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ebooklib_autoupdate-0.18.3-py3-none-any.whl (27.6 kB view details)

Uploaded Python 3

File details

Details for the file ebooklib_autoupdate-0.18.3.tar.gz.

File metadata

  • Download URL: ebooklib_autoupdate-0.18.3.tar.gz
  • Upload date:
  • Size: 117.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.7.7

File hashes

Hashes for ebooklib_autoupdate-0.18.3.tar.gz
Algorithm Hash digest
SHA256 08f86d09a833127215bbf75a53fb0e207bac983eb0877d991b87717f03b6bf44
MD5 4fe045f0e7d10da3fa7330d7ebdc66c2
BLAKE2b-256 91382bf9dd128965536e09dd291d668235830f487700479bfe2338083db7acc9

See more details on using hashes here.

File details

Details for the file ebooklib_autoupdate-0.18.3-py3-none-any.whl.

File metadata

File hashes

Hashes for ebooklib_autoupdate-0.18.3-py3-none-any.whl
Algorithm Hash digest
SHA256 efcc63ecd64facb2e091e08116f8f17f814f195daab60709fed9215c979ee6c6
MD5 10835c094d351560529907b6789c504d
BLAKE2b-256 b94aa8f05d9b9dff45325516c0830690a1523e85896aba9b2da98e0589ccf9dd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page