Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 12-16-2023, 12:27 PM   #1
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,008
Karma: 6422750
Join Date: Sep 2020
Device: Calibre E-book viewer
Marking titles that contain Notes? (e.g. GR Author notes)

I was hoping there was some way to filter authors that have notes, from the main search bar, but I remembered this topic where Kovid explained that this isn't possible:
https://www.mobileread.com/forums/sh...12&postcount=7

One of the use cases for that search would be to filter titles whose authors have already been processed with the plugin GR Author Notes.

My current workaround will be tagging the processed titles with "Author Notes OK".

So I come to ask, would it be a convenient addition to have a Mark Books button in the Notes Browser, similar to the one in the FTS window? This way, one could select all processed items in the Notes browser, then hit "Mark Books", then in the main search bar type

not marked:true

to filter GR notes unprocessed titles.

Last edited by Comfy.n; 12-16-2023 at 01:04 PM.
Comfy.n is online now   Reply With Quote
Old 12-16-2023, 01:43 PM   #2
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
It seems you are asking for a way to find all items (e.g. authors) that have an attached note, then find all books with 1 or more of the found authors. Is this right?

If so then doing it in the notes browser probably isn't straight forward because that browser doesn't know about books. However, it can be done in a template search (with a python template). The template would first get a list of item names with notes, check book-by-book if one of those item names is associated with the book, resulting in a standard search result list.

I will think a bit about it, and assuming I am right then provide an example.
chaley is offline   Reply With Quote
Old 12-16-2023, 01:51 PM   #3
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,008
Karma: 6422750
Join Date: Sep 2020
Device: Calibre E-book viewer
Quote:
Originally Posted by chaley View Post
It seems you are asking for a way to find all items (e.g. authors) that have an attached note, then find all books with 1 or more of the found authors. Is this right?
exactly

Quote:
Originally Posted by chaley View Post
If so then doing it in the notes browser probably isn't straight forward because that browser doesn't know about books. However, it can be done in a template search (with a python template).
I too had somewhat figured that this isn't as straight forward as it is with FTS, given that FTS does know about the titles.

Quote:
Originally Posted by chaley View Post
I will think a bit about it, and assuming I am right then provide an example.
thanks!
Comfy.n is online now   Reply With Quote
Old 12-16-2023, 02:00 PM   #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
Here is something that works for me.

The template:
Code:
python:
def evaluate(book, context):
	db = context.db.new_api
	items_with_notes = context.globals.get('items_with_notes')
	if items_with_notes is None:
		items_with_notes = db.get_all_items_that_have_notes('authors')
		context.globals['items_with_notes'] = items_with_notes
	for aut in book.authors:
		if db.get_item_id('authors', aut) in items_with_notes:
			return '1'
	return ''
You set which category you are interested in by changing 'authors' to the category name of interest, e.g., tags.

The template search is:
Click image for larger version

Name:	Clipboard01.jpg
Views:	64
Size:	68.4 KB
ID:	205240

EDIT: This template is slow. See the template in post #10.

Last edited by chaley; 12-21-2023 at 12:00 PM. Reason: Link to post with a faster template.
chaley is offline   Reply With Quote
Old 12-16-2023, 02:52 PM   #5
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,008
Karma: 6422750
Join Date: Sep 2020
Device: Calibre E-book viewer
That one halts Calibre, for me. Additionally, I notice that the "Copy current search..." button doesn't get enabled for me, so I may be doing something wrong:

Click image for larger version

Name:	MWSnap 2023-12-16, 16_34_30.png
Views:	66
Size:	23.1 KB
ID:	205244

On another note, I find that the output generated by the GR Author Notes plugin show up a bit garbled in the Notes Browser, not sure if that's expected:

Click image for larger version

