Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 12-18-2023, 07:53 PM   #1
shauntih
Junior Member
shauntih began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Sep 2013
Device: Kindle
Can Calibre search for a count?

Is there a way to search for the series that have, say > 5 books in the series, or for authors that have > 10 books in the library? I like to read large series and being able to search for a count would really help me find books to read when I'm in this mood. I haven't been able to find anything that is pointing me in the right direction.

Any help is appreciated!
Celita
shauntih is offline   Reply With Quote
Old 12-18-2023, 08:32 PM   #2
Sirtel
Grand Sorcerer
Sirtel ought to be getting tired of karma fortunes by now.Sirtel ought to be getting tired of karma fortunes by now.Sirtel ought to be getting tired of karma fortunes by now.Sirtel ought to be getting tired of karma fortunes by now.Sirtel ought to be getting tired of karma fortunes by now.Sirtel ought to be getting tired of karma fortunes by now.Sirtel ought to be getting tired of karma fortunes by now.Sirtel ought to be getting tired of karma fortunes by now.Sirtel ought to be getting tired of karma fortunes by now.Sirtel ought to be getting tired of karma fortunes by now.Sirtel ought to be getting tired of karma fortunes by now.
 
Sirtel's Avatar
 
Posts: 10,147
Karma: 224760044
Join Date: Jan 2014
Location: Estonia
Device: Kobo Sage & Libra 2
The tag browser -> Settings (in the lower left corner of the tag browser) -> Sort by the number of books. When you then click on either Authors or Series in the tag browser, you'll see them ordered by the number of books.
Sirtel is offline   Reply With Quote
Old 12-18-2023, 10:29 PM   #3
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 20,582
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
↑ ↑ ↑ ✔

You may need to use this too:

Click image for larger version

Name:	Screenshot 2023-12-19 142748.jpg
Views:	100
Size:	57.9 KB
ID:	205325

BR
BetterRed is online now   Reply With Quote
Old 12-19-2023, 05:44 AM   #4
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
You can generate a list of books in a series (or any other column) with at least N books in the series with a template search. I felt like playing with it and here is a solution that works for me.

Steps:
  1. Create a stored template (Preferences / Template functions / Stored templates).
    • The template name is 'count_books_with_same_field_value'. It can actually be what you want, but it must be a valid name and you must use this name below.
    • The template is
      Code:
      python:
      def evaluate(book, context):
      	args = context.arguments
      	if args is None or len(args) != 2:
      		return 'Bad argument count. Must be 2 (column, count)'
      	
      	column = args[0]
      	min_count = int(args[1])
      
      	globals = context.globals
      	db = context.db.new_api
      
      	if globals is None or 'possibles' not in globals:
      		possibles = set()
      		id_count_map = db.get_usage_count_by_id(column)
      		for id,count in id_count_map.items():
      			if count >= min_count:
      				possibles.add(db.get_item_name(column, id))
      		globals['possibles'] = possibles
      
      	possibles = globals['possibles']
      	book_vals = db.field_for(column, book.id)
      
      	if not isinstance(book_vals, (tuple, list)):
      		book_vals = list((book_vals,))
      	for v in book_vals:
      		if v in possibles:
      			return '1'
      	return ''
    • Press the "Create" button to store the template.
    Here is a screen capture of the Stored template dialog.
    Click image for larger version

Name:	Clipboard01.jpg
Views:	58
Size:	162.1 KB
ID:	205326
  2. Create a template search
    • Click the "Advanced search" icon in the search bar (a gear).
    • Choose "Template search"
    • Set the "Template value" to "True"
    • Set the "Comparison type" to "Set/Not set"
    • Set the "Template" to
      Code:
      program: count_books_with_same_field_value('series', 4)
      where 'series' is the column lookup key you want to check, and '4' is the minimum count you want.
    • Here is a screen capture of the Template search dialog
      Click image for larger version

