From d9770c2e67796b99d0a2034efd5c7ba9c0eca9f8 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Wed, 22 Dec 2021 11:19:23 -0500 Subject: [PATCH] small fixes --- config/config.yml.template | 3 +++ modules/config.py | 34 ++++++++++++++++++++-------------- modules/library.py | 4 ++-- modules/meta.py | 2 +- plex_meta_manager.py | 4 +++- 5 files changed, 29 insertions(+), 18 deletions(-) diff --git a/config/config.yml.template b/config/config.yml.template index c5b96e31..31ed0f61 100644 --- a/config/config.yml.template +++ b/config/config.yml.template @@ -18,7 +18,9 @@ settings: # Can be individually specified cache_expiration: 60 asset_directory: config/assets asset_folders: true + asset_depth: 0 create_asset_folders: false + dimensional_asset_rename: false show_missing_season_assets: false sync_mode: append collection_minimum: 1 @@ -29,6 +31,7 @@ settings: # Can be individually specified only_filter_missing: false show_unmanaged: true show_filtered: false + show_options: false show_missing: true show_missing_assets: true save_missing: true diff --git a/modules/config.py b/modules/config.py index dbd909a9..5dd42e1b 100644 --- a/modules/config.py +++ b/modules/config.py @@ -11,6 +11,7 @@ from modules.icheckmovies import ICheckMovies from modules.imdb import IMDb from modules.letterboxd import Letterboxd from modules.mal import MyAnimeList +from modules.meta import PlaylistFile from modules.notifiarr import Notifiarr from modules.omdb import OMDb from modules.plex import Plex @@ -367,18 +368,18 @@ class ConfigFile: self.playlist_names = [] self.playlist_files = [] - if "playlists" in self.data: + playlists_pairs = [] + if "playlist_files" in self.data: logger.info("Reading in Playlist Files") - if self.data["playlists"] is None: - raise Failed("Config Error: playlists attribute is blank") - playlists_pairs = [] - paths_to_check = self.data["playlists"] if isinstance(self.data["playlists"], list) else [self.data["playlists"]] + if self.data["playlist_files"] is None: + raise Failed("Config Error: playlist_files attribute is blank") + paths_to_check = self.data["playlist_files"] if isinstance(self.data["playlist_files"], list) else [self.data["playlist_files"]] for path in paths_to_check: if isinstance(path, dict): def check_dict(attr): if attr in path: if path[attr] is None: - err = f"Config Error: playlists {attr} is blank" + err = f"Config Error: playlist_files {attr} is blank" self.errors.append(err) logger.error(err) else: @@ -405,15 +406,20 @@ class ConfigFile: logger.error(f"Config Error: Folder not found: {folder}") else: playlists_pairs.append(("File", path)) - for file_type, playlist_file in playlists_pairs: - try: - playlist_obj = PlaylistFile(self, file_type, playlist_file) - self.playlist_names.extend([p for p in playlist_obj.playlists]) - self.playlist_files.append(playlist_obj) - except Failed as e: - util.print_multiline(e, error=True) else: - logger.warning("playlists attribute not found") + default_playlist_file = os.path.abspath(os.path.join(self.default_dir, "playlists.yml")) + if os.path.exists(default_playlist_file): + playlists_pairs.append(("File", default_playlist_file)) + logger.warning(f"playlist_files attribute not found using {default_playlist_file} as default") + else: + logger.warning("playlist_files attribute not found") + for file_type, playlist_file in playlists_pairs: + try: + playlist_obj = PlaylistFile(self, file_type, playlist_file) + self.playlist_names.extend([p for p in playlist_obj.playlists]) + self.playlist_files.append(playlist_obj) + except Failed as e: + util.print_multiline(e, error=True) self.TVDb = TVDb(self, self.general["tvdb_language"]) self.IMDb = IMDb(self) diff --git a/modules/library.py b/modules/library.py index 786cb4c5..c5b172d3 100644 --- a/modules/library.py +++ b/modules/library.py @@ -107,9 +107,9 @@ class Library(ABC): except Failed as e: util.print_multiline(e, error=True) - if len(self.metadata_files) == 0 and not self.library_operation: + if len(self.metadata_files) == 0 and not self.library_operation and not self.config.playlist_files: logger.info("") - raise Failed("Config Error: No valid metadata files or library operations found") + raise Failed("Config Error: No valid metadata files, playlist files, or library operations found") if self.asset_directory: logger.info("") diff --git a/modules/meta.py b/modules/meta.py index 57721dfe..a3b60901 100644 --- a/modules/meta.py +++ b/modules/meta.py @@ -56,7 +56,7 @@ class DataFile: elif os.path.exists(os.path.abspath(self.path)): content = open(self.path, encoding="utf-8") else: - raise Failed(f"File Error: File does not exist {self.path}") + raise Failed(f"File Error: File does not exist {os.path.abspath(self.path)}") data, _, _ = yaml.util.load_yaml_guess_indent(content) return data except yaml.scanner.ScannerError as ye: diff --git a/plex_meta_manager.py b/plex_meta_manager.py index 5b8f9a83..ed3bc92a 100644 --- a/plex_meta_manager.py +++ b/plex_meta_manager.py @@ -977,6 +977,7 @@ def run_collection(config, library, metadata, requested_collections): items_added = 0 items_removed = 0 + valid = True if not builder.smart_url and builder.builders: logger.info("") logger.info(f"Sync Mode: {'sync' if builder.sync else 'append'}") @@ -1003,6 +1004,7 @@ def run_collection(config, library, metadata, requested_collections): elif len(builder.added_items) < builder.minimum and builder.build_collection: logger.info("") logger.info(f"Collection Minimum: {builder.minimum} not met for {mapping_name} Collection") + valid = False if builder.details["delete_below_minimum"] and builder.obj: builder.delete_collection() builder.deleted = True @@ -1019,7 +1021,7 @@ def run_collection(config, library, metadata, requested_collections): stats["sonarr"] += sonarr_add run_item_details = True - if builder.build_collection and (builder.builders or builder.smart_url): + if valid and builder.build_collection and (builder.builders or builder.smart_url): try: builder.load_collection() if builder.created: