View Single Post
Old 07-09-2022, 08:51 AM   #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: 12,476
Karma: 8025702
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
The functions are in calibre 5.99.12 (the calibre 6 beta).

This stored template and template search do the job, assuming I understand you correctly.

Stored template: authors_only_one_book
Code:
program:
	vals = globals(vals='');
	if !vals then
		all_authors = book_values('authors', 'authors:true', '&', 1);
		for aut in all_authors separator '&':
			if book_count('authors:="' & aut & '"', 1) == 1 then 
				vals = list_join('&', vals, '&', aut, '&')
			fi
		rof;
		set_globals(vals)
	fi;

	res = '';
	for aut in 'authors':
		if str_in_list(vals, '&', aut, 1, '') then
			res =  1;
			break
		fi
	rof;
	return res
The template search:
Code:
template:"program: authors_only_one_book()#@#:n:1"
chaley is offline   Reply With Quote