Name:	Clipboard02.jpg
Views:	59
Size:	71.5 KB
ID:	205327
  3. Save the new template search as a saved search if you wish

For example, this template search:
Code:
template:"""program: count_books_with_same_field_value('series', 4)#@#:b:True"""
will produce a list of books in any series with at least 4 books.

Comparison of approaches:
  • The techniques mentioned in the above posts do something similar, one item at a time. For example, sorting by count in the tag browser then clicking on a series with the count you wish will produce a list of books in that series.
  • The template search approach described here produces a list of books in all series with at least the count you wish.
I can't say which technique works better for you.
chaley is offline   Reply With Quote
Old 12-19-2023, 05:44 PM   #5
shauntih
Junior Member
shauntih began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Sep 2013
Device: Kindle
Quote:
Originally Posted by Sirtel View Post
The tag browser -> Settings (in the lower left corner of the tag browser) -> Sort by the number of books. When you then click on either Authors or Series in the tag browser, you'll see them ordered by the number of books.
Unfortunately, that doesn't allow me to search when I don't know what I'm searching for. But thank you for the response.

See post 7

Last edited by BetterRed; 12-19-2023 at 06:07 PM.
shauntih is offline   Reply With Quote
Old 12-19-2023, 05:55 PM   #6
shauntih
Junior Member
shauntih began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Sep 2013
Device: Kindle
Quote:
Originally Posted by chaley View Post
You can generate a list of books in a series (or any other column) with at least N books in the series with a template search. I felt like playing with it and here is a solution that works for me.
...
Comparison of approaches:
  • The techniques mentioned in the above posts do something similar, one item at a time. For example, sorting by count in the tag browser then clicking on a series with the count you wish will produce a list of books in that series.
  • The template search approach described here produces a list of books in all series with at least the count you wish.
I can't say which technique works better for you.

This sounds like more what I'm after. I don't know python (yet), and have never used templates, so this is all new to me. It sounds like it may get me where I need to be once I figure it out. I am a little confused that when I enter the python code in the template, it is so tiny it cannot be read (see attached). It doesn't look like that in your snippet.

Am I strange for wanting to find authors or series I like (because I have, like 10 books by that author), when I can't remember who they are? I don't think it should be this difficult.
Attached Thumbnails
Click image for larger version

Name:	python_code.jpg
Views:	43
Size:	26.1 KB
ID:	205335  
shauntih is offline   Reply With Quote
Old 12-19-2023, 06:00 PM   #7
shauntih
Junior Member
shauntih began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Sep 2013
Device: Kindle
Quote:
Originally Posted by Sirtel View Post
The tag browser -> Settings (in the lower left corner of the tag browser) -> Sort by the number of books. When you then click on either Authors or Series in the tag browser, you'll see them ordered by the number of books.
I misunderstood originally, and don't know how to edit the original reply. Actually, this DOES help!
shauntih is offline   Reply With Quote
Old 12-19-2023, 06:07 PM   #8
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 20,582
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Quote:
Originally Posted by shauntih View Post
I misunderstood originally, and don't know how to edit the original reply. Actually, this DOES help!
Once you've reached 10 posts, you should be able to edit your own posts.

Meantime I fixed it for you.

BR
BetterRed is online now   Reply With Quote
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: 724
Karma: 228142
Join Date: Sep 2017
Location: 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
Reply

Tags
count


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How does calibre count books Gardenman Library Management 2 12-21-2021 12:27 AM
Word count in calibre C-novice Library Management 2 03-11-2018 10:57 PM
Possible to get a word count in Calibre? Notjohn Calibre 15 01-23-2016 06:20 PM
Incorrect book count in Calibre Library on Device SquareWheels Library Management 19 10-08-2013 09:18 PM
Calibre and loaded ebook count pagansoul Calibre 7 01-30-2012 11:19 AM


All times are GMT -4. The time now is 11:46 PM.


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