View Single Post
Old 12-25-2023, 01:04 PM   #9
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: 902
Karma: 810834
Join Date: Sep 2017
Location: Buenos Aires, Argentina
Device: moon+ reader, kindle paperwhite
There is a plugin to count the books of an author "Author Book Count"
Or else you could put aside the forms that I recommend @chaley, I use one that he surely would have made taking into account the column of the count of books by author and in the detail of the book it gives you the information if that book belongs to a series:

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 count of books 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 number of books to title - author string
        x = x + f' -- From the series "{series}, which has {book_count} book{"s" if book_count > 1 else ""}'
    else:
        x = x + " -- This book does not belong to a series"
    return x

Last edited by chaley; 12-25-2023 at 02:17 PM. Reason: Fixed indenting destroyed by the origional post.
dunhill is offline   Reply With Quote