diff --git a/config/config.yml.template b/config/config.yml.template index b4d1b994..290fe139 100644 --- a/config/config.yml.template +++ b/config/config.yml.template @@ -25,7 +25,8 @@ settings: # Can be individually specified dimensional_asset_rename: false show_missing_season_assets: false sync_mode: append - collection_minimum: 1 + minimum_items: 1 + default_collection_order: delete_below_minimum: true delete_not_scheduled: false run_again_delay: 2 @@ -45,7 +46,7 @@ webhooks: # Can be individually specified error: run_start: run_end: - collection_changes: + changes: plex: # Can be individually specified per library as well; REQUIRED for the script to run url: http://192.168.1.12:32400 token: #################### diff --git a/modules/builder.py b/modules/builder.py index c7cecae0..743b56c1 100644 --- a/modules/builder.py +++ b/modules/builder.py @@ -331,6 +331,29 @@ class CollectionBuilder: else: self.sync = self.data[methods["sync_mode"]].lower() == "sync" + test_sort = None + if "collection_order" in methods and not self.playlist: + if self.data[methods["collection_order"]] is None: + raise Failed(f"{self.Type} Warning: collection_order attribute is blank") + else: + test_sort = self.data[methods["collection_order"]] + elif "collection_order" not in methods and not self.playlist and self.library.default_collection_order: + test_sort = self.library.default_collection_order + logger.warning(f"{self.Type} Warning: collection_order not found using library default_collection_order: {self.library.default_collection_order}") + self.custom_sort = self.playlist + if test_sort: + logger.debug("") + logger.debug("Validating Method: collection_order") + logger.debug(f"Value: {test_sort}") + if test_sort.lower() in plex.collection_order_options: + self.details["collection_order"] = test_sort.lower() + if test_sort.lower() == "custom" and self.build_collection: + self.custom_sort = True + elif (self.library.is_movie and test_sort.lower() in plex.movie_sorts) or (self.library.is_show and test_sort.lower() in plex.show_sorts): + self.custom_sort = test_sort.lower() + else: + raise Failed(f"{self.Type} Error: {test_sort} collection_order invalid\n\trelease (Order Collection by release dates)\n\talpha (Order Collection Alphabetically)\n\tcustom (Custom Order Collection)\n\tOther sorting options can be found at https://github.com/meisnate12/Plex-Meta-Manager/wiki/Smart-Builders#sort-options") + self.custom_sort = self.playlist if "collection_order" in methods and not self.playlist: logger.debug("") diff --git a/modules/config.py b/modules/config.py index 7bef3e4c..35b5d351 100644 --- a/modules/config.py +++ b/modules/config.py @@ -239,6 +239,7 @@ class ConfigFile: "dimensional_asset_rename": check_for_attribute(self.data, "dimensional_asset_rename", parent="settings", var_type="bool", default=False), "show_missing_season_assets": check_for_attribute(self.data, "show_missing_season_assets", parent="settings", var_type="bool", default=False), "sync_mode": check_for_attribute(self.data, "sync_mode", parent="settings", default="append", test_list=sync_modes), + "default_collection_order": check_for_attribute(self.data, "default_collection_order", parent="settings", default_is_none=True), "minimum_items": check_for_attribute(self.data, "minimum_items", parent="settings", var_type="int", default=1), "delete_below_minimum": check_for_attribute(self.data, "delete_below_minimum", parent="settings", var_type="bool", default=False), "delete_not_scheduled": check_for_attribute(self.data, "delete_not_scheduled", parent="settings", var_type="bool", default=False), @@ -522,6 +523,7 @@ class ConfigFile: params["asset_folders"] = check_for_attribute(lib, "asset_folders", parent="settings", var_type="bool", default=self.general["asset_folders"], do_print=False, save=False) params["asset_depth"] = check_for_attribute(lib, "asset_depth", parent="settings", var_type="int", default=self.general["asset_depth"], do_print=False, save=False) 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) + params["default_collection_order"] = check_for_attribute(lib, "default_collection_order", parent="settings", default=self.general["default_collection_order"], default_is_none=True, do_print=False, save=False) params["show_unmanaged"] = check_for_attribute(lib, "show_unmanaged", parent="settings", var_type="bool", default=self.general["show_unmanaged"], do_print=False, save=False) params["show_filtered"] = check_for_attribute(lib, "show_filtered", parent="settings", var_type="bool", default=self.general["show_filtered"], do_print=False, save=False) params["show_options"] = check_for_attribute(lib, "show_options", parent="settings", var_type="bool", default=self.general["show_options"], do_print=False, save=False) diff --git a/modules/library.py b/modules/library.py index 6731a9c7..a42fc31c 100644 --- a/modules/library.py +++ b/modules/library.py @@ -46,6 +46,7 @@ class Library(ABC): self.dimensional_asset_rename = params["dimensional_asset_rename"] self.show_missing_season_assets = params["show_missing_season_assets"] self.sync_mode = params["sync_mode"] + self.default_collection_order = params["default_collection_order"] self.minimum_items = params["minimum_items"] self.delete_below_minimum = params["delete_below_minimum"] self.delete_not_scheduled = params["delete_not_scheduled"]