View Single Post
Old 08-18-2024, 10:50 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: 12,465
Karma: 8025600
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by foosion View Post
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)
How would I do this?
Create a VL with the search expression you wish then use the built-in "Pick a random book" action.

You would probably also want to do one or both of:
  • add the "Pick..." action to some toolbar or context menu.
  • add the "All GUI actions" action somewhere, which gives you access to all actions without putting them on menus etc individually. This action an excellent way to see calibre actions that are hidden by default.

Edit: If your goal is to read (View) the random book, do it in Action chains.
  • Choose the virtual library.
  • Pick a random book.
  • View that book.
  • Turn off the chosen VL.

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.
chaley is offline   Reply With Quote