Name:	MWSnap 2023-12-16, 16_41_16.png
Views:	63
Size:	80.3 KB
ID:	205245
Comfy.n is online now   Reply With Quote
Old 12-16-2023, 03:25 PM   #6
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
That one halts Calibre, for me. Additionally, I notice that the "Copy current search..." button doesn't get enabled for me, so I may be doing something wrong:
What do you mean by "halts calibre"? How long did you let it run? You might try it on a smaller virtual library to see if there is a performance problem, although I did run it on a 50,000 book library with no problems.
chaley is offline   Reply With Quote
Old 12-16-2023, 03:39 PM   #7
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,008
Karma: 6422750
Join Date: Sep 2020
Device: Calibre E-book viewer
Quote:
Originally Posted by chaley View Post
What do you mean by "halts calibre"? How long did you let it run? You might try it on a smaller virtual library to see if there is a performance problem, although I did run it on a 50,000 book library with no problems.
Ah, nice. I did as you suggested on a subset of the library containing only epub format and language:english (VL). Then I ran the template search and let it run for some minutes... then it returned the results containing author notes.

Thanks!
Comfy.n is online now   Reply With Quote
Old 12-16-2023, 07:14 PM   #8
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
Ah, nice. I did as you suggested on a subset of the library containing only epub format and language:english (VL). Then I ran the template search and let it run for some minutes... then it returned the results containing author notes.

Thanks!
I found a linear search in the API I used, which is why it is taking forever. There is an alternate API that avoids that problem.

Try this template instead. I think you will find it takes at most a few seconds on the full library.
Code:
python:
def evaluate(book, context):
	db = context.db.new_api
	authors_with_notes = context.globals.get('authors_with_notes')
	if authors_with_notes is None:
		print('authors notes is none')
		authors_with_notes = db.get_all_items_that_have_notes('authors')
		context.globals['authors_with_notes'] = authors_with_notes
		context.globals['item_name_map'] = db.get_item_name_map('authors')
	item_name_map = context.globals['item_name_map']
	for aut in book.authors:
		if item_name_map.get(aut) in authors_with_notes:
			return '1'
	return ''
chaley is offline   Reply With Quote
Old 12-16-2023, 07:30 PM   #9
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,008
Karma: 6422750
Join Date: Sep 2020
Device: Calibre E-book viewer
Yay, that works! Results came almost instantly.

While saving this search as "has author notes", I've found another saved search on my history named "has data files", which I probably got from one of your posts in the template questions thread: """program:has_extra_files()#@#:b:yes""". Thanks for that one, too.
Comfy.n is online now   Reply With Quote
Old 12-19-2023, 08:44 AM   #10
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
Here is a template that you can customize to check columns other than authors. Change 'authors' in the line "column = 'authors'" to the lookup name of your choice.

Code:
python:
def evaluate(book, context):
	column = 'authors'

	db = context.db.new_api
	items_with_notes = context.globals.get('items_with_notes')
	if items_with_notes is None:
		items_with_notes = db.get_all_items_that_have_notes(column)
		context.globals['items_with_notes'] = items_with_notes
		context.globals['item_name_map'] = db.get_item_name_map(column)
	item_name_map = context.globals['item_name_map']

	vals = book.get(column)
	if vals is None:
		return ''
	if isinstance(vals, str):
		vals = tuple((vals,))
	for val in vals:
		if item_name_map.get(val) in items_with_notes:
			return '1'
	return ''

Last edited by chaley; 12-19-2023 at 08:49 AM.
chaley is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[GUI Plugin] GR Author Notes azuravian Plugins 45 Yesterday 03:15 AM
How to add notes to Calendar Notes on specific days? Mi7 Onyx Boox 3 03-30-2023 07:13 AM
Forma Why some notes are popup notes, some are jumping notes in Kobo Forma codychan Kobo Reader 11 11-22-2022 02:25 PM
Bug? When in Notes, I Need to press 3 times on Power button to put to sleep Notes Huyggy Onyx Boox 2 06-12-2022 09:27 AM
Which one? Read PDF and marking tool. Evtl. take notes. Esel2k Which one should I buy? 4 11-04-2016 06:08 AM


All times are GMT -4. The time now is 06:12 AM.


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