View Single Post
Old 08-19-2024, 06:22 AM   #12
foosion
Evangelist
foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.foosion is an enigma wrapped up in a mystery.
 
Posts: 479
Karma: 41524
Join Date: Sep 2011
Device: Kobo Libra 2 & Clara BW
Quote:
Originally Posted by chaley View Post
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)
That is very powerful. I need to learn the Calibre API.

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?
foosion is offline   Reply With Quote