Thread: eBookCleaner
View Single Post
Old 02-16-2012, 03:51 AM   #8
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: 26,120
Karma: 5101571
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
The API to get and set a file in a calibre book record is simply

Code:
# This will get the epub format for the book identified by id=book_id. The epub file will be copied to a temp file and the path to the temp file will be returned.
db.format(book_id, 'epub', index_is_id=True, as_path=True)

# This will set the epub format for the book record identified by book_id
stream = open(path_to_file, 'rb')
db.add_format(book_id, 'epub', stream, index_is_id=True)
For the rest of the plugin API, see the examples in this tutorial: http://manual.calibre-ebook.com/creating_plugins.html
kovidgoyal is online now   Reply With Quote