From 6298bccdc2bbf99a87e36f05cfef33dd37029016 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Thu, 20 Oct 2022 09:32:09 -0400 Subject: [PATCH] [139] fix library_translation issue --- VERSION | 2 +- modules/meta.py | 28 +++++++++++++--------------- modules/plex.py | 2 +- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/VERSION b/VERSION index 97f73ef8..5c069a15 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.17.3-develop138 +1.17.3-develop139 diff --git a/modules/meta.py b/modules/meta.py index 7702cbf2..ba9b22c9 100644 --- a/modules/meta.py +++ b/modules/meta.py @@ -74,6 +74,7 @@ class DataFile: self.templates = {} self.translations = {} self.key_names = {} + self.translation_variables = {} def get_file_name(self): data = f"{self.config.GitHub.configs_url}{self.path}.yml" if self.type == "GIT" else self.path @@ -147,16 +148,17 @@ class DataFile: translations = {k: {"default": v} for k, v in yaml.data["translations"].items()} lib_type = self.library.type.lower() if self.library else "item" logger.debug(f"Translations Loaded From: {dir_path}") - key_names = {k: {"default": v[lib_type]} for k, v in yaml.data["variables"].items()} + key_names = {} + variables = {k: {"default": v[lib_type]} for k, v in yaml.data["variables"].items()} def add_translation(yaml_path, yaml_key, data=None): yaml_content = YAML(input_data=data, path=yaml_path if data is None else None, check_empty=True) if "variables" in yaml_content.data and yaml_content.data["variables"]: for var_key, var_value in yaml_content.data["variables"].items(): if lib_type in var_value: - if var_key not in key_names: - key_names[var_key] = {} - key_names[var_key][yaml_key] = var_value[lib_type] + if var_key not in variables: + variables[var_key] = {} + variables[var_key][yaml_key] = var_value[lib_type] if "translations" in yaml_content.data and yaml_content.data["translations"]: for ky, vy in yaml_content.data["translations"].items(): @@ -184,7 +186,7 @@ class DataFile: for file in os.listdir(dir_path): if file.endswith(".yml") and file != "default.yml": add_translation(os.path.abspath(f"{dir_path}/{file}"), file[:-4]) - return translations, key_names + return translations, key_names, variables def apply_template(self, call_name, mapping_name, data, template_call, extra_variables): if not self.templates: @@ -262,6 +264,7 @@ class DataFile: language = variables["language"] if "language" in variables else "default" translation_variables = {k: v[language if language in v else "default"] for k, v in self.translations.items()} + translation_variables.update({k: v[language if language in v else "default"] for k, v in self.translation_variables.items()}) key_name_variables = {} for var_key, var_value in self.key_names.items(): if var_key == "library_type" and language in var_value: @@ -491,9 +494,7 @@ class DataFile: for file_type, template_file, temp_vars, _ in files: temp_data = self.load_file(file_type, template_file, overlay=overlay) if temp_data and isinstance(temp_data, dict) and "templates" in temp_data and temp_data["templates"] and isinstance(temp_data["templates"], dict): - for temp_key, temp_value in temp_data["templates"].items(): - if temp_key not in self.templates: - self.templates[temp_key] = (temp_value, temp_vars) + self.templates.update({k: (v, temp_vars) for k, v in temp_data["templates"].items() if k not in self.templates}) def translation_files(self, data, overlay=False): if data and "translations" in data and data["translations"]: @@ -501,13 +502,10 @@ class DataFile: if not files: logger.error("Config Error: No Paths Found for translations") for file_type, template_file, _, _ in files: - temp_data, key_data = self.load_file(file_type, template_file, overlay=overlay, translation=True) - for k, v in temp_data.items(): - if k not in self.translations: - self.translations[k] = v - for k, v in key_data.items(): - if k not in self.key_names: - self.key_names[k] = v + temp_data, key_data, variables = self.load_file(file_type, template_file, overlay=overlay, translation=True) + self.translations.update({k: v for k, v in temp_data.items() if k not in self.translations}) + self.key_names.update({k: v for k, v in key_data.items() if k not in self.key_names}) + self.translation_variables.update({k: v for k, v in variables.items() if k not in self.translation_variables}) class MetadataFile(DataFile): def __init__(self, config, library, file_type, path, temp_vars, asset_directory): diff --git a/modules/plex.py b/modules/plex.py index 0c10636d..8e6b8f6b 100644 --- a/modules/plex.py +++ b/modules/plex.py @@ -295,7 +295,7 @@ float_attributes = [ float_modifiers = number_modifiers + [".rated"] search_display = {"added": "Date Added", "release": "Release Date", "hdr": "HDR", "progress": "In Progress", "episode_progress": "Episode In Progress"} tag_attributes = [ - "actor", "audio_language", "collection", "content_rating", "country", "director", "genre", "label", "network", + "actor", "audio_language", "collection", "content_rating", "country", "director", "genre", "label", "season_label", "episode_label", "network", "producer", "resolution", "studio", "subtitle_language", "writer", "season_collection", "episode_collection", "edition", "artist_genre", "artist_collection", "artist_country", "artist_mood", "artist_label", "artist_style", "album_genre", "album_mood", "album_style", "album_format", "album_type", "album_collection", "album_source", "album_label", "track_mood", "track_source", "track_label"