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 03-16-2024, 02:15 PM   #31
Wiggo
Leftutti
Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.
 
Wiggo's Avatar
 
Posts: 400
Karma: 1121267
Join Date: Feb 2019
Location: Bavaria
Device: iPad Pro, Kobo Libra 2
As I said, the problem was sitting in front of the monitor - I feel dumb again

This opend my eyes
Quote:
Originally Posted by chaley View Post
This is my saved search, using the stored template:
Attachment 206934

The names must be spelled exactly the same in the stored templates and the saved searches.
I tried it first in advanced search with templates and there it didn't work

Wiggo is offline   Reply With Quote
Old 03-16-2024, 02:26 PM   #32
Comfy.n
want to learn what I want
Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.
 
Posts: 1,002
Karma: 6422750
Join Date: Sep 2020
Device: Calibre E-book viewer
Quote:
Originally Posted by chaley View Post
@Comfy.n: in your chain "One + Has Bio" you should put the "item_has_notes" search term before the "get_one_book_per_field_value" search term. The way you have it the search can miss results for the reasons explained in post 21.
Yes I hadn't noticed there is a difference. I've replaced the attachment, in case someone wants to use the same menu items, renaming that one to Has Bio + One instead of One + Has Bio.
Comfy.n is offline   Reply With Quote
Old 03-16-2024, 03:00 PM   #33
Comfy.n
want to learn what I want
Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.
 
Posts: 1,002
Karma: 6422750
Join Date: Sep 2020
Device: Calibre E-book viewer
Quote:
Originally Posted by chaley View Post
This is my saved search, using the stored template:
Attachment 206934

The names must be spelled exactly the same in the stored templates and the saved searches.
I like to see the original search expression on the search bar. That's one of the reasons why I often create menu items in Action Chains and use those instead of saved searches!
Comfy.n is offline   Reply With Quote
Old 03-16-2024, 03:06 PM   #34
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
Quote:
Originally Posted by Comfy.n View Post
I like to see the original search expression on the search bar. That's one of the reasons why I often create menu items in Action Chains and use those instead of saved searches!
Interesting. I prefer the brevity. When I want to see the "real" search I use the menu item in the search menu to get the underlying search text. It's good we both can have what we want.
chaley is offline   Reply With Quote
Old 03-16-2024, 03:06 PM   #35
Comfy.n
want to learn what I want
Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.
 
Posts: 1,002
Karma: 6422750
Join Date: Sep 2020
Device: Calibre E-book viewer
Quote:
Originally Posted by chaley View Post
This has become a game of whack-a-Mole. The number of variants one can make on this theme is unbounded. Why not show 2 books per series where the author has the letter 'Q' in the name and it doesn't have the tag "mumble"? Or two publishers filtered in reverse alphabetical order when the books have ratings > 4? Or the last 3 books by date from an author with notes?
I won't go that far, I hope!!
Comfy.n is offline   Reply With Quote
Old 03-16-2024, 03:26 PM   #36
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 8,639
Karma: 61234567
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Would the method be much different for showing one book per series (with notes), with the lowest-indexed book per series?
ownedbycats is offline   Reply With Quote
Old 03-16-2024, 04:26 PM   #37
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
Quote:
Originally Posted by ownedbycats View Post
Would the method be much different for showing one book per series (with notes), with the lowest-indexed book per series?
Are you asking about the stuff I talked about in post 24? If so then the process would be:
  1. Run the search
    Code:
    template:"""program: item_has_notes('series')#@#:b:yes"""
    This gets you a list of books where the series value has a note attached.
  2. Make a temp VL from this search. This isn't strictly necessary because you could use a compound search, but it does make it easier to sort and to experiment to get the list you want.
  3. Sort the booklist by series ascending.
  4. Run
    Code:
    template:"""program: get_N_books_per_field_value('series',1)#@#:b:yes"""
    The template used in this search is still under thought/development.
You would see a list one book per series, where that book has the lowest series index.

If you sorted the series descending in step 3 then you would get the highest numbered book in each series.

If you search for rating:true, sort the rating column in reverse, then run the template in step 4 with 'publisher', you would get the highest rated book for each publisher.

And so on.
chaley is offline   Reply With Quote
Old 03-17-2024, 11:33 AM   #38
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
template to summarize the booklist

After playing for a while I have something that works for me.

