[38] fix visible_* variables in the defaults

This commit is contained in:
meisnate12 2022-12-01 17:28:30 -05:00
parent c8398b902e
commit 782e4eafc4
6 changed files with 70 additions and 47 deletions

View file

@ -1 +1 @@
1.18.0-develop37 1.18.0-develop38

View file

@ -144,9 +144,9 @@ dynamic_collections:
tmdb_movie: tmdb_movie:
halloween: halloween:
- 23437 # A Nightmare on Elm Street (2010) - 23437 # A Nightmare on Elm Street (2010)
visible_home_<<key>>: visible_home:
default: true default: true
visible_shared_<<key>>: visible_shared:
default: true default: true
image: image:
default: seasonal/<<key>> default: seasonal/<<key>>

View file

@ -70,6 +70,8 @@ dynamic_collections:
- "05" - "05"
- "06" - "06"
- G - All Ages - G - All Ages
- A
- no/A
TV-Y: TV-Y:
- TV-Y7 - TV-Y7
- TV-Y7-FV - TV-Y7-FV
@ -79,6 +81,12 @@ dynamic_collections:
- "07" - "07"
- "08" - "08"
- "09" - "09"
- no/5
- no/05
- no/6
- no/06
- no/7
- no/07
TV-PG: TV-PG:
- gb/PG - gb/PG
- gb/9+ - gb/9+
@ -87,6 +95,11 @@ dynamic_collections:
- 12 - 12
- 13 - 13
- PG - Children - PG - Children
- no/9
- no/09
- no/10
- no/11
- no/12
TV-14: TV-14:
- gb/12A - gb/12A
- 12+ - 12+
@ -99,6 +112,8 @@ dynamic_collections:
- 16 - 16
- 17 - 17
- PG-13 - Teens 13 or older - PG-13 - Teens 13 or older
- no/15
- no/16
TV-MA: TV-MA:
- 18 - 18
- gb/18 - gb/18
@ -109,3 +124,4 @@ dynamic_collections:
- R - 17+ (violence & profanity) - R - 17+ (violence & profanity)
- R+ - Mild Nudity - R+ - Mild Nudity
- Rx - Hentai - Rx - Hentai
- no/18

View file

@ -42,13 +42,16 @@ templates:
item_sonarr_tag_<<key>>: <<item_sonarr_tag>> item_sonarr_tag_<<key>>: <<item_sonarr_tag>>
url_poster: https://raw.githubusercontent.com/meisnate12/Plex-Meta-Manager-Images/master/<<image>>.jpg url_poster: https://raw.githubusercontent.com/meisnate12/Plex-Meta-Manager-Images/master/<<image>>.jpg
url_poster_<<key>>: <<url_poster>> url_poster_<<key>>: <<url_poster>>
visible_library_<<key>>: <<visible_library>>
visible_home_<<key>>: <<visible_home>>
visible_shared_<<key>>: <<visible_shared>>
optional: optional:
- use_<<key>> - use_<<key>>
- allowed_libraries - allowed_libraries
- collection_mode - collection_mode
- visible_library_<<key>> - visible_library
- visible_home_<<key>> - visible_home
- visible_shared_<<key>> - visible_shared
- item_radarr_tag - item_radarr_tag
- item_sonarr_tag - item_sonarr_tag
- trakt_list - trakt_list

View file

