Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Development

Notices

Reply
 
Thread Tools Search this Thread
Old 05-03-2022, 01:51 PM   #1
jacobalbano
Junior Member
jacobalbano began at the beginning.
 
jacobalbano's Avatar
 
Posts: 5
Karma: 10
Join Date: May 2022
Device: Kobo Libra H2O
Searching for another book by its identifier

Hey all, couldn't find any other topic that answered my question, hopefully I didn't miss anything.

The plugin I'm writing is intended to be able to automatically copy metadata from the first book in a series over to later installments. So for example, I'd import a book with the identifier of "wxyz:1234-2" (this is a custom format that includes the series and volume number), and it would automatically search for the first entry in that series and copy its series name, authors, tags, etc.

However, I can't figure out any way to actually find books in the database from their identifiers. The API does have a field that seems likely, but for some reason it's empty. My tags display with no issue, and I do indeed have books in my library that already have identifiers set.

Code:
>>> db.all_field_names('tags')
frozenset({'Manga', 'GOG', 'Novel', 'Aozora', 'Amazon'})
>>> db.all_field_names('identifiers')
frozenset()
>>>
Am I missing something obvious? Any pointers would be appreciated
jacobalbano is offline   Reply With Quote
Old 05-03-2022, 04:01 PM   #2
jacobalbano
Junior Member
jacobalbano began at the beginning.
 
jacobalbano's Avatar
 
Posts: 5
Karma: 10
Join Date: May 2022
Device: Kobo Libra H2O
Seems like I can get what I want by using
Code:
db.search('identifiers:wxyz:1234-1')
which gives me a set containing the book's id. I'll go with this solution unless someone comes up with a better one, but I still wonder if the cache is buggy when it comes to identifiers.
jacobalbano is offline   Reply With Quote
Advert
Old 05-03-2022, 09:42 PM   #3
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: 45,342
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
all_field_names is for many-to-one or many-to-many fields. identifiers is not one of them. identifiers are intended to be unique per book. Using search is fine for this use case.
kovidgoyal is offline   Reply With Quote
Old 05-04-2022, 11:36 AM   #4
jacobalbano
Junior Member
jacobalbano began at the beginning.
 
jacobalbano's Avatar
 
Posts: 5
Karma: 10
Join Date: May 2022
Device: Kobo Libra H2O
That makes sense! I figured since it didn't raise an error (as it would have if I'd used a field name that didn't exist at all) that there was some way to do it that I wasn't understanding. Thank you for the confirmation
jacobalbano is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with removing identifier from book Terisa de morgan Library Management 2 11-04-2019 09:49 AM
Doubt about removing identifier in book Terisa de morgan Library Management 6 04-08-2019 03:20 AM
Aura HD Searching in a book bookwurm70 Kobo Reader 2 07-08-2014 04:32 PM
No identifier causes delay in View and Edit Book MerlinMama Calibre 17 06-02-2014 07:03 PM
Searching within a E-Book benjaminvm Sony Reader Dev Corner 3 08-18-2008 11:44 AM


All times are GMT -4. The time now is 01:00 PM.


MobileRead.com is a privately owned, operated and funded community.