diff --git a/modules/builder.py b/modules/builder.py index 10ed940e..9617e4d1 100644 --- a/modules/builder.py +++ b/modules/builder.py @@ -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", diff --git a/modules/config.py b/modules/config.py index f7188c7a..3952d4ad 100644 --- a/modules/config.py +++ b/modules/config.py @@ -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": "<>"}} + params["tmdb_collections"] = {"exclude_ids": [], "remove_suffix": None, "template": {"tmdb_collection_details": "<>"}} 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"] = {} diff --git a/modules/library.py b/modules/library.py index e5f5b537..fb55edcd 100644 --- a/modules/library.py +++ b/modules/library.py @@ -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("") diff --git a/plex_meta_manager.py b/plex_meta_manager.py index 21cf262f..f79c0f3c 100644 --- a/plex_meta_manager.py +++ b/plex_meta_manager.py @@ -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"] },