The following template processes the books displayed on the book list, in the order they are displayed. The template has two arguments: "field name" and "item count". It looks at "field name" in each book (in order). If the book has an "item value" in that field, it checks if it already has found "item count" books for that "item value". If it has then it ignores the book. If it hasn't then it adds the book to the list of books to display.
Spoiler:
Code:
python:
def evaluate(book, context):
	from collections import defaultdict
	if context.arguments is None or len(context.arguments) != 2:
		raise ValueError("This template requires two arguments, field_name and item_count")
	field_name = context.arguments[0]
	desired_count = int(context.arguments[1])

	data_view = context.db.data
	db = context.db.new_api
	# Check if we have already computed the necessary data
	book_ids = context.globals.get('book_ids', None)
	if book_ids is None:
		# The candidates are the books matched by any previous search expression
		candidates = context.globals.get('_candidates', db.all_book_ids())
		books = defaultdict(set)
		answer = set()
		# Scan the library from top to bottom, in the order being displayed. This
		# reflects what is currently shown in the GUI, such as previous searches or VLs.
		for book_id in (tr.book_id for tr in data_view):
			# Check if this book is allowed by previous search terms
			if book_id not in candidates:
				continue
			# Get the value(s) to be checked.
			item_values = db.field_for(field_name, book_id)
			if item_values is None:
				continue
			if isinstance(item_values, str):
				# We have a single value, such as a publisher or series.
				# Make it into a list of one value
				item_values = (item_values,)
			for item_val in item_values:
				# Check if we have seen this item value before.
				item_set = books[item_val]
				if len(item_set) < desired_count:
					# We haven't hit the limit of books with this item value to display
					item_set.add(book_id)
					answer.add(book_id)
		# Save the computed results to be used for the rest of the books being examined
		context.globals['book_ids'] = answer

	# Check if the current book is to be displayed
	book_ids = context.globals['book_ids']
	return '1' if book.id in book_ids else ''
Click image for larger version

Name:	Clipboard05.jpg
Views:	9
Size:	159.2 KB
ID:	206972


Because the book list is scanned in displayed order, how the book list is sorted is important. The "item values" are checked in their order of appearance. This lets you control which books you get, for example:
  • Highest or lowest series index.
  • Find series with more than 5 books then show the book with the lowest series index. (Uses this template search for the Find series part.)
  • Tags with the highest or lowest rating.
  • Publishers with highest or lowest rating.
  • Authors of books with a series that has notes, in genre order.
  • And so on.
Basically, if you can sort the book list into the order you want, this template will respect that order, showing "item count" books having "field name" with some "item value".

Although not strictly required, the template works much better if running from latest source. If you don't then search caching can get involved, showing you some previous result instead of a current calculation. The change will be in the next release/preview.

The following example will show the first book of each series that has a rating.
  • As above, create a stored template containing the template code in the spoiler. Name it whatever you want. I used "summarize_booklist". Ignore the ValueError shown in the Stored templates dialog.
  • Use search to find the list of books you want to process. I recommend you make a temporary VL for the search once you have what you want. Example: rating:true
  • Sort the book list in the order you want books to be examined. Example: series ascending.
  • Using Advanced search, make a template search. Example: lowest series index. Because I used the name "summarize_booklist", the search looks like this:
    Click image for larger version

Name:	Clipboard01.jpg
Views:	15
Size:	69.9 KB
ID:	206973

    The template is
    Code:
    program: summarize_booklist('series',1)

Last edited by chaley; 03-18-2024 at 07:24 AM. Reason: Changed the template name to summarize_booklist()
chaley is offline   Reply With Quote
Old 03-19-2024, 02:18 AM   #39
Comfy.n
want to learn what I want
Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.
 
Posts: 1,002
Karma: 6422750
Join Date: Sep 2020
Device: Calibre E-book viewer
Quote:
Originally Posted by chaley View Post

The template is
Code:
program: summarize_booklist('series',1)
Looks awesome, I must have missed this post! Will try it when I'm not almost asleep.

edit: Wheee! Just did a quick test with template:"""program: summarize_booklist('publisher',15)#@#:b:yes""" and v:true (v= GR votes), then sorted by multiple columns on Publisher then GR votes, thus getting my listing of top voted titles by Publisher:

Click image for larger version

Name:	MWSnap 2024-03-19, 03_54_56.png
Views:	19
Size:	29.3 KB
ID:	206997


Last edited by Comfy.n; 03-19-2024 at 02:58 AM.
Comfy.n is offline   Reply With Quote
Old 04-05-2024, 11:04 AM   #40
Wiggo
Leftutti
Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.
 
Wiggo's Avatar
 
Posts: 400
Karma: 1121267
Join Date: Feb 2019
Location: Bavaria
Device: iPad Pro, Kobo Libra 2
@chaley

I have an author who has both author notes and series notes.