@ -195,31 +195,31 @@ class DataFile:
raise Failed(f"{self.data_type} Error: template attribute is blank") raise Failed(f"{self.data_type} Error: template attribute is blank")
else: else:
new_attributes = {} new_attributes = {}
for variables in util.get_list(template_call, split=False): for original_variables in util.get_list(template_call, split=False):
if not isinstance(variables, dict): if not isinstance(original_variables, dict):
raise Failed(f"{self.data_type} Error: template attribute is not a dictionary") raise Failed(f"{self.data_type} Error: template attribute is not a dictionary")
elif "name" not in variables: elif "name" not in original_variables:
raise Failed(f"{self.data_type} Error: template sub-attribute name is required") raise Failed(f"{self.data_type} Error: template sub-attribute name is required")
elif not variables["name"]: elif not original_variables["name"]:
raise Failed(f"{self.data_type} Error: template sub-attribute name is blank") raise Failed(f"{self.data_type} Error: template sub-attribute name is blank")
elif variables["name"] not in self.templates: elif original_variables["name"] not in self.templates:
raise Failed(f"{self.data_type} Error: template {variables['name']} not found") raise Failed(f"{self.data_type} Error: template {original_variables['name']} not found")
elif not isinstance(self.templates[variables["name"]][0], dict): elif not isinstance(self.templates[original_variables["name"]][0], dict):
raise Failed(f"{self.data_type} Error: template {variables['name']} is not a dictionary") raise Failed(f"{self.data_type} Error: template {original_variables['name']} is not a dictionary")
else: else:
logger.separator(f"Template {variables['name']}", space=False, border=False, debug=True) logger.separator(f"Template {original_variables['name']}", space=False, border=False, debug=True)
logger.trace("") logger.trace("")
logger.trace(f"Call: {variables}") logger.trace(f"Original: {original_variables}")
remove_variables = [] remove_variables = []
optional = [] optional = []
for tm in variables: for tm in original_variables:
if variables[tm] is None: if original_variables[tm] is None:
remove_variables.append(tm) remove_variables.append(tm)
variables.pop(tm) original_variables.pop(tm)
optional.append(str(tm)) optional.append(str(tm))
template, temp_vars = self.templates[variables["name"]] template, temp_vars = self.templates[original_variables["name"]]
if call_name: if call_name:
name = call_name name = call_name
@ -229,11 +229,23 @@ class DataFile:
name = mapping_name name = mapping_name
name_var = f"{self.data_type.lower()}_name" name_var = f"{self.data_type.lower()}_name"
variables[name_var] = str(name) original_variables[name_var] = str(name)
variables["mapping_name"] = mapping_name original_variables["mapping_name"] = mapping_name
variables["library_type"] = self.library.type.lower() if self.library else "item" original_variables["library_type"] = self.library.type.lower() if self.library else "item"
variables["library_typeU"] = self.library.type if self.library else "Item" original_variables["library_typeU"] = self.library.type if self.library else "Item"
variables["library_name"] = self.library.name if self.library else "playlist" original_variables["library_name"] = self.library.name if self.library else "playlist"
def replace_var(input_item, search_dicts):
if not isinstance(search_dicts, list):
search_dicts = [search_dicts]
return_item = input_item
for search_dict in search_dicts:
for rk, rv in search_dict.items():
if f"<<{rk}>>" == str(return_item):
return_item = rv
if f"<<{rk}>>" in str(return_item):
return_item = str(return_item).replace(f"<<{rk}>>", str(rv))
return return_item
conditionals = {} conditionals = {}
if "conditionals" in template: if "conditionals" in template:
@ -254,8 +266,10 @@ class DataFile:
init_defaults = template["default"] init_defaults = template["default"]
all_init_defaults = {k: v for k, v in init_defaults.items()} all_init_defaults = {k: v for k, v in init_defaults.items()}
variables = {}
temp_conditionals = {} temp_conditionals = {}
for input_dict, input_type, overwrite_call in [ for input_dict, input_type, overwrite_call in [
(original_variables, "Call", False),
(temp_vars, "External", False), (temp_vars, "External", False),
(extra_variables, "Definition", False), (extra_variables, "Definition", False),
(self.temp_vars, "Config", True) (self.temp_vars, "Config", True)
@ -277,7 +291,9 @@ class DataFile:
raise Failed(f"{self.data_type} Error: {input_type} template sub-attribute default is not a dictionary") raise Failed(f"{self.data_type} Error: {input_type} template sub-attribute default is not a dictionary")
for dk, dv in input_value.items(): for dk, dv in input_value.items():
all_init_defaults[dk] = dv all_init_defaults[dk] = dv
elif input_value is None: else:
input_key = replace_var(input_key, original_variables)
if input_value is None:
optional.append(str(input_key)) optional.append(str(input_key))
if input_key in variables: if input_key in variables:
variables.pop(input_key) variables.pop(input_key)
@ -312,18 +328,6 @@ class DataFile:
variables["key_name"] = key_name_variables[variables["key_name"]] variables["key_name"] = key_name_variables[variables["key_name"]]
variables["translated_key_name"] = variables["key_name"] variables["translated_key_name"] = variables["key_name"]
def replace_var(input_item, search_dicts):
if not isinstance(search_dicts, list):
search_dicts = [search_dicts]
return_item = input_item
for search_dict in search_dicts:
for rk, rv in search_dict.items():
if f"<<{rk}>>" == str(return_item):
return_item = rv
if f"<<{rk}>>" in str(return_item):
return_item = str(return_item).replace(f"<<{rk}>>", str(rv))
return return_item
default = {} default = {}
if all_init_defaults: 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} var_default = {replace_var(dk, variables): replace_var(dv, variables) for dk, dv in all_init_defaults.items() if dk not in variables}