View Single Post
Old 09-09-2023, 10:03 AM   #8875
JimmXinu
Plugin Developer
JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.
 
JimmXinu's Avatar
 
Posts: 6,999
Karma: 4604635
Join Date: Dec 2011
Location: Midwest USA
Device: Kobo Clara Colour running KOReader
The conditional part of a in/exclude_metadata_pre line (after &&) uses the same routines to get metadata values as everything else. Which means replace_metadata has already been applied to rating when the warnings _metadata_pre line is applied.

The wiki page mentions that for replace_metadata but not for in/exclude specifically:
Quote:
NOTE: The way it works is that include/exclude_pre then replace_metadata then include/exclude_post are applied to each metadata entry as it's used, not all metadata as a whole. When using replace_metadata conditional clauses (see ReplaceMetadata), be aware that the include/exclude_metadata for both pre and post will already be applied to the metadata entries you are using in the conditional.
I will update that wording. Changing the behavior is a huge can of worms I'm not opening.

FYI, warnings is a standard metadata entry, you don't need to use add_to_extra_valid_entries:warnings. And be aware that extrawarnings is not universal, there are only a handful of standard metadata entries that have extraX settings.

Here's a solution that works for me:
Code:
add_to_extra_valid_entries:rating_raw
include_in_rating_raw:rating.NOREPL
include_in_warnings:warnings,"CAUTION"

exclude_metadata_pre:
 warnings==CAUTION&&rating_raw!=XXX-I

add_to_replace_metadata:
 rating=>^XXX-I$=>NC-17
I've created a raw copy of rating, replaced the extrawarnings line, and matched only "XXX-I" as an entire string. So if "XXX-II" shows up, it doesn't give you "NC-17I".
JimmXinu is offline   Reply With Quote