From f889eaf274bba87ccbebecfb69ba6930c07a0f25 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Thu, 30 Dec 2021 12:13:01 -0500 Subject: [PATCH] change arr attribute names --- config/config.yml.template | 6 +++-- modules/builder.py | 37 +++++++++++++++--------------- modules/config.py | 47 ++++++++++++++++++++++++++++---------- modules/radarr.py | 2 +- modules/sonarr.py | 2 +- 5 files changed, 60 insertions(+), 34 deletions(-) diff --git a/config/config.yml.template b/config/config.yml.template index 290fe139..0fda29fd 100644 --- a/config/config.yml.template +++ b/config/config.yml.template @@ -70,7 +70,8 @@ anidb: # Not required for AniDB builder radarr: # Can be individually specified per library as well url: http://192.168.1.12:7878 token: ################################ - add: false + add_missing: false + add_existing: false root_folder_path: S:/Movies monitor: true availability: announced @@ -82,7 +83,8 @@ radarr: # Can be individually specified sonarr: # Can be individually specified per library as well url: http://192.168.1.12:8989 token: ################################ - add: false + add_missing: false + add_existing: false root_folder_path: "S:/TV Shows" monitor: all quality_profile: HD-1080p diff --git a/modules/builder.py b/modules/builder.py index a148cbe1..a804abd7 100644 --- a/modules/builder.py +++ b/modules/builder.py @@ -45,7 +45,8 @@ method_alias = { "anilist_tag": "anilist_search", "anilist_genre": "anilist_search", "anilist_season": "anilist_search", "mal_producer": "mal_studio", "mal_licensor": "mal_studio", "trakt_recommended": "trakt_recommended_weekly", "trakt_watched": "trakt_watched_weekly", "trakt_collected": "trakt_collected_weekly", - "collection_changes_webhooks": "changes_webhooks" + "collection_changes_webhooks": "changes_webhooks", + "radarr_add": "radarr_add_missing", "sonarr_add": "sonarr_add_missing", } filter_translation = { "record_label": "studio", @@ -101,9 +102,9 @@ collectionless_details = ["collection_order", "plex_collectionless", "label", "l item_bool_details = ["item_tmdb_season_titles", "item_assets", "revert_overlay", "item_lock_background", "item_lock_poster", "item_lock_title", "item_refresh"] item_details = ["item_label", "item_radarr_tag", "item_sonarr_tag", "item_overlay"] + item_bool_details + list(plex.item_advance_keys.keys()) none_details = ["label.sync", "item_label.sync"] -radarr_details = ["radarr_add", "radarr_add_existing", "radarr_folder", "radarr_monitor", "radarr_search", "radarr_availability", "radarr_quality", "radarr_tag"] +radarr_details = ["radarr_add_missing", "radarr_add_existing", "radarr_folder", "radarr_monitor", "radarr_search", "radarr_availability", "radarr_quality", "radarr_tag"] sonarr_details = [ - "sonarr_add", "sonarr_add_existing", "sonarr_folder", "sonarr_monitor", "sonarr_language", "sonarr_series", + "sonarr_add_missing", "sonarr_add_existing", "sonarr_folder", "sonarr_monitor", "sonarr_language", "sonarr_series", "sonarr_quality", "sonarr_season", "sonarr_search", "sonarr_cutoff_search", "sonarr_tag" ] album_details = ["item_label", "item_album_sorting"] @@ -573,20 +574,20 @@ class CollectionBuilder: if not self.smart_url and len(self.builders) == 0: raise Failed(f"{self.Type} Error: No builders were found") - if "add" not in self.radarr_details: - self.radarr_details["add"] = self.library.Radarr.add if self.library.Radarr else False + if "add_missing" not in self.radarr_details: + self.radarr_details["add_missing"] = self.library.Radarr.add_missing if self.library.Radarr else False if "add_existing" not in self.radarr_details: self.radarr_details["add_existing"] = self.library.Radarr.add_existing if self.library.Radarr else False - if "add" not in self.sonarr_details: - self.sonarr_details["add"] = self.library.Sonarr.add if self.library.Sonarr else False + if "add_missing" not in self.sonarr_details: + self.sonarr_details["add_missing"] = self.library.Sonarr.add_missing if self.library.Sonarr else False if "add_existing" not in self.sonarr_details: self.sonarr_details["add_existing"] = self.library.Sonarr.add_existing if self.library.Sonarr else False if self.smart_url or self.collectionless or self.library.is_music: - self.radarr_details["add"] = False + self.radarr_details["add_missing"] = False self.radarr_details["add_existing"] = False - self.sonarr_details["add"] = False + self.sonarr_details["add_missing"] = False self.sonarr_details["add_existing"] = False if self.radarr_details["add_existing"] or self.sonarr_details["add_existing"]: @@ -597,8 +598,8 @@ class CollectionBuilder: self.sync = True self.do_missing = not self.no_missing and (self.details["show_missing"] or self.details["save_missing"] - or (self.library.Radarr and self.radarr_details["add"]) - or (self.library.Sonarr and self.sonarr_details["add"])) + or (self.library.Radarr and self.radarr_details["add_missing"]) + or (self.library.Sonarr and self.sonarr_details["add_missing"])) if self.build_collection: try: @@ -827,7 +828,7 @@ class CollectionBuilder: self.item_details[method_name] = str(method_data).lower() def _radarr(self, method_name, method_data): - if method_name in ["radarr_add", "radarr_add_existing", "radarr_monitor", "radarr_search"]: + if method_name in ["radarr_add_missing", "radarr_add_existing", "radarr_monitor", "radarr_search"]: self.radarr_details[method_name[7:]] = self._parse(method_name, method_data, datatype="bool") elif method_name == "radarr_folder": self.radarr_details["folder"] = method_data @@ -842,7 +843,7 @@ class CollectionBuilder: self.radarr_details["tag"] = util.get_list(method_data, lower=True) def _sonarr(self, method_name, method_data): - if method_name in ["sonarr_add", "sonarr_add_existing", "sonarr_season", "sonarr_search", "sonarr_cutoff_search"]: + if method_name in ["sonarr_add_missing", "sonarr_add_existing", "sonarr_season", "sonarr_search", "sonarr_cutoff_search"]: self.sonarr_details[method_name[7:]] = self._parse(method_name, method_data, datatype="bool") elif method_name in ["sonarr_folder", "sonarr_quality", "sonarr_language"]: self.sonarr_details[method_name[7:]] = method_data @@ -1630,7 +1631,7 @@ class CollectionBuilder: modifier = modifier_alias[modifier] if modifier in modifier_alias else modifier if attribute == "add_to_arr": - attribute = "radarr_add" if self.library.is_movie else "sonarr_add" + attribute = "radarr_add_missing" if self.library.is_movie else "sonarr_add_missing" elif attribute in ["arr_tag", "arr_folder"]: attribute = f"{'rad' if self.library.is_movie else 'son'}{attribute}" elif attribute in plex.date_attributes and modifier in [".gt", ".gte"]: @@ -1905,10 +1906,10 @@ class CollectionBuilder: if len(missing_movies_with_names) > 0: if self.details["save_missing"] is True: self.library.add_missing(self.name, missing_movies_with_names, True) - if self.run_again or (self.library.Radarr and (self.radarr_details["add"] or "item_radarr_tag" in self.item_details)): + if self.run_again or (self.library.Radarr and (self.radarr_details["add_missing"] or "item_radarr_tag" in self.item_details)): missing_tmdb_ids = [missing_id for title, missing_id in missing_movies_with_names] if self.library.Radarr: - if self.radarr_details["add"]: + if self.radarr_details["add_missing"]: try: added_to_radarr += self.library.Radarr.add_tmdb(missing_tmdb_ids, **self.radarr_details) except Failed as e: @@ -1944,10 +1945,10 @@ class CollectionBuilder: if len(missing_shows_with_names) > 0: if self.details["save_missing"] is True: self.library.add_missing(self.name, missing_shows_with_names, False) - if self.run_again or (self.library.Sonarr and (self.sonarr_details["add"] or "item_sonarr_tag" in self.item_details)): + if self.run_again or (self.library.Sonarr and (self.sonarr_details["add_missing"] or "item_sonarr_tag" in self.item_details)): missing_tvdb_ids = [missing_id for title, missing_id in missing_shows_with_names] if self.library.Sonarr: - if self.sonarr_details["add"]: + if self.sonarr_details["add_missing"]: try: added_to_sonarr += self.library.Sonarr.add_tvdb(missing_tvdb_ids, **self.sonarr_details) except Failed as e: diff --git a/modules/config.py b/modules/config.py index 35b5d351..b9f860ab 100644 --- a/modules/config.py +++ b/modules/config.py @@ -79,6 +79,10 @@ class ConfigFile: replace_attr(new_config, "save_missing", "plex") if new_config["libraries"]: for library in new_config["libraries"]: + 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]: replace_attr(new_config["libraries"][library], "asset_directory", "plex") replace_attr(new_config["libraries"][library], "sync_mode", "plex") @@ -89,6 +93,17 @@ class ConfigFile: if new_config["libraries"][library] and "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 "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 "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 "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"]: changes = [] def hooks(attr): @@ -127,8 +142,16 @@ class ConfigFile: if "omdb" in new_config: new_config["omdb"] = new_config.pop("omdb") if "notifiarr" in new_config: new_config["notifiarr"] = new_config.pop("notifiarr") if "anidb" in new_config: new_config["anidb"] = new_config.pop("anidb") - if "radarr" in new_config: new_config["radarr"] = new_config.pop("radarr") - if "sonarr" in new_config: new_config["sonarr"] = new_config.pop("sonarr") + if "radarr" in new_config: + temp = new_config.pop("radarr") + if "add" in temp: + temp["add_missing"] = temp.pop("add") + new_config["radarr"] = temp + if "sonarr" in new_config: + temp = new_config.pop("sonarr") + if "add" in temp: + temp["add_missing"] = temp.pop("add") + new_config["sonarr"] = temp if "trakt" in new_config: new_config["trakt"] = new_config.pop("trakt") if "mal" in new_config: new_config["mal"] = new_config.pop("mal") if not self.read_only: @@ -460,7 +483,7 @@ class ConfigFile: self.general["radarr"] = { "url": check_for_attribute(self.data, "url", parent="radarr", var_type="url", default_is_none=True), "token": check_for_attribute(self.data, "token", parent="radarr", default_is_none=True), - "add": check_for_attribute(self.data, "add", parent="radarr", var_type="bool", default=False), + "add_missing": check_for_attribute(self.data, "add_missing", parent="radarr", var_type="bool", default=False), "add_existing": check_for_attribute(self.data, "add_existing", parent="radarr", var_type="bool", default=False), "root_folder_path": check_for_attribute(self.data, "root_folder_path", parent="radarr", default_is_none=True), "monitor": check_for_attribute(self.data, "monitor", parent="radarr", var_type="bool", default=True), @@ -474,7 +497,7 @@ class ConfigFile: self.general["sonarr"] = { "url": check_for_attribute(self.data, "url", parent="sonarr", var_type="url", default_is_none=True), "token": check_for_attribute(self.data, "token", parent="sonarr", default_is_none=True), - "add": check_for_attribute(self.data, "add", parent="sonarr", var_type="bool", default=False), + "add_missing": check_for_attribute(self.data, "add_missing", parent="sonarr", var_type="bool", default=False), "add_existing": check_for_attribute(self.data, "add_existing", parent="sonarr", var_type="bool", default=False), "root_folder_path": check_for_attribute(self.data, "root_folder_path", parent="sonarr", default_is_none=True), "monitor": check_for_attribute(self.data, "monitor", parent="sonarr", test_list=sonarr.monitor_descriptions, default="all"), @@ -552,8 +575,8 @@ class ConfigFile: params["mass_critic_rating_update"] = check_for_attribute(lib, "mass_critic_rating_update", test_list=mass_update_options, default_is_none=True, save=False, do_print=False) params["mass_trakt_rating_update"] = check_for_attribute(lib, "mass_trakt_rating_update", var_type="bool", default=False, save=False, do_print=False) params["split_duplicates"] = check_for_attribute(lib, "split_duplicates", var_type="bool", default=False, save=False, do_print=False) - params["radarr_add_all"] = check_for_attribute(lib, "radarr_add_all", var_type="bool", default=False, save=False, do_print=False) - params["sonarr_add_all"] = check_for_attribute(lib, "sonarr_add_all", var_type="bool", default=False, save=False, do_print=False) + params["radarr_add_all_existing"] = check_for_attribute(lib, "radarr_add_all_existing", var_type="bool", default=False, save=False, do_print=False) + params["sonarr_add_all_existing"] = check_for_attribute(lib, "sonarr_add_all_existing", var_type="bool", default=False, save=False, do_print=False) if lib and "operations" in lib and lib["operations"]: if isinstance(lib["operations"], dict): @@ -573,12 +596,12 @@ class ConfigFile: params["mass_trakt_rating_update"] = check_for_attribute(lib["operations"], "mass_trakt_rating_update", var_type="bool", default=False, save=False) if "split_duplicates" in lib["operations"]: params["split_duplicates"] = check_for_attribute(lib["operations"], "split_duplicates", var_type="bool", default=False, save=False) - if "radarr_add_all" in lib["operations"]: - params["radarr_add_all"] = check_for_attribute(lib["operations"], "radarr_add_all", var_type="bool", default=False, save=False) + if "radarr_add_all_existing" in lib["operations"]: + params["radarr_add_all_existing"] = check_for_attribute(lib["operations"], "radarr_add_all_existing", var_type="bool", default=False, save=False) if "radarr_remove_by_tag" in lib["operations"]: params["radarr_remove_by_tag"] = check_for_attribute(lib["operations"], "radarr_remove_by_tag", var_type="comma_list", default=False, save=False) - 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 "sonarr_add_all_existing" in lib["operations"]: + params["sonarr_add_all_existing"] = check_for_attribute(lib["operations"], "sonarr_add_all_existing", var_type="bool", default=False, save=False) 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 "mass_collection_mode" in lib["operations"]: @@ -700,7 +723,7 @@ class ConfigFile: library.Radarr = Radarr(self, library, { "url": check_for_attribute(lib, "url", parent="radarr", var_type="url", default=self.general["radarr"]["url"], req_default=True, save=False), "token": check_for_attribute(lib, "token", parent="radarr", default=self.general["radarr"]["token"], req_default=True, save=False), - "add": check_for_attribute(lib, "add", parent="radarr", var_type="bool", default=self.general["radarr"]["add"], save=False), + "add_missing": check_for_attribute(lib, "add_missing", parent="radarr", var_type="bool", default=self.general["radarr"]["add_missing"], save=False), "add_existing": check_for_attribute(lib, "add_existing", parent="radarr", var_type="bool", default=self.general["radarr"]["add_existing"], save=False), "root_folder_path": check_for_attribute(lib, "root_folder_path", parent="radarr", default=self.general["radarr"]["root_folder_path"], req_default=True, save=False), "monitor": check_for_attribute(lib, "monitor", parent="radarr", var_type="bool", default=self.general["radarr"]["monitor"], save=False), @@ -728,7 +751,7 @@ class ConfigFile: library.Sonarr = Sonarr(self, library, { "url": check_for_attribute(lib, "url", parent="sonarr", var_type="url", default=self.general["sonarr"]["url"], req_default=True, save=False), "token": check_for_attribute(lib, "token", parent="sonarr", default=self.general["sonarr"]["token"], req_default=True, save=False), - "add": check_for_attribute(lib, "add", parent="sonarr", var_type="bool", default=self.general["sonarr"]["add"], save=False), + "add_missing": check_for_attribute(lib, "add_missing", parent="sonarr", var_type="bool", default=self.general["sonarr"]["add_missing"], save=False), "add_existing": check_for_attribute(lib, "add_existing", parent="sonarr", var_type="bool", default=self.general["sonarr"]["add_existing"], save=False), "root_folder_path": check_for_attribute(lib, "root_folder_path", parent="sonarr", default=self.general["sonarr"]["root_folder_path"], req_default=True, save=False), "monitor": check_for_attribute(lib, "monitor", parent="sonarr", test_list=sonarr.monitor_descriptions, default=self.general["sonarr"]["monitor"], save=False), diff --git a/modules/radarr.py b/modules/radarr.py index 950d48ec..b026f424 100644 --- a/modules/radarr.py +++ b/modules/radarr.py @@ -22,7 +22,7 @@ class Radarr: self.api._validate_add_options(params["root_folder_path"], params["quality_profile"]) except ArrException as e: raise Failed(e) - self.add = params["add"] + self.add_missing = params["add_missing"] self.add_existing = params["add_existing"] self.root_folder_path = params["root_folder_path"] self.monitor = params["monitor"] diff --git a/modules/sonarr.py b/modules/sonarr.py index e3d47e99..2e8e1c75 100644 --- a/modules/sonarr.py +++ b/modules/sonarr.py @@ -40,7 +40,7 @@ class Sonarr: self.api._validate_add_options(params["root_folder_path"], params["quality_profile"], params["language_profile"]) except ArrException as e: raise Failed(e) - self.add = params["add"] + self.add_missing = params["add_missing"] self.add_existing = params["add_existing"] self.root_folder_path = params["root_folder_path"] self.monitor = params["monitor"]