{"id":13595415,"url":"https://github.com/aerkalov/ebooklib","last_synced_at":"2025-05-14T08:06:45.874Z","repository":{"id":38375477,"uuid":"9857325","full_name":"aerkalov/ebooklib","owner":"aerkalov","description":"A versatile Python library for EPUB2/EPUB3 manipulation and processing.","archived":false,"fork":false,"pushed_at":"2025-05-10T12:35:32.000Z","size":900,"stargazers_count":1617,"open_issues_count":101,"forks_count":236,"subscribers_count":40,"default_branch":"master","last_synced_at":"2025-05-10T13:40:03.361Z","etag":null,"topics":["epub","python","python-library"],"latest_commit_sha":null,"homepage":"https://ebooklib.readthedocs.io/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aerkalov.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.txt","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.txt","dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2013-05-04T17:10:18.000Z","updated_at":"2025-05-10T13:10:47.000Z","dependencies_parsed_at":"2024-01-15T03:59:18.274Z","dependency_job_id":"1ab88648-3e75-435f-b11c-43303a24d30e","html_url":"https://github.com/aerkalov/ebooklib","commit_stats":{"total_commits":145,"total_committers":38,"mean_commits":"3.8157894736842106","dds":0.4758620689655172,"last_synced_commit":"a55089afc40042e2dcaddd2fc7364192f0b3ca0a"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aerkalov%2Febooklib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aerkalov%2Febooklib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aerkalov%2Febooklib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aerkalov%2Febooklib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aerkalov","download_url":"https://codeload.github.com/aerkalov/ebooklib/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253425395,"owners_count":21906498,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["epub","python","python-library"],"created_at":"2024-08-01T16:01:49.598Z","updated_at":"2025-05-14T08:06:40.861Z","avatar_url":"https://github.com/aerkalov.png","language":"Python","readme":"# About EbookLib\n\nEbookLib is a Python library for managing EPUB2/EPUB3 and Kindle files. It's capable of reading and writing EPUB files programmatically.\n\nWe are working on [refreshing the project](https://github.com/aerkalov/ebooklib/issues/318) so please check and comment if you have your own ideas what needs to happen with the project.\n\nThe 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.\n\nEbookLib is used in [Booktype](https://github.com/sourcefabric/Booktype/) from Sourcefabric, as well as [sprits-it!](https://github.com/the-happy-hippo/sprits-it), [fanfiction2ebook](https://github.com/ltouroumov/fanfiction2ebook), [viserlalune](https://github.com/vjousse/viserlalune) and [Telemeta](https://github.com/Parisson/Telemeta).\n\nPackages of EbookLib for GNU/Linux are available in [Debian](https://packages.debian.org/python-ebooklib) and [Ubuntu](http://packages.ubuntu.com/python-ebooklib). \n\nSphinx documentation is generated from the templates in the docs/ directory and made available at http://ebooklib.readthedocs.io\n\n# Usage\n\n## Reading\n```py\nimport ebooklib\nfrom ebooklib import epub\n\nbook = epub.read_epub('test.epub')\n\nfor image in book.get_items_of_type(ebooklib.ITEM_IMAGE):\n    print(image)\n```\n\n\n## Writing\n```py\nfrom ebooklib import epub\n\nbook = epub.EpubBook()\n\n# set metadata\nbook.set_identifier(\"id123456\")\nbook.set_title(\"Sample book\")\nbook.set_language(\"en\")\n\nbook.add_author(\"Author Authorowski\")\nbook.add_author(\n    \"Danko Bananko\",\n    file_as=\"Gospodin Danko Bananko\",\n    role=\"ill\",\n    uid=\"coauthor\",\n)\n\n# create chapter\nc1 = epub.EpubHtml(title=\"Intro\", file_name=\"chap_01.xhtml\", lang=\"hr\")\nc1.content = (\n    \"\u003ch1\u003eIntro heading\u003c/h1\u003e\"\n    \"\u003cp\u003eZaba je skocila u baru.\u003c/p\u003e\"\n    '\u003cp\u003e\u003cimg alt=\"[ebook logo]\" src=\"static/ebooklib.gif\"/\u003e\u003cbr/\u003e\u003c/p\u003e'\n)\n\n# create image from the local image\nimage_content = open(\"ebooklib.gif\", \"rb\").read()\nimg = epub.EpubImage(\n    uid=\"image_1\",\n    file_name=\"static/ebooklib.gif\",\n    media_type=\"image/gif\",\n    content=image_content,\n)\n\n# add chapter\nbook.add_item(c1)\n# add image\nbook.add_item(img)\n\n# define Table Of Contents\nbook.toc = (\n    epub.Link(\"chap_01.xhtml\", \"Introduction\", \"intro\"),\n    (epub.Section(\"Simple book\"), (c1,)),\n)\n\n# add default NCX and Nav file\nbook.add_item(epub.EpubNcx())\nbook.add_item(epub.EpubNav())\n\n# define CSS style\nstyle = \"BODY {color: white;}\"\nnav_css = epub.EpubItem(\n    uid=\"style_nav\",\n    file_name=\"style/nav.css\",\n    media_type=\"text/css\",\n    content=style,\n)\n\n# add CSS file\nbook.add_item(nav_css)\n\n# basic spine\nbook.spine = [\"nav\", c1]\n\n# write to the file\nepub.write_epub(\"test.epub\", book, {})\n```\n\n\n# License\nEbookLib is licensed under the [AGPL license](LICENSE.txt).\n\n\n# Authors\nFull list of authors is in [AUTHORS.txt](AUTHORS.txt) file.\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faerkalov%2Febooklib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faerkalov%2Febooklib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faerkalov%2Febooklib/lists"}