EpubEdit is a Python package for viewing and editing EPUB file metadata.
- Installation:
pip install epubedit- Usage:
from epubedit import Epubedit # import the library
book = Epubedit('book_name') # create Epubedit object
book.get_metadata() - get_metadata ->
str|List[str] - get_selected_metadata ->
Dict[str, str] - get_all_metadata ->
Dict[str, str]
Read the value of a single metadata
- "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 WhalePass 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"}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"
]
}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()