diff --git a/modules/config.py b/modules/config.py index b9f860ab..2bfd3f63 100644 --- a/modules/config.py +++ b/modules/config.py @@ -79,32 +79,34 @@ class ConfigFile: replace_attr(new_config, "save_missing", "plex") if new_config["libraries"]: for library in new_config["libraries"]: + if not new_config["libraries"][library]: + continue if "radarr_add_all" in new_config["libraries"][library]: new_config["libraries"][library]["radarr_add_all_existing"] = new_config["libraries"][library].pop("radarr_add_all") if "sonarr_add_all" in new_config["libraries"][library]: new_config["libraries"][library]["sonarr_add_all_existing"] = new_config["libraries"][library].pop("sonarr_add_all") - if new_config["libraries"][library] and "plex" in new_config["libraries"][library]: + if "plex" in new_config["libraries"][library]: replace_attr(new_config["libraries"][library], "asset_directory", "plex") replace_attr(new_config["libraries"][library], "sync_mode", "plex") replace_attr(new_config["libraries"][library], "show_unmanaged", "plex") replace_attr(new_config["libraries"][library], "show_filtered", "plex") replace_attr(new_config["libraries"][library], "show_missing", "plex") replace_attr(new_config["libraries"][library], "save_missing", "plex") - if new_config["libraries"][library] and "settings" in new_config["libraries"][library]: + if "settings" in new_config["libraries"][library]: if "collection_minimum" in new_config["libraries"][library]["settings"]: new_config["libraries"][library]["settings"]["minimum_items"] = new_config["libraries"][library]["settings"].pop("collection_minimum") - if new_config["libraries"][library] and "radarr" in new_config["libraries"][library]: + if "radarr" in new_config["libraries"][library]: if "add" in new_config["libraries"][library]["radarr"]: new_config["libraries"][library]["radarr"]["add_missing"] = new_config["libraries"][library]["radarr"].pop("add") - if new_config["libraries"][library] and "sonarr" in new_config["libraries"][library]: + if "sonarr" in new_config["libraries"][library]: if "add" in new_config["libraries"][library]["sonarr"]: new_config["libraries"][library]["sonarr"]["add_missing"] = new_config["libraries"][library]["sonarr"].pop("add") - if new_config["libraries"][library] and "operations" in new_config["libraries"][library]: + if "operations" in new_config["libraries"][library]: if "radarr_add_all" in new_config["libraries"][library]["operations"]: new_config["libraries"][library]["operations"]["radarr_add_all_existing"] = new_config["libraries"][library]["operations"].pop("radarr_add_all") if "sonarr_add_all" in new_config["libraries"][library]["operations"]: new_config["libraries"][library]["operations"]["sonarr_add_all_existing"] = new_config["libraries"][library]["operations"].pop("sonarr_add_all") - if new_config["libraries"][library] and "webhooks" in new_config["libraries"][library] and "collection_changes" not in new_config["libraries"][library]["webhooks"]: + if "webhooks" in new_config["libraries"][library] and "collection_changes" not in new_config["libraries"][library]["webhooks"]: changes = [] def hooks(attr): if attr in new_config["libraries"][library]["webhooks"]: diff --git a/modules/library.py b/modules/library.py index a42fc31c..6c226492 100644 --- a/modules/library.py +++ b/modules/library.py @@ -67,9 +67,9 @@ class Library(ABC): self.mass_audience_rating_update = params["mass_audience_rating_update"] self.mass_critic_rating_update = params["mass_critic_rating_update"] self.mass_trakt_rating_update = params["mass_trakt_rating_update"] - self.radarr_add_all = params["radarr_add_all"] + self.radarr_add_all_existing = params["radarr_add_all_existing"] self.radarr_remove_by_tag = params["radarr_remove_by_tag"] - self.sonarr_add_all = params["sonarr_add_all"] + self.sonarr_add_all_existing = params["sonarr_add_all_existing"] self.sonarr_remove_by_tag = params["sonarr_remove_by_tag"] self.mass_collection_mode = params["mass_collection_mode"] self.tmdb_collections = params["tmdb_collections"] @@ -80,10 +80,13 @@ 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 + + self.tmdb_library_operation = self.assets_for_all 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.tmdb_collections or self.radarr_add_all_existing or self.sonarr_add_all_existing + self.library_operation = self.tmdb_library_operation or self.delete_unmanaged_collections or self.delete_collections_with_less \ + or self.radarr_remove_by_tag or self.sonarr_remove_by_tag or self.mass_collection_mode \ + or self.genre_mapper metadata = [] for file_type, metadata_file in self.metadata_path: if file_type == "Folder": diff --git a/modules/plex.py b/modules/plex.py index 262e9a57..592ec429 100644 --- a/modules/plex.py +++ b/modules/plex.py @@ -263,7 +263,7 @@ number_attributes = ["plays", "episode_plays", "duration", "tmdb_vote_count", "a search_display = {"added": "Date Added", "release": "Release Date", "hdr": "HDR", "progress": "In Progress", "episode_progress": "Episode In Progress"} tag_attributes = [ "actor", "audio_language", "collection", "content_rating", "country", "director", "genre", "label", "network", - "producer", "resolution", "studio", "subtitle_language", "writer" "artist_genre", "artist_collection", + "producer", "resolution", "studio", "subtitle_language", "writer", "artist_genre", "artist_collection", "artist_country", "artist_mood", "artist_style", "album_genre", "album_mood", "album_style", "album_format", "album_type", "album_collection", "album_source", "album_label", "track_mood", "track_source" ] diff --git a/plex_meta_manager.py b/plex_meta_manager.py index 71c0f74e..d1a62cfb 100644 --- a/plex_meta_manager.py +++ b/plex_meta_manager.py @@ -229,18 +229,6 @@ def update_libraries(config): logger.debug(f"Show Missing: {library.show_missing}") logger.debug(f"Show Missing Assets: {library.show_missing_assets}") logger.debug(f"Save Missing: {library.save_missing}") - logger.debug(f"Assets For All: {library.assets_for_all}") - logger.debug(f"Delete Collections With Less: {library.delete_collections_with_less}") - logger.debug(f"Delete Unmanaged Collections: {library.delete_unmanaged_collections}") - logger.debug(f"Mass Genre Update: {library.mass_genre_update}") - logger.debug(f"Mass Audience Rating Update: {library.mass_audience_rating_update}") - logger.debug(f"Mass Critic Rating Update: {library.mass_critic_rating_update}") - logger.debug(f"Mass Trakt Rating Update: {library.mass_trakt_rating_update}") - logger.debug(f"Split Duplicates: {library.split_duplicates}") - logger.debug(f"Radarr Add All: {library.radarr_add_all}") - logger.debug(f"Sonarr Add All: {library.sonarr_add_all}") - logger.debug(f"TMDb Collections: {library.tmdb_collections}") - logger.debug(f"Genre Mapper: {library.genre_mapper}") logger.debug(f"Clean Bundles: {library.clean_bundles}") logger.debug(f"Empty Trash: {library.empty_trash}") logger.debug(f"Optimize: {library.optimize}") @@ -281,7 +269,7 @@ def update_libraries(config): logger.info("") builder.sort_collection() - if not config.test_mode and not collection_only: + if library.library_operation and not config.test_mode and not collection_only: library_operations(config, library) logger.removeHandler(library_handler) @@ -370,16 +358,13 @@ def library_operations(config, library): logger.debug(f"Mass Trakt Rating Update: {library.mass_trakt_rating_update}") logger.debug(f"Mass Collection Mode Update: {library.mass_collection_mode}") logger.debug(f"Split Duplicates: {library.split_duplicates}") - logger.debug(f"Radarr Add All: {library.radarr_add_all}") + logger.debug(f"Radarr Add All Existing: {library.radarr_add_all_existing}") logger.debug(f"Radarr Remove by Tag: {library.radarr_remove_by_tag}") - logger.debug(f"Sonarr Add All: {library.sonarr_add_all}") + logger.debug(f"Sonarr Add All Existing: {library.sonarr_add_all_existing}") logger.debug(f"Sonarr Remove by Tag: {library.sonarr_remove_by_tag}") logger.debug(f"TMDb Collections: {library.tmdb_collections}") logger.debug(f"Genre Mapper: {library.genre_mapper}") - tmdb_operation = library.assets_for_all or library.mass_genre_update or library.mass_audience_rating_update \ - or library.mass_critic_rating_update or library.mass_trakt_rating_update \ - or library.tmdb_collections or library.radarr_add_all or library.sonarr_add_all - logger.debug(f"TMDb Operation: {tmdb_operation}") + logger.debug(f"TMDb Operation: {library.tmdb_library_operation}") if library.split_duplicates: items = library.search(**{"duplicate": True}) @@ -387,7 +372,7 @@ def library_operations(config, library): item.split() logger.info(util.adjust_space(f"{item.title[:25]:<25} | Splitting")) - if tmdb_operation: + if library.tmdb_library_operation: items = library.get_all() radarr_adds = [] sonarr_adds = [] @@ -435,11 +420,11 @@ def library_operations(config, library): pass path = os.path.dirname(str(item.locations[0])) if library.is_movie else str(item.locations[0]) - if library.Radarr and library.radarr_add_all and tmdb_id: + if library.Radarr and library.radarr_add_all_existing and tmdb_id: path = path.replace(library.Radarr.plex_path, library.Radarr.radarr_path) path = path[:-1] if path.endswith(('/', '\\')) else path radarr_adds.append((tmdb_id, path)) - if library.Sonarr and library.sonarr_add_all and tvdb_id: + if library.Sonarr and library.sonarr_add_all_existing and tvdb_id: path = path.replace(library.Sonarr.plex_path, library.Sonarr.sonarr_path) path = path[:-1] if path.endswith(('/', '\\')) else path sonarr_adds.append((tvdb_id, path)) @@ -545,13 +530,13 @@ def library_operations(config, library): except Failed: pass - if library.Radarr and library.radarr_add_all: + if library.Radarr and library.radarr_add_all_existing: try: library.Radarr.add_tmdb(radarr_adds) except Failed as e: logger.error(e) - if library.Sonarr and library.sonarr_add_all: + if library.Sonarr and library.sonarr_add_all_existing: try: library.Sonarr.add_tvdb(sonarr_adds) except Failed as e: