I am investigating whether it is possible to generate an ebook, say, a Kindle book, programmatically. are there any libraries, open source or proprietary? in particular, for python.
An ebook or epub is just xhtml with some meta info and stuff. Every page is a xhtml file.
Here is a tutorial on How to Make an ePub eBook by Hand.
Many but especially see calibre which can take text in various forms or HTML and convert to epub, mobi etc.
For .epub, as others have said, any tool that can generate XHTML will work - partially. You may also need the ability to generate a .gz file, IIRC, since I think the outermost container for EPUB is of that format, but Python has support for that in the standard library. I think IBM developerWorks had a tutorial on how to generate EPUB format ebooks, maybe in Python. Search on their site for it. Liza Daly, founder of ThreePress, who specializes in publishing-related development (in Python) and is the creator of O'Reilly Bookworm, a web-based EPUB reading application, may also have some tools for generating EPUB on her site.
My own xtopdf toolkit (written in Python), which requires the open-source version of the Reportlab toolkit (also in Python) can be used to generate simple PDF ebooks from a set of text files, where each file represents a chapter of the book. In the xtopdf package (.zip / .gz file), there is a script called PDFBook.py which does this.
You can get xtopdf from here:
http://sourceforge.net/projects/xtopdf/
And this page has a guide to installing xtopdf and to using that PDFBook.py script:
http://www.mail-archive.com/[email protected]/msg100069.html
So if you can generate those chapter files as text, programmatically (which should be possible), you can combine that ability with the PDFBook.py program, to do what you need - programmatically generate ebooks - for the case of PDF ebooks.
If you need any help using xtopdf, feel free to contact me via my web site's contact page - dancingbison dot com slash contact dot html - use my Gmail address given there. The (hosted) site goes down for short periods sometimes, so if you can't access it, just try again sometime later.
HTH, Vasudev Ram
Amazon provides kindlegen which is a command line program for generating an ebook from XML/HTML sources.
I generated books for Stack Overflow content using a set of scripts available here (the code is a mix of Python, Java, and XSLT).
Another example is rss2mobi which generates ebooks from a Google Reader feed (this one is all Python).
© 2022 - 2024 — McMap. All rights reserved.