epub-show-cover.py gets "IndexError: list index out of range" error
Closed this issue · 1 comments
RickVincent commented
Hi Antonios,
I am testing your tool "epub-show-cover.py", but constantly get below error with some of my epub books.
cover_id = t.xpath("//opf:metadata/opf:meta[@name='cover']",
IndexError: list index out of range
could you help to check?
Attached 2 opf files for your reference. (Pls unzip it due to uploading limitation of github.)
content.zip
content2.zip
Alamot commented
Well, some EPUB files do not declare explicitly a cover image. Instead, they use an img tag inside the first xhtmt file.
EPUB v2.0 should declare a cover image like this:
<metadata>
...
<meta name="cover" content="cover-image" />
...
</metadata>
<manifest>
...
<item href="cover.jpg" id="cover-image" media-type="image/jpeg" />
...
</manifest>
EPUB v3.0 should declare a cover image like this:
<manifest>
...
<item href="cover.jpg" id="cover-image" media-type="image/jpeg" properties="cover-image"/>
...
</manifest>
In any case, I added some code that tries to find an image inside the first xhtml file. You can try it.