Skip to main content

a python package to read ePub infos and edit it.

Project description

EpubEdit

EpubEdit is a Python package for viewing and editing EPUB file metadata.

Installation and Usage

  • Installation:
pip install epubedit
  • Usage:
from epubedit import Epubedit # import the library

book = Epubedit('book_name') # create Epubedit object 
book.get_metadata() 

Methods

  1. get_metadata -> str | List[str]
  2. get_selected_metadata -> Dict[str, str]
  3. get_all_metadata -> Dict[str, str]

1. get_metadata(str) -> str | List

Read the value of a single metadata

Supported parameters:

  • "epub_version"
  • "book_name"
  • "author_name"
  • "publisher_name"
  • "ISBN"
  • "ASIN"
  • "bookid"
  • "describe"
  • "language"
  • "rights"
  • "publication_date"

Example:

from epubedit import Epubedit

book = Epubedit("Moby Dick.epub")
print(book.get_metadata('book_name'))

Running results

Moby Dick; Or, The Whale

2. get_selected_metadata(Iterable[str]) -> Dict[str: str]

Pass a list and transmit the corresponding metadata values

from epubedit import Epubedit

book = Epubedit("Moby Dick.epub")
print(book.get_selected_metadata(["book_name", "epub_version", "language"]))

Running results

{"book_name": "Moby Dick; Or, The Whale", "epub_version": "3.0", "language": "en"}

3. get_all_metadata() -> Dict[str: str]

No input value, all metadata information is transmitted. If there is a lack of relevant information in EPUB, it will return str: "" or list: []

book = Epubedit('Moby Dick.epub')
print(book.get_all_metadata())

Running results

{
    "epub_version": "3.0",
    "rights": "Public domain in the USA.",
    "book_name": "Moby Dick; Or, The Whale",
    "author": ["Herman Melville"],
    "isbn": "",
    "asin": "",
    "publisher": "",
    "published_date": "",
    "modified_date": "2024-07-20T22:24:39Z",
    "language": "en",
    "subject": [
        "Whaling -- Fiction",
        "Sea stories",
        "Psychological fiction",
        "Ship captains -- Fiction",
        "Adventure stories",
        "Mentally ill -- Fiction",
        "Ahab, Captain (Fictitious character) -- Fiction",
        "Whales -- Fiction",
        "Whaling ships -- Fiction"
    ]
}

4. change_metadata(Dict[str: str]) -> None

book = Epubedit("your.epub")

book.change_metadata("epub_version", "3.0")
book.change_metadata("book_name", "new_name")
book.change_metadata("author_name", "new_author")
book.change_metadata("publisher_name", "new_publisher")

book.commit()

Links

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

epubedit-0.1.1.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

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

epubedit-0.1.1-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file epubedit-0.1.1.tar.gz.

File metadata

  • Download URL: epubedit-0.1.1.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.1

File hashes

Hashes for epubedit-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7cde5df09f6095f53252d3fd060f2bb95b43ad9cffe35118789dc5272a49093f
MD5 330e7822adb92bfa1517adbe48d2b739
BLAKE2b-256 8128664f1849fd6d7134bdc80b35d9d1f15b776f3d29fdcc97bd57740963a4a9

See more details on using hashes here.

File details

Details for the file epubedit-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: epubedit-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.1

File hashes

Hashes for epubedit-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a37add6c9351ea2a1c06f84390540baf15f75025cfdb08435b0502e6a51a117f
MD5 80a6fb3dcceace95792e2ce225dba06e
BLAKE2b-256 e7d8b34312d30d71b6106b7774a6b9e863b8bea8d3bf768a6672716bd93e3285

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