[33] add custom_keys to dynamic attributes

pull/811/head
meisnate12 3 years ago
parent 4d2bf6b304
commit 7b7b174e61

@ -1 +1 @@
1.16.2-develop32
1.16.2-develop33

@ -1,4 +1,4 @@
import operator, os, re
import math, operator, os, re
from datetime import datetime
from modules import plex, ergast, util
from modules.util import Failed, ImageData
@ -243,7 +243,6 @@ class MetadataFile(DataFile):
self.collections = get_dict("collections", data, library.collections)
self.dynamic_collections = get_dict("dynamic_collections", data)
col_names = library.collections + [c for c in self.collections]
all_items = None
if self.dynamic_collections:
logger.info("")
logger.separator("Dynamic Collections")
@ -267,10 +266,15 @@ class MetadataFile(DataFile):
auto_type = dynamic[methods["type"]].lower()
og_exclude = util.parse("Config", "exclude", dynamic, parent=map_name, methods=methods, datatype="strlist") if "exclude" in methods else []
include = util.parse("Config", "include", dynamic, parent=map_name, methods=methods, datatype="strlist") if "include" in methods else []
custom_keys = util.parse("Config", "custom_keys", dynamic, parent=map_name, methods=methods, datatype="dictliststr") if "custom_keys" in methods else {}
if og_exclude and include:
raise Failed(f"Config Error: {map_name} cannot have both include and exclude attributes")
addons = util.parse("Config", "addons", dynamic, parent=map_name, methods=methods, datatype="dictliststr") if "addons" in methods else {}
exclude = [str(e) for e in og_exclude]
for custom_key, combined_keys in custom_keys.items():
for combined_key in combined_keys:
if combined_key not in exclude:
exclude.append(combined_key)
for k, v in addons.items():
if k in v:
logger.warning(f"Config Warning: {k} cannot be an addon for itself")
@ -417,6 +421,15 @@ class MetadataFile(DataFile):
_check_dict(self.config.Trakt.get_people(option))
else:
raise Failed(f"Config Error: {map_name} type attribute {dynamic[methods['type']]} invalid")
for custom_key, combined_keys in custom_keys.items():
if custom_key in all_keys:
raise Failed(f"Config Error: Custom key: {custom_key} cannot be an actual key")
final_keys = [ck for ck in combined_keys if ck in all_keys]
if final_keys:
if include:
include.append(custom_key)
auto_list[custom_key] = custom_key
addons[custom_key] = final_keys
title_format = default_title_format
if "title_format" in methods:
title_format = util.parse("Config", "title_format", dynamic, parent=map_name, methods=methods, default=default_title_format)
@ -453,6 +466,7 @@ class MetadataFile(DataFile):
logger.debug(f"Data: {dynamic_data}")
logger.debug(f"Exclude: {exclude}")
logger.debug(f"Addons: {addons}")
logger.debug(f"Custom Keys: {custom_keys}")
logger.debug(f"Template: {template_name}")
logger.debug(f"Template Variables: {template_variables}")
logger.debug(f"Remove Prefix: {remove_prefix}")

Loading…
Cancel
Save