From bb9979c1ae9a738c7b7bb4835e962e7870c194a2 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Fri, 16 Apr 2021 14:27:39 -0400 Subject: [PATCH] library_type no longer needed --- config/config.yml.template | 5 +---- modules/config.py | 24 ++++++++++++++---------- modules/plex.py | 7 ++++--- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/config/config.yml.template b/config/config.yml.template index f9bb7211..acd21927 100644 --- a/config/config.yml.template +++ b/config/config.yml.template @@ -1,12 +1,9 @@ ## This file is a template remove the .template to use the file -libraries: +libraries: # Library Names must have a colon (:) placed after them Movies: - library_type: movie TV Shows: - library_type: show Anime: - library_type: show settings: # Can be individually specified per library as well cache: true cache_expiration: 60 diff --git a/modules/config.py b/modules/config.py index 605cacfc..fb3d158a 100644 --- a/modules/config.py +++ b/modules/config.py @@ -85,7 +85,7 @@ class Config: replace_attr(new_config, "save_missing", "plex") if new_config["libraries"]: for library in new_config["libraries"]: - if "plex" in new_config["libraries"][library]: + 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") replace_attr(new_config["libraries"][library], "show_unmanaged", "plex") @@ -113,7 +113,7 @@ class Config: def check_for_attribute(data, attribute, parent=None, test_list=None, default=None, do_print=True, default_is_none=False, req_default=False, var_type="str", throw=False, save=True): endline = "" if parent is not None: - if parent in data: + if data and parent in data: data = data[parent] else: data = None @@ -312,7 +312,8 @@ class Config: for library_name, lib in libs.items(): util.separator() params = {} - if "library_name" in lib and lib["library_name"]: + logger.info("") + if lib and "library_name" in lib and lib["library_name"]: params["name"] = str(lib["library_name"]) logger.info(f"Connecting to {params['name']} ({library_name}) Library...") else: @@ -323,32 +324,32 @@ class Config: if params["asset_directory"] is None: logger.warning("Config Warning: Assets will not be used asset_directory attribute must be set under config or under this specific Library") - if "settings" in lib and lib["settings"] and "sync_mode" in lib["settings"]: + if lib and "settings" in lib and lib["settings"] and "sync_mode" in lib["settings"]: params["sync_mode"] = check_for_attribute(lib, "sync_mode", parent="settings", test_list=sync_modes, default=self.general["sync_mode"], do_print=False, save=False) else: params["sync_mode"] = check_for_attribute(lib, "sync_mode", test_list=sync_modes, default=self.general["sync_mode"], do_print=False, save=False) - if "settings" in lib and lib["settings"] and "show_unmanaged" in lib["settings"]: + if lib and "settings" in lib and lib["settings"] and "show_unmanaged" in lib["settings"]: params["show_unmanaged"] = check_for_attribute(lib, "show_unmanaged", parent="settings", var_type="bool", default=self.general["show_unmanaged"], do_print=False, save=False) else: params["show_unmanaged"] = check_for_attribute(lib, "show_unmanaged", var_type="bool", default=self.general["show_unmanaged"], do_print=False, save=False) - if "settings" in lib and lib["settings"] and "show_filtered" in lib["settings"]: + if lib and "settings" in lib and lib["settings"] and "show_filtered" in lib["settings"]: params["show_filtered"] = check_for_attribute(lib, "show_filtered", parent="settings", var_type="bool", default=self.general["show_filtered"], do_print=False, save=False) else: params["show_filtered"] = check_for_attribute(lib, "show_filtered", var_type="bool", default=self.general["show_filtered"], do_print=False, save=False) - if "settings" in lib and lib["settings"] and "show_missing" in lib["settings"]: + if lib and "settings" in lib and lib["settings"] and "show_missing" in lib["settings"]: params["show_missing"] = check_for_attribute(lib, "show_missing", parent="settings", var_type="bool", default=self.general["show_missing"], do_print=False, save=False) else: params["show_missing"] = check_for_attribute(lib, "show_missing", var_type="bool", default=self.general["show_missing"], do_print=False, save=False) - if "settings" in lib and lib["settings"] and "save_missing" in lib["settings"]: + if lib and "settings" in lib and lib["settings"] and "save_missing" in lib["settings"]: params["save_missing"] = check_for_attribute(lib, "save_missing", parent="settings", var_type="bool", default=self.general["save_missing"], do_print=False, save=False) else: params["save_missing"] = check_for_attribute(lib, "save_missing", var_type="bool", default=self.general["save_missing"], do_print=False, save=False) - if "mass_genre_update" in lib and lib["mass_genre_update"]: + if lib and "mass_genre_update" in lib and lib["mass_genre_update"]: params["mass_genre_update"] = check_for_attribute(lib, "mass_genre_update", test_list=mass_genre_update_options, default_is_none=True, save=False) else: params["mass_genre_update"] = None @@ -359,7 +360,6 @@ class Config: try: params["metadata_path"] = check_for_attribute(lib, "metadata_path", var_type="path", default=os.path.join(default_dir, f"{library_name}.yml"), throw=True) - params["library_type"] = check_for_attribute(lib, "library_type", test_list=library_types, throw=True) params["plex"] = {} params["plex"]["url"] = check_for_attribute(lib, "url", parent="plex", default=self.general["plex"]["url"], req_default=True, save=False) params["plex"]["token"] = check_for_attribute(lib, "token", parent="plex", default=self.general["plex"]["token"], req_default=True, save=False) @@ -372,6 +372,7 @@ class Config: continue if self.general["radarr"]["url"] or "radarr" in lib: + logger.info("") logger.info(f"Connecting to {params['name']} library's Radarr...") radarr_params = {} try: @@ -391,6 +392,7 @@ class Config: logger.info(f"{params['name']} library's Radarr Connection {'Failed' if library.Radarr is None else 'Successful'}") if self.general["sonarr"]["url"] or "sonarr" in lib: + logger.info("") logger.info(f"Connecting to {params['name']} library's Sonarr...") sonarr_params = {} try: @@ -416,6 +418,7 @@ class Config: logger.info(f"{params['name']} library's Sonarr Connection {'Failed' if library.Sonarr is None else 'Successful'}") if self.general["tautulli"]["url"] or "tautulli" in lib: + logger.info("") logger.info(f"Connecting to {params['name']} library's Tautulli...") tautulli_params = {} try: @@ -426,6 +429,7 @@ class Config: util.print_multiline(e, error=True) logger.info(f"{params['name']} library's Tautulli Connection {'Failed' if library.Tautulli is None else 'Successful'}") + logger.info("") self.libraries.append(library) util.separator() diff --git a/modules/plex.py b/modules/plex.py index e0c65b5f..e329df52 100644 --- a/modules/plex.py +++ b/modules/plex.py @@ -121,12 +121,13 @@ class PlexAPI: except requests.exceptions.ConnectionError: util.print_stacktrace() raise Failed("Plex Error: Plex url is invalid") - self.is_movie = params["library_type"] == "movie" - self.is_show = params["library_type"] == "show" - self.Plex = next((s for s in self.PlexServer.library.sections() if s.title == params["name"] and ((self.is_movie and isinstance(s, MovieSection)) or (self.is_show and isinstance(s, ShowSection)))), None) + self.Plex = next((s for s in self.PlexServer.library.sections() if s.title == params["name"]), None) if not self.Plex: raise Failed(f"Plex Error: Plex Library {params['name']} not found") + self.is_movie = self.Plex.type == "movie" + self.is_show = self.Plex.type == "show" + logger.info(f"Using Metadata File: {params['metadata_path']}") try: self.data, ind, bsi = yaml.util.load_yaml_guess_indent(open(params["metadata_path"], encoding="utf-8"))