View Single Post
Old 07-12-2025, 02:27 PM   #46
edojan
Connoisseur
edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.
 
Posts: 68
Karma: 11226
Join Date: Mar 2022
Device: Kobo Libra 2, Aura H2O
[QUOTE=chaley;4524192]
Code:
python:
def evaluate(book, context):
	import os
	from calibre.library import current_library_path

	fmt_metadata = book.get('format_metadata')
	if fmt_metadata:
		for v in fmt_metadata.values():
			# A calibre format name is three section, author, title, format.extension
			# We want to return author/format without the extension
			p = v['path']
			r,f = os.path.split(p)
			format = os.path.splitext(f)[0]
			r,title = os.path.split(r)
			r,author  = os.path.split(r)
			return '/'.join((author, format))
	else:
		return 'title - author'
your code works well also! Thank you for your help.
edojan is offline   Reply With Quote