View Single Post
Old 05-10-2017, 05:09 PM   #54
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Yay, the server beta is finally released! Now I can stop promising people that "it's supposed to be coming soon, your long-awaited bookmarks/annotations paradise is nigh".

Quote:
Originally Posted by latepaul View Post
At home I've got a script I use to add books and populate custom columns with initial values. It uses calibredb a lot - so I'll try that when I get back.
It would probably be a lot more efficient to write it in python using `calibre-debug` to run it. You can use the database API.

Example snippet to initialize your library so you can modify it via the "cache" object:

Code:
#!/usr/bin/calibre-debug

def init_cache(library_path=None):
    if library_path:
        from calibre.utils.filename import import expanduser
        library_path = expanduser(library_path)
    else:
        from calibre.utils.config import prefs
        library_path = prefs['library_path']
    from calibre.db.backend import DB
    from calibre.db.cache import Cache
    backend = DB(library_path)
    cache = Cache(backend)
    cache.init()
    return cache

cache = init_cache()
eschwartz is offline   Reply With Quote