From b52ee2d1891d86985a507e8bbec08e7c7dc49135 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Mon, 8 Apr 2024 10:15:15 -0400 Subject: [PATCH] [7] Let conditional `.exists` work with default variables --- CHANGELOG | 1 + VERSION | 2 +- modules/imdb.py | 7 +++++-- modules/meta.py | 7 ++++--- modules/plex.py | 7 +++++-- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 200a6f71..d451ca23 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -8,6 +8,7 @@ Add Page Topics Options to `imdb_search` Add `lxml` Docker Version using an old lxml version that supports more cpus # Updates +Let conditional `.not` and `.exists` work with default variables # Defaults diff --git a/VERSION b/VERSION index a2ac0bfb..ee700f52 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.21.0-develop6 +1.21.0-develop7 diff --git a/modules/imdb.py b/modules/imdb.py index 08242ccb..be5fe68c 100644 --- a/modules/imdb.py +++ b/modules/imdb.py @@ -20,8 +20,11 @@ charts = { } imdb_search_attributes = [ "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", - "company", "content_rating", "country", "country.any", "country.not", "country.origin", "keyword", "keyword.any", + "votes.gte", "votes.lte", "genre", "genre.any", "genre.not", "topic", "topic.any", "topic.not", + "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", "language.primary", "popularity.gte", "popularity.lte", "cast", "cast.any", "cast.not", "runtime.gte", "runtime.lte", "adult", diff --git a/modules/meta.py b/modules/meta.py index 66ad1aa1..04ddc311 100644 --- a/modules/meta.py +++ b/modules/meta.py @@ -391,13 +391,14 @@ class DataFile: var_key = replace_var(var_key, [variables, default]) var_value = replace_var(var_value, [variables, default]) 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) 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" - 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" - con_var_value = var_key[:-7] + con_var_value = var_name elif var_key.endswith(".not"): var_name = var_key[:-4] if var_name in variables or var_name in default: diff --git a/modules/plex.py b/modules/plex.py index 402cb9c2..fc627b9e 100644 --- a/modules/plex.py +++ b/modules/plex.py @@ -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): continue keys = {v: k for k, v in options.items()} - if keys[getattr(item, key)] not in ["default", "all", "never"]: - attrs[advance_edit] = keys[getattr(item, key)] + attr = 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): sub_items = {}