|
|
#1 |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,281
Karma: 16800000
Join Date: Sep 2009
Location: UK
Device: ClaraHD, Forma, Libra2, Clara2E, LibraCol, PBTouchHD3
|
Querying Metadata from outside the GUI?
I'd like to understand the calibre metadata structure better. If I know the path/to/library and a book's id within that library, is it possible to access metadata (read only) via a simple script using the Windows commandline method:
Code:
calibre-debug path/to/myscript.py Code:
db = self.gui.current_db
my_title = db.new_api.field_for('title', my_bookid)
|
|
|
|
|
|
#2 |
|
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,701
Karma: 28549304
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
You can always load a db, like this:
from calibre.library import db db = db('path/to/library/folder') that will give you the same object as gui.current_db |
|
|
|
| Advert | |
|
|
|
|
#3 |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,281
Karma: 16800000
Join Date: Sep 2009
Location: UK
Device: ClaraHD, Forma, Libra2, Clara2E, LibraCol, PBTouchHD3
|
I didn't realise that. That makes life much easier. Thanks
|
|
|
|
|
|
#4 |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,529
Karma: 8075744
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
@jackie_w: if you normally use the new DB interface then you can get a new db handle with something like the following function
Code:
def init_cache(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 Code:
cache = init_cache(sys.argv[1])
# Loop through all the books in the library
for id_ in cache.all_book_ids():
.....
|
|
|
|
|
|
#5 |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,281
Karma: 16800000
Join Date: Sep 2009
Location: UK
Device: ClaraHD, Forma, Libra2, Clara2E, LibraCol, PBTouchHD3
|
@chaley,
Thanks for the info - I'll squirrel it away. At the moment I'm just interested in seeing what fields/methods are available for querying metadata for a single book in the database. It all came about because I wanted to tweak the Count Pages plugin more to my liking and I realised I didn't really have a clue about the metadata processing in there. FWIW it turns out I didn't really need to know much to achieve what I wanted ... but now I'm aware of my ignorance I feel the need to do something about it ![]() P.S. Hope you're well. France seems to be having some bad times recently. |
|
|
|
| Advert | |
|
|
|
|
#6 | ||
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,529
Karma: 8075744
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Quote:
But then, so is the UK, what with brexit. I know I shouldn't get into this here, but BoJo as foreign secretary? Really? (No need to answer. )
|
||
|
|
|
![]() |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [GUI Plugin] Zotero Metadata Importer | DaltonST | Plugins | 295 | 03-22-2025 10:47 AM |
| [GUI Plugin] Consolidate All Library Metadata (CALM) | DaltonST | Plugins | 334 | 02-02-2025 03:28 PM |
| GUI Ideas for ePub3 MetaData Editor | KevinH | Sigil | 3 | 12-02-2015 02:58 PM |
| Getting custom metadata field in GUI plugin | SauliusP. | Development | 7 | 02-11-2012 02:31 AM |
| Problem updating metadata (using mobi2mobi command line and gui) | whitearrow | Kindle Formats | 3 | 12-05-2009 08:07 PM |