From 9a94861ced476de6b6664970c45320b449c839d0 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Wed, 9 Nov 2022 15:13:04 -0500 Subject: [PATCH] [2] fix metadata file assets --- VERSION | 2 +- modules/meta.py | 11 ++++++----- modules/plex.py | 4 ++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/VERSION b/VERSION index 52db8a87..40add566 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.18.0-develop1 +1.18.0-develop2 diff --git a/modules/meta.py b/modules/meta.py index 806c491e..195fbf0c 100644 --- a/modules/meta.py +++ b/modules/meta.py @@ -252,6 +252,7 @@ class DataFile: if not isinstance(template["default"], dict): raise Failed(f"{self.data_type} Error: template sub-attribute default is not a dictionary") init_defaults = template["default"] + all_init_defaults = {k: v for k, v in init_defaults.items()} for input_dict, input_type, overwrite_call in [ (temp_vars, "External", False), (extra_variables, "Definition", False), @@ -273,7 +274,7 @@ class DataFile: if not isinstance(input_value, dict): raise Failed(f"{self.data_type} Error: {input_type} template sub-attribute default is not a dictionary") for dk, dv in input_value.items(): - init_defaults[dk] = dv + all_init_defaults[dk] = dv elif input_value is None: optional.append(str(input_key)) elif overwrite_call: @@ -310,8 +311,8 @@ class DataFile: return return_item default = {} - if init_defaults: - var_default = {replace_var(dk, variables): replace_var(dv, variables) for dk, dv in init_defaults.items() if dk not in variables} + if all_init_defaults: + var_default = {replace_var(dk, variables): replace_var(dv, variables) for dk, dv in all_init_defaults.items() if dk not in variables} for dkey, dvalue in var_default.items(): final_key = replace_var(dkey, var_default) final_value = replace_var(dvalue, var_default) @@ -326,7 +327,7 @@ class DataFile: if op not in default and op not in conditionals: optional.append(str(op)) optional.append(f"{op}_encoded") - else: + elif op in init_defaults: logger.debug("") logger.debug(f"Template Warning: variable {op} cannot be optional if it has a default") else: @@ -1243,7 +1244,7 @@ class MetadataFile(DataFile): logger.info(f"{self.library.type}: {mapping_name} Details Update {'Complete' if updated else 'Not Needed'}") - asset_location, folder_name = self.library.item_images(item, meta, methods, initial=True, asset_location=self.asset_directory if self.asset_directory else None) + asset_location, folder_name = self.library.item_images(item, meta, methods, initial=True, asset_directory=self.asset_directory + self.library.asset_directory if self.asset_directory else None) if "seasons" in methods and self.library.is_show: if not meta[methods["seasons"]]: diff --git a/modules/plex.py b/modules/plex.py index eebe3024..86ecf786 100644 --- a/modules/plex.py +++ b/modules/plex.py @@ -1045,12 +1045,12 @@ class Plex(Library): logger.info(final) return final[28:] if final else final - def item_images(self, item, group, alias, initial=False, asset_location=None, title=None, image_name=None, folder_name=None): + def item_images(self, item, group, alias, initial=False, asset_location=None, asset_directory=None, title=None, image_name=None, folder_name=None): if title is None: title = item.title posters, backgrounds = util.get_image_dicts(group, alias) try: - asset_poster, asset_background, item_dir, folder_name = self.find_item_assets(item, item_asset_directory=asset_location) + asset_poster, asset_background, item_dir, folder_name = self.find_item_assets(item, item_asset_directory=asset_location, asset_directory=asset_directory) if asset_poster: posters["asset_directory"] = asset_poster if asset_background: