From 3b703da1f35f8423ee981a3b9d48ece02e0260ea Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Tue, 17 Jan 2023 21:28:10 -0600 Subject: [PATCH] Add r_anthmax/n_anthmax options for custom_columns_settings --- calibre-plugin/fff_plugin.py | 13 ++++++++----- calibre-plugin/plugin-defaults.ini | 9 +++++++-- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/calibre-plugin/fff_plugin.py b/calibre-plugin/fff_plugin.py index 15185e67..32b8c624 100644 --- a/calibre-plugin/fff_plugin.py +++ b/calibre-plugin/fff_plugin.py @@ -2337,9 +2337,11 @@ class FanFicFarePlugin(InterfaceAction): (meta,custcol) = [ x.strip() for x in line.split("=>") ] flag='r' anthaver=False + anthmax=False if "," in custcol: (custcol,flag) = [ x.strip() for x in custcol.split(",") ] anthaver = 'anthaver' in flag + anthmax = 'anthmax' in flag flag=flag[0] # first char only. if meta not in book['all_metadata']: @@ -2369,13 +2371,14 @@ class FanFicFarePlugin(InterfaceAction): if 'anthology_meta_list' in book and meta in book['anthology_meta_list']: # re-split list, strip commas, convert to floats items = [ float(x.replace(",","")) for x in val.split(", ") ] - if anthaver: - if items: + val = 0 + if items: + if anthaver: val = sum(items) / float(len(items)) + elif anthmax: + val = max(items) else: - val = 0 - else: - val = sum(items) + val = sum(items) else: val = unicode(val).replace(",","") else: diff --git a/calibre-plugin/plugin-defaults.ini b/calibre-plugin/plugin-defaults.ini index 8bdecd60..c3a09d12 100644 --- a/calibre-plugin/plugin-defaults.ini +++ b/calibre-plugin/plugin-defaults.ini @@ -347,8 +347,13 @@ conditionals_use_lists:true ## 'r' and 'n' for normal downloads, but to average the metadata for ## the differents story in an anthology before setting in integer and ## float type custom columns. This can be useful for a averrating -## column, for example. Default is to sum the values of all stories, -## and numChapters and numWords are always summed. +## column, for example. +## 'r_anthmax' and 'n_anthmax' indicate 'r' and 'n' for normal +## downloads, but to use the highest value for the metadata from the +## differents story in an anthology in integer and float type custom +## columns. +## Default is to sum the values of all stories, and numChapters and +## numWords are always summed. #custom_columns_settings: # cliches=>#acolumn