Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Ebookmeta is a Python library for managing epub2, epub3 and fb2 files metadata.
Library allows you to read and write some of the metadata fields of epub2, epub3 and fb2 files.
The following fields can be read: identifier, title, authors, tags, book series and series index, language, description, translators, and cover data (image as byte array, file name, and media type). It is possible to write all fields, excluding description and identifier.
When changing the cover, the library does not check whether the image byte array matches the media type. You must ensure that this data is correct.
There is a limitation for epub files: you can't add cover if it doesn't exist in file. You can only replace an existing cover.
This library used in my other project Libro2 - GUI tool for editing metadata, rename and convert to other formats for ebook files.
pip3 install ebookmeta
python3 setup.py install
import ebookmeta
meta = ebookmeta.get_metadata('test.epub') # returning Metadata class
print(meta.title)
for author in metadata.authors:
print(author)
import ebookmeta
meta = ebookmeta.get_metadata('test.epub')
meta.title = 'New book title'
meta.set_author_list(['Isaac Azimov, Arthur Charles Clarke'])
ebookmeta.set_metadata('test.epub', meta) # Set epub metadata from Metadata class
Metadata.get_filename_by_pattern(filename_pattern, author_pattern) Return the filename, based on template. Template can contain placeholders, path delimiters, and any other characters that are included in the output without modification. Usage:
meta = ebook.get_metadata('oldfilename.epub')
new_filename = meta.get_filename_by_pattern('#Author. #Title', '#l{ #fi.}')
For example, for epub Azimov's Foundation book, return "Azimov I. Foundation.epub" string.
You can group template parts into optional blocks. An optional block is denoted with curly braces {}. An optional block must contain only one placeholder and any number of other characters. The optional block is completely excluded from the result if the value of the placeholder is None. Optional blocks can't be nested. Usage:
meta1 = ebook.get_metadata('book_with_series.epub')
meta2 = ebook.get_metadata('book_without_series.epub')
meta1.get_filename_by_pattern('/books/#Author/{#Series/}{#Number. }#Title', '#l{ #fi.}')
meta2.get_filename_by_pattern('/books/#Author/{#Series/}{#Number. }#Title', '#l{ #fi.}')
For example, for epub Azimov's Foundation book if metadata contains series and series_index (Foundation 1), return "/books/Azimov I/Foundation/1. Foundation.epub". For epub Azimov,s I, robot return "/books/Azimov I/I, robot.epub".
Possible filename placeholders:
РЈou can change the letter case of the placeholder value, just put the placeholder name in the right case. For example:
Possible author name placeholders:
FAQs
Read/write ebook metadata for fb2, epub2 and epub3 files
We found that ebookmeta demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.