ebooklib icon indicating copy to clipboard operation
ebooklib copied to clipboard

file_name should be a required parameter for EpubHtml()

Open grapemix opened this issue 6 years ago • 1 comments

Hi,

First, I would like to thanks for this awesome lib. Here is a low priority small bug I experienced while playing with this lib. When I called epub.EpubHtml(title="something) WITHOUT the file_name param, I got no error. However, I got this err when I try to call the write_epub().

. . . raise ValueError("no path specified") ValueError: no path specified

I think the file_name should be a required parameter for EpubHtml() for better debugging exp. Ty.

Update:

I found out that the ebook I created cannot be rendered by KOReader. After debugging, calibre's validation function pointed me to the media_type of the EpubHtml. I have to set the media_type to 'application/xhtml+xml' for KOreader to read it.

grapemix avatar Dec 30 '18 04:12 grapemix

Thanks!

Good point. Nothing is done until you start to create EPUB file and I am kind of OK that you don't have to specify everything in the constructor but on the other hand file_name is really required if you have inter file linking. Other possibility would be to generate file name from the title but then you have to check if title is defined. Yeah, maybe it would be best to make it required. Just have to see how this could break code people already have in the production.

About the media_type, it uses mimetype module to figure out the content type for different extensions but it also adds 'application/xhtml+xml' for '.xhtml'. Did you use .html or .xhtml extension?

Aco

aerkalov avatar Jan 02 '19 23:01 aerkalov