View Single Post
Old 04-05-2025, 01:44 AM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,400
Karma: 27756918
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
waaaaaaaaay too much work for an OS specific feature, at least for me. Though if someone is interested in building one that works with calibre, it would likely be doable by using the apple provided WKWebView to render HTML. The HTML would be extracted using

Code:
calibre-debug -c "from calibre.ebooks.oeb.iterator.book import extract_book; import sys; print(extract_book(sys.argv[-2], sys.argv[-1])[1])" /path/to/ebook/file /path/to/outputdir
Running that command will extract the book as HTML into outputdir and print out the path to the OPF file that lists all the HTML files resulting from the book. It should be trivial to parse the OPF and get the list of HTML files to display.

Whether this is fast enough for quicklook, is debatable though. You could improve its performance by writing a python script that runs a daemon to service requests avoiding the startup cost of running calibre-debug. The script can be run directly as

calibre-debug /path/to/script.py

then the script can listen for requests on STDIN or a socket and run extract_book and write the OPF path to STDOUT or the socket.
kovidgoyal is offline   Reply With Quote