|
|||||||
![]() |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
Enthusiast
![]() Posts: 27
Karma: 30
Join Date: Jul 2011
Device: none
|
How can I use the database API to get a collection of all known series?
I'm writing a plugin, and I'd like to obtain a list of all the series in all the books. I'll use the list to answer questions like "Is there a series with this name 'SomeName'" and "Which series have a name that starts with the string 'SomePrefix'"
I've tried various approaches including: Code:
series_fields = self.db_cache_api.fields['series']
for val, book_ids in series_fields.iter_searchable_values(
self.db_cache_api.get_metadata,
self.db_cache_api.all_book_ids()
):
print("val=\"%s\"" % val)
Thanks for any help! |
|
|
|
|
|
#2 |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,525
Karma: 8065948
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
I don't know where the attribute 'cache_api" is defined. Is it something you made?
In any event, here is a calibre python template that returns all the current series names. Code:
python:
python:
def evaluate(book, context):
series_names = context.db.new_api.all_field_names('series')
return ', '.join(series_names)
Code:
series_names = self.db.new_api.all_field_names('series')
Code:
series_id = context.db.new_api.get_item_id('series', 'Bah')
# should check for None
series_books = context.db.new_api.books_for_field('series', series_id)
|
|
|
|
| Advert | |
|
|
|
|
#3 |
|
Enthusiast
![]() Posts: 27
Karma: 30
Join Date: Jul 2011
Device: none
|
Thanks! This works for me so far. I just want the series names.
`self.db_cache_api`is just an instance field where I keep the results of `db.new_api` after the current class was constructed. |
|
|
|
![]() |
| Tags |
| api, database, plug-ins |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Series and Collection | guidoexge | Library Management | 1 | 08-23-2019 10:43 AM |
| Problems using Calibre 3.15.0 Database API | einnordlicht | Development | 2 | 01-06-2018 10:28 PM |
| Accessing Series and Metadata with the "new api" | hakan42 | Development | 3 | 10-03-2013 05:57 AM |
| Author and Series database | huon | Calibre | 5 | 03-31-2012 08:45 PM |
| Series/Collection | sikm | Calibre | 7 | 10-28-2011 04:44 PM |