[7] Let conditional .exists work with default variables

This commit is contained in:
meisnate12 2024-04-08 10:15:15 -04:00
parent b5e44976bd
commit b52ee2d189
5 changed files with 16 additions and 8 deletions

View file

@ -8,6 +8,7 @@ Add Page Topics Options to `imdb_search`
Add `lxml` Docker Version using an old lxml version that supports more cpus Add `lxml` Docker Version using an old lxml version that supports more cpus
# Updates # Updates
Let conditional `.not` and `.exists` work with default variables
# Defaults # Defaults

View file

@ -1 +1 @@
1.21.0-develop6 1.21.0-develop7

View file

@ -20,8 +20,11 @@ charts = {
} }
imdb_search_attributes = [ imdb_search_attributes = [
"limit", "sort_by", "title", "type", "type.not", "release.after", "release.before", "rating.gte", "rating.lte", "limit", "sort_by", "title", "type", "type.not", "release.after", "release.before", "rating.gte", "rating.lte",
"votes.gte", "votes.lte", "genre", "genre.any", "genre.not", "event", "event.winning", "imdb_top", "imdb_bottom", "votes.gte", "votes.lte", "genre", "genre.any", "genre.not", "topic", "topic.any", "topic.not",
"company", "content_rating", "country", "country.any", "country.not", "country.origin", "keyword", "keyword.any", "alternate_version", "alternate_version.not", "crazy_credit", "crazy_credit.not", "location", "location.not",
"goof", "goof.not", "plot", "plot.not", "quote", "quote.not", "soundtrack", "soundtrack.not",
"trivia", "trivia.not", "event", "event.winning", "imdb_top", "imdb_bottom", "company", "content_rating",
"country", "country.any", "country.not", "country.origin", "keyword", "keyword.any",
"keyword.not", "series", "series.not", "list", "list.any", "list.not", "language", "language.any", "language.not", "keyword.not", "series", "series.not", "list", "list.any", "list.not", "language", "language.any", "language.not",
"language.primary", "popularity.gte", "popularity.lte", "cast", "cast.any", "cast.not", "runtime.gte", "language.primary", "popularity.gte", "popularity.lte", "cast", "cast.any", "cast.not", "runtime.gte",
"runtime.lte", "adult", "runtime.lte", "adult",

View file

@ -391,13 +391,14 @@ class DataFile:
var_key = replace_var(var_key, [variables, default]) var_key = replace_var(var_key, [variables, default])
var_value = replace_var(var_value, [variables, default]) var_value = replace_var(var_value, [variables, default])
if var_key.endswith(".exists"): if var_key.endswith(".exists"):
var_name = var_key[:-7]
con_var_value = util.parse(self.data_type, var_key, var_value, datatype="bool", default=False) con_var_value = util.parse(self.data_type, var_key, var_value, datatype="bool", default=False)
if con_var_value: if con_var_value:
if var_key[:-7] not in variables or variables[var_key[:-7]] is None: if (var_name not in variables or variables[var_name] is None) and (var_name not in default and default[var_name] is None):
error_text = "- does not exist" error_text = "- does not exist"
elif var_key[:-7] in variables and variables[var_key[:-7]] is not None: elif (var_name in variables and variables[var_name] is not None) or (var_name in default and default[var_name] is not None):
error_text = "- exists" error_text = "- exists"
con_var_value = var_key[:-7] con_var_value = var_name
elif var_key.endswith(".not"): elif var_key.endswith(".not"):
var_name = var_key[:-4] var_name = var_key[:-4]
if var_name in variables or var_name in default: if var_name in variables or var_name in default:

View file

@ -1615,8 +1615,11 @@ class Plex(Library):
if advance_edit in self.metadata_backup["exclude"] or not hasattr(item, key) or not getattr(item, key): if advance_edit in self.metadata_backup["exclude"] or not hasattr(item, key) or not getattr(item, key):
continue continue
keys = {v: k for k, v in options.items()} keys = {v: k for k, v in options.items()}
if keys[getattr(item, key)] not in ["default", "all", "never"]: attr = getattr(item, key)
attrs[advance_edit] = keys[getattr(item, key)] if attr not in keys:
logger.error(f"Item {item.title} {advance_edit} {attr} Not Found rating key: {item.ratingKey}")
elif keys[attr] not in ["default", "all", "never"]:
attrs[advance_edit] = keys[attr]
def _recur(sub, item_type_in=None): def _recur(sub, item_type_in=None):
sub_items = {} sub_items = {}