View Single Post
Old 05-10-2025, 01:27 PM   #10
dunhill
Guru
dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.
 
dunhill's Avatar
 
Posts: 897
Karma: 810834
Join Date: Sep 2017
Location: Buenos Aires, Argentina
Device: moon+ reader, kindle paperwhite
I have a custom information column with this template, maybe you can adapt it and see if it works for you.

Code:
python:
def evaluate(book, context):
# Use the built-in template function to format the title and authors
x = context.funcs.template('{Title} - {authors}')
# Count the books in the series. First get the series name
series = book.get('series')
if series:
# The book is in a series. Get the book count in that series
db = context.db.new_api
series_id = db.get_item_id('series', series)
book_count = len(db.books_for_field('series', series_id))
# Add the number of books to the title - author string
x = x + f' - From the series "{series}, which has {book_count} books {"s" if book_count > 1 else ""}'
else:
x = x + " - This book does not belong to a series"
return x
dunhill is offline   Reply With Quote