08-18-2024, 06:46 PM | #1 |
Evangelist
Posts: 431
Karma: 41524
Join Date: Sep 2011
Device: Kobo Libra 2 & Clara BW
|
Pick a random book?
I'd like to create something that goes through all of my Calibre books, finds those that have the onkobo column checked but doesn't have a date in the finished column, then choose one at random.
Something like: Code:
import random unfinished = [book for books if book.onkobo and not book.finished] book = random.choice(unfinished) show(book.title, book.author) |
08-18-2024, 07:33 PM | #2 |
Well trained by Cats
Posts: 30,440
Karma: 58055868
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
I have a VL for 'To Read'
Code:
Not #finished:>12/31/2000 and formats:true and not formats:other and not #usertags:split_up usertags is what it says , I tag there when I use Epub Split (PI) on a boxed set So, if it has a format and not fand any of the other, it represents my (outta control) TBR pile Once that VL is active, you just use the dice Icon (select a Random Book) Note: You may need to add it to a toolbar |
Advert | |
|
08-18-2024, 07:49 PM | #3 |
Evangelist
Posts: 431
Karma: 41524
Join Date: Sep 2011
Device: Kobo Libra 2 & Clara BW
|
Goes off to figure out virtual libraries.
I like the idea of tracking abandoned books. |
08-18-2024, 07:55 PM | #4 |
Grand Sorcerer
Posts: 11,428
Karma: 230178176
Join Date: Jan 2014
Location: Estonia
Device: Kobo Sage & Libra 2
|
|
08-18-2024, 08:31 PM | #5 |
Well trained by Cats
Posts: 30,440
Karma: 58055868
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
The reason I prefer VL's is because you can use them in conjunction with the Tag Browser.
Show To Read and filter by Science Fiction |
Advert | |
|
08-18-2024, 09:20 PM | #6 | |
Evangelist
Posts: 431
Karma: 41524
Join Date: Sep 2011
Device: Kobo Libra 2 & Clara BW
|
Quote:
Last edited by foosion; 08-18-2024 at 09:29 PM. |
|
08-18-2024, 10:12 PM | #7 |
Custom User Title
Posts: 9,499
Karma: 64500003
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
I have a stored template for tracking read status and for it I defined did-not-finished by adding 'dnf' to the#admintags column.
Code:
program: percent = $$#percentread; if 'dnf' inlist $#admintags then 'didnotfinish' elif percent >=#1 && percent <=#99 then 'currentlyreading' elif $#readinglist=='To Be Read' && percent ==#0 then 'toberead' elif percent >=#100 then 'read' elif percent == 'None' then 'undefined' elif percent >=#0 then 'unread' fi Last edited by ownedbycats; 08-18-2024 at 10:15 PM. |
08-18-2024, 10:50 PM | #8 | |
Grand Sorcerer
Posts: 12,018
Karma: 7257323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
You would probably also want to do one or both of:
Edit: If your goal is to read (View) the random book, do it in Action chains.
EDIT 2: My post is more-or-less the same as @theduck's post (#2 above). Apologies for the repeat. Last edited by chaley; 08-19-2024 at 03:33 AM. |
|
08-19-2024, 03:38 AM | #9 |
Grand Sorcerer
Posts: 12,018
Karma: 7257323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
@foosion: if you really want to roll your own implementation, I think the easiest is to do it in an Action chains python action. Use db.cache.search() to get the list of ids, select one randomly, then gui2.actions.view.view_format_by_id() to launch the viewer.
Last edited by chaley; 08-19-2024 at 05:55 AM. Reason: spelling |
08-19-2024, 05:54 AM | #10 |
Grand Sorcerer
Posts: 12,018
Karma: 7257323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Here is a sample Action chains python action that does a search, selects a random book id, then "view"s the EPUB format of that book.
Code:
def run(gui, settings, chain): db = gui.current_db ids = list(db.new_api.search('#mybool:true and formats:epub')) if ids: import random random_id = random.choice(ids) view_action = gui.iactions['View'] view_action.view_format_by_id(random_id, 'EPUB', open_at=None) |
08-19-2024, 06:04 AM | #11 |
Evangelist
Posts: 431
Karma: 41524
Join Date: Sep 2011
Device: Kobo Libra 2 & Clara BW
|
Although I've been using Calibre for about 15 years, until I got a Kobo I barely used any of Calibre's features beyond add a book and view. I'm going to have to devote some time to reading the manual and playing.
|
08-19-2024, 06:22 AM | #12 | |
Evangelist
Posts: 431
Karma: 41524
Join Date: Sep 2011
Device: Kobo Libra 2 & Clara BW
|
Quote:
I'd do "#onkobo:true and #finished:false" instead of #mybool. Is there a way to show a message, if I want to identify the chosen book rather than use the viewer? |
|
08-19-2024, 06:24 AM | #13 |
Grand Sorcerer
Posts: 12,018
Karma: 7257323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
|
08-19-2024, 06:27 AM | #14 |
Evangelist
Posts: 431
Karma: 41524
Join Date: Sep 2011
Device: Kobo Libra 2 & Clara BW
|
|
08-19-2024, 06:28 AM | #15 |
Grand Sorcerer
Posts: 12,018
Karma: 7257323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to assign Pick a Random Book to a keyboard combination? | jamesgl | Calibre | 3 | 05-14-2022 05:54 PM |
Pick multiple random books? | BookJunkieLI | Library Management | 5 | 05-24-2020 11:10 AM |
"Pick Random Book" - not so random?? | Chris_Snow | Library Management | 3 | 09-15-2013 06:44 PM |
Adding "Pick a Random Book" in Sharing over the net | ippopom | Recipes | 2 | 01-13-2013 04:32 AM |
Do you pick the book first or do you look for books available on your device? | Bob Russell | Which one should I buy? | 21 | 09-08-2008 12:34 PM |