He is listed in author notes and "one book per author", but unfortunately not in series notes and "one book per author" - series notes only he is listed too.

What additional information would you need, I always forget something?

edit: the author has also aliases

Last edited by Wiggo; 04-05-2024 at 12:36 PM.
Wiggo is offline   Reply With Quote
Old 04-05-2024, 01:09 PM   #41
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
Quote:
Originally Posted by Wiggo View Post
@chaley

I have an author who has both author notes and series notes.

He is listed in author notes and "one book per author", but unfortunately not in series notes and "one book per author" - series notes only he is listed too.

What additional information would you need, I always forget something?

edit: the author has also aliases
I don't understand the question. What exactly are you searching for (the search string)? And how is the booklist sorted? Remember, the template keeps the first item it encounters. In your case I suspect the first author isn't the one with notes.

The template knows nothing of aliases. It compares the author names, and either they are the same or they aren't.
chaley is offline   Reply With Quote
Old 04-06-2024, 11:59 AM   #42
Wiggo
Leftutti
Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.
 
Wiggo's Avatar
 
Posts: 400
Karma: 1121267
Join Date: Feb 2019
Location: Bavaria
Device: iPad Pro, Kobo Libra 2
Quote:
Originally Posted by chaley View Post
I don't understand the question. What exactly are you searching for (the search string)? And how is the booklist sorted? Remember, the template keeps the first item it encounters. In your case I suspect the first author isn't the one with notes.

The template knows nothing of aliases. It compares the author names, and either they are the same or they aren't.
First I click in the tag browser on my saved search "has series notes"

Click image for larger version

Name:	calibre_tWUJFLc9pn.jpg
Views:	46
Size:	285.3 KB
ID:	207378 Click image for larger version

Name:	calibre_jYS5Rdk7m4.jpg
Views:	34
Size:	21.3 KB
ID:	207379

and then additionally on "one book per author"

Click image for larger version

Name:	calibre_QZq1d6QhHH.jpg
Views:	33
Size:	195.6 KB
ID:	207380 Click image for larger version

Name:	calibre_KMTAaTY4bS.jpg
Views:	30
Size:	23.1 KB
ID:	207381

and Dan Adams disappears. What am I doing wrong?
Wiggo is offline   Reply With Quote
Old 04-06-2024, 12:16 PM   #43
Comfy.n
want to learn what I want
Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.
 
Posts: 1,002
Karma: 6422750
Join Date: Sep 2020
Device: Calibre E-book viewer
Hi Wiggo, I liked your icons for book formats. They fit better on dark theme than the ones I'm using. Would you mind sharing them in a zip attachment?

I'd never thought of using a column just for symbols, seems a good thing to do!
Comfy.n is offline   Reply With Quote
Old 04-06-2024, 12:23 PM   #44
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
Quote:
Originally Posted by Wiggo View Post
First I click in the tag browser on my saved search "has series notes"

Attachment 207378 Attachment 207379

and then additionally on "one book per author"

Attachment 207380 Attachment 207381

and Dan Adams disappears. What am I doing wrong?
My guess is that "Dan Adams" is the author of books in a different series or no series, and one of those books is appearing ahead of the books with series with a note.

Order is important in "and" search clauses. Clauses following an "and" operate of the results of the previous search clauses. As such they don't see any books already filtered out. This "shortcutting" improves search performance a lot.

Try changing the order of the search to
Code:
search:"=#Has.Series notes" and search:"=#Has._One book per author"
This order ensures that the one-book-per-author search operates on the results of the has-series-notes search.
chaley is offline   Reply With Quote
Old 04-06-2024, 12:23 PM   #45
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 8,639
Karma: 61234567
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Quote:
Originally Posted by Comfy.n View Post
I'd never thought of using a column just for symbols, seems a good thing to do!
And here I thought I was being creative by doing this to the Formats column:

Name:  2024-04-06 13_23_10-calibre — __ My Books __ Currently Reading __.png
Views: 61
Size:  4.5 KB
ownedbycats is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Books sent to Amazon show with my email as ther author Robmonster Calibre 9 11-05-2020 01:17 PM
Show Books from Only 1 Author RiffRaffAK Library Management 2 06-04-2020 10:26 AM
Expanded search option for "Show books by the same author as the current book" ALT+A Sisela Library Management 1 11-28-2015 09:54 AM
author search in book details panel mobic Library Management 3 11-26-2015 10:50 AM
To show author and author sort as same? pinky62 Library Management 5 03-18-2014 12:55 PM


All times are GMT -4. The time now is 03:53 AM.


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