added dictionary_variables to tmdb_collections

pull/528/head
meisnate12 3 years ago
parent f33a2df5f0
commit aa95c63794

@ -559,10 +559,22 @@ class ConfigFile:
if "sonarr_remove_by_tag" in lib["operations"]:
params["sonarr_remove_by_tag"] = check_for_attribute(lib["operations"], "sonarr_remove_by_tag", var_type="comma_list", default=False, save=False)
if "tmdb_collections" in lib["operations"]:
params["tmdb_collections"] = {"exclude_ids": [], "remove_suffix": None, "template": {"tmdb_collection_details": "<<collection_id>>"}}
params["tmdb_collections"] = {
"exclude_ids": [],
"remove_suffix": None,
"dictionary_variables": {},
"template": {"tmdb_collection_details": "<<collection_id>>"}
}
if lib["operations"]["tmdb_collections"] and isinstance(lib["operations"]["tmdb_collections"], dict):
params["tmdb_collections"]["exclude_ids"] = check_for_attribute(lib["operations"]["tmdb_collections"], "exclude_ids", var_type="int_list", default_is_none=True, save=False)
params["tmdb_collections"]["remove_suffix"] = check_for_attribute(lib["operations"]["tmdb_collections"], "remove_suffix", default_is_none=True, save=False)
if "dictionary_variables" in lib["operations"]["tmdb_collections"] and lib["operations"]["tmdb_collections"]["dictionary_variables"] and isinstance(lib["operations"]["tmdb_collections"]["dictionary_variables"], dict):
for key, value in lib["operations"]["tmdb_collections"]["dictionary_variables"].items():
if isinstance(value, dict):
params["tmdb_collections"]["dictionary_variables"][key] = value
else:
logger.warning(f"Config Warning: tmdb_collections dictionary_variables {key} must be a dictionary")
if "template" in lib["operations"]["tmdb_collections"] and lib["operations"]["tmdb_collections"]["template"] and isinstance(lib["operations"]["tmdb_collections"]["template"], dict):
params["tmdb_collections"]["template"] = lib["operations"]["tmdb_collections"]["template"]
else:

@ -846,21 +846,21 @@ def library_operations(config, library):
util.separator(f"Starting TMDb Collections")
logger.info("")
suffixes = util.get_list(library.tmdb_collections["remove_suffix"])
def remove_suffixes(_name):
if suffixes:
for suffix in suffixes:
if _name.endswith(suffix):
_name = _name[:-len(_name)]
return _name.strip()
new_collections = {}
for _i, _n in tmdb_collections.items():
if int(_i) not in library.tmdb_collections["exclude_ids"]:
template = {"name": "TMDb Collection", "collection_id": _i}
for k, v in library.tmdb_collections["dictionary_variables"]:
if int(_i) in v:
template[k] = v[int(_i)]
if suffixes:
for suffix in suffixes:
if _n.endswith(suffix):
_n = _n[:-len(_n)]
new_collections[_n.strip()] = {"template": template}
metadata = MetadataFile(config, library, "Data", {
"collections": {
remove_suffixes(_n): {"template": {"name": "TMDb Collection", "collection_id": _i}}
for _i, _n in tmdb_collections.items() if int(_i) not in library.tmdb_collections["exclude_ids"]
},
"templates": {
"TMDb Collection": library.tmdb_collections["template"]
}
"collections": new_collections,
"templates": {"TMDb Collection": library.tmdb_collections["template"]}
})
run_collection(config, library, metadata, metadata.get_collections(None))

Loading…
Cancel
Save