Quote:
Originally Posted by kovidgoyal
library specific preferences are stored in metadatadb from where you should be able to easily extract them using any sqlite library. If you want to do it using calibre, all you need to do is:
Code:
calibre-debug -c "import sys, pprint; from calibre.library import db; db = db(sys.argv[-1]); pprint.pprint(db.prefs)" "/path/to/library/folder"
If you prefer json output replace pprint.pprint(db.prefs) with
Code:
import json; print(json.dumps(db.prefs, indent=2, sort_keys=True))
|
Kovid,
The batch file I used, using your one-liner spit out a log that looked bereft of carriage returns. And given the arcane listing, I'm not sure that it was in an order of hierarchy that would lead to something useful. And as for your JSON code, it seems with the file mentioned above, I already have a XML-Like code right there.
So, back to my utility I go. I have a four-paned window with two JSON documents being loaded in the top two panes. A pane of buttons to do things and a results pane. Right now, I'm cherry picking the JSON code for just the user stuff. I'm recreating a query string from the User search preferences and that's the MOST valuable to me.
For instance in L1, I have Danny's user search preferences as ((authors:"=J.K. Rowling) AND (tags:"Sports") AND tags:"Baseball")) but in L2, Danny's search preferences are ((tags:"Sports") AND tags:"Baseball")).
With the outputted text file for the combined results I'm getting, I have this bit of output:
User: Danny
Search
L1: ((authors:"=J.K. Rowling) AND (tags:"Sports") AND tags:"Baseball"))
L2: ((tags:"Sports") AND tags:"Baseball"))
Now, with Calibre open, I can now SEE the differences, go to L2 and add Rowling to Danny's search preferences (although I wish I could just paste one search string over the other. Still, the documentor will let me see this.
(I'd actually hoped to affect Calibre's settings by fiddling with the JSON file, but I realize the word BACKUP is there in the title for a reason. Stilllllllll, it would have been great.)
Now, for the time being, because I have lots of memory, I'm running the whole shooting match off in-memory tables and are thus limited to two tables documented (in my useful fractions). But turning the useful but larded JSON code into my version of cleaned up data remains something I have to do outside of your command-line example. THANKS for providing that. Good to see that you can get (and understand) settings when you want.