Skip to content

childeyouyu/epubedit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EpubEdit

PyPI version

Downloads Downloads last 6 month Downloads Downloads

PyPI - License LOC

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"
    ]
}

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

About

a python package to read ePub infos and edit it.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages