update tmdb_collections

pull/487/head
meisnate12 3 years ago
parent 35b9896650
commit e81e07b003

@ -37,7 +37,7 @@ method_alias = {
"producers": "producer",
"writers": "writer",
"years": "year", "show_year": "year", "show_years": "year",
"show_title": "title",
"show_title": "title", "filter": "filters",
"seasonyear": "year", "isadult": "adult", "startdate": "start", "enddate": "end", "averagescore": "score",
"minimum_tag_percentage": "min_tag_percent", "minimumtagrank": "min_tag_percent", "minimum_tag_rank": "min_tag_percent",
"anilist_tag": "anilist_search", "anilist_genre": "anilist_search", "anilist_season": "anilist_search",

@ -481,16 +481,20 @@ class Config:
if "sonarr_add_all" in lib["operations"]:
params["sonarr_add_all"] = check_for_attribute(lib["operations"], "sonarr_add_all", var_type="bool", default=False, save=False)
if "tmdb_collections" in lib["operations"]:
params["tmdb_collections"] = {"exclude_ids": [], "remove_collection": False, "template": {"tmdb_collection_details": "<<collection_id>>"}}
params["tmdb_collections"] = {"exclude_ids": [], "remove_suffix": None, "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_collection"] = check_for_attribute(lib["operations"]["tmdb_collections"], "remove_collection", var_type="bool", default=False, save=False)
params["tmdb_collections"]["remove_suffix"] = check_for_attribute(lib["operations"]["tmdb_collections"], "remove_suffix", default_is_none=True, save=False)
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:
logger.warning("Config Warning: Using default template for tmdb_collections")
else:
logger.error("Config Error: tmdb_collections blank using default settings")
if params["tmdb_collections"]["exclude_ids"] is None:
params["tmdb_collections"]["exclude_ids"] = []
if params["tmdb_collections"]["remove_suffix"]:
params["tmdb_collections"]["remove_suffix"] = params["tmdb_collections"]["remove_suffix"].strip()
if "genre_mapper" in lib["operations"]:
if lib["operations"]["genre_mapper"] and isinstance(lib["operations"]["genre_mapper"], dict):
params["genre_mapper"] = {}

@ -69,7 +69,10 @@ class Library(ABC):
self.clean_bundles = params["plex"]["clean_bundles"] # TODO: Here or just in Plex?
self.empty_trash = params["plex"]["empty_trash"] # TODO: Here or just in Plex?
self.optimize = params["plex"]["optimize"] # TODO: Here or just in Plex?
self.library_operation = self.assets_for_all or self.delete_unmanaged_collections or self.delete_collections_with_less \
or self.mass_genre_update or self.mass_audience_rating_update or self.mass_critic_rating_update \
or self.mass_trakt_rating_update or self.radarr_add_all or self.sonarr_add_all \
or self.tmdb_collections or self.genre_mapper
metadata = []
for file_type, metadata_file in self.metadata_path:
if file_type == "Folder":
@ -94,9 +97,9 @@ class Library(ABC):
except Failed as e:
util.print_multiline(e, error=True)
if len(self.metadata_files) == 0:
if len(self.metadata_files) == 0 and not self.library_operation:
logger.info("")
raise Failed("Metadata File Error: No valid metadata files found")
raise Failed("Config Error: No valid metadata files or library operations found")
if self.asset_directory:
logger.info("")

@ -235,12 +235,11 @@ def update_libraries(config):
logger.debug(f"Optimize: {library.optimize}")
logger.debug(f"Timeout: {library.timeout}")
items = None
if not library.is_other:
logger.info("")
util.separator(f"Mapping {library.name} Library", space=False, border=False)
logger.info("")
items = library.map_guids()
library.map_guids()
for metadata in library.metadata_files:
logger.info("")
util.separator(f"Running Metadata File\n{metadata.path}")
@ -272,7 +271,7 @@ def update_libraries(config):
builder.sort_collection()
if not config.test_mode and not collection_only:
library_operations(config, library, items=items)
library_operations(config, library)
logger.removeHandler(library_handler)
except Exception as e:
@ -335,7 +334,7 @@ def update_libraries(config):
if library.optimize:
library.query(library.PlexServer.library.optimize)
def library_operations(config, library, items=None):
def library_operations(config, library):
logger.info("")
util.separator(f"{library.name} Library Operations")
logger.info("")
@ -363,8 +362,7 @@ def library_operations(config, library, items=None):
logger.info(util.adjust_space(f"{item.title[:25]:<25} | Splitting"))
if tmdb_operation:
if items is None:
items = library.get_all()
items = library.get_all()
radarr_adds = []
sonarr_adds = []
tmdb_collections = {}
@ -535,7 +533,7 @@ def library_operations(config, library, items=None):
logger.info("")
metadata = Metadata(config, library, "Data", {
"collections": {
_n.replace(" Collection", "") if library.tmdb_collections["remove_collection"] else _n:
_n.replace(library.tmdb_collections["remove_suffix"], "").strip() if library.tmdb_collections["remove_suffix"] else _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"]
},

Loading…
Cancel
Save