12-16-2023, 12:27 PM | #1 |
want to learn what I want
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. |
12-16-2023, 01:43 PM | #2 |
Grand Sorcerer
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. |
12-16-2023, 01:51 PM | #3 | ||
want to learn what I want
Posts: 1,008
Karma: 6422750
Join Date: Sep 2020
Device: Calibre E-book viewer
|
Quote:
Quote:
thanks! |
||
12-16-2023, 02:00 PM | #4 |
Grand Sorcerer
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 '' The template search is: 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. |
12-16-2023, 02:52 PM | #5 |
want to learn what I want
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:
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: |
12-16-2023, 03:25 PM | #6 |
Grand Sorcerer
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
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.
|
12-16-2023, 03:39 PM | #7 | |
want to learn what I want
Posts: 1,008
Karma: 6422750
Join Date: Sep 2020
Device: Calibre E-book viewer
|
Quote:
Thanks! |
|
12-16-2023, 07:14 PM | #8 | |
Grand Sorcerer
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
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 '' |
|
12-16-2023, 07:30 PM | #9 |
want to learn what I want
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. |
12-19-2023, 08:44 AM | #10 |
Grand Sorcerer
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. |
|
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 |