Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get EPUB version number #274

Open
gregoriopellegrino opened this issue Jan 23, 2023 · 1 comment
Open

How to get EPUB version number #274

gregoriopellegrino opened this issue Jan 23, 2023 · 1 comment

Comments

@gregoriopellegrino
Copy link

I am currently working on a project that involves processing EPUB files and I am using the EbookLib library to do so. I am trying to extract the version number of the EPUB file (EPUB 2 or EPUB 3, etc.), but I am not sure how to do it using this library.

Is there a specific method?

@judelgadoc
Copy link

If you look at epub.py there's an attribute of the EpubBook class called EPUB_VERSION (line 549) and another one called version (line 1434). I don't know if it's a bug, but apparently EPUB_VERSION it's always set to None, therefore if you do something like

from ebooklib import epub

book = epub.read_epub("tsb.epub")
print(book.version)
print(book.EPUB_VERSION)

the output is

3.0
None

I think book.version is created after loading the file, because if you do it on a book created with the library, it throws AttributeError: 'EpubBook' object has no attribute 'version' but if you save that EPUB and then load the file created it works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants