View Single Post
Old 12-16-2020, 08:38 PM   #3
JimmXinu
Plugin Developer
JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.
 
JimmXinu's Avatar
 
Posts: 7,025
Karma: 4604635
Join Date: Dec 2011
Location: Midwest USA
Device: Kobo Clara Colour running KOReader
The nice thing about open source is you can always look at the source.

In this case, new_api is the Cache class in https://github.com/kovidgoyal/calibr...re/db/cache.py It appears to only have library_id and dbpath properties. dbpath contains the library name, but as part of the full abspath to 'metadata.db' for that library.

The other approach is to look at the code for something that already has what you want. In this case, the Choose Library action knows about library names. I keep a fork of calibre checkouted and used find grep on 'Switch/create library' to find it in: https://github.com/kovidgoyal/calibr...ose_library.py

That action has a method library_name(), which you can call from your plugin as self.gui.iactions['Choose Library'].library_name(), or you can look at the code and find that what it really does it give you the basename of the self.gui.current_db.libary_path.
JimmXinu is offline   Reply With Quote