[27] update smart collection counts

This commit is contained in:
meisnate12 2022-11-19 15:17:43 -05:00
parent 197b1c476c
commit 1128edcafe
4 changed files with 18 additions and 18 deletions

View file

@ -1 +1 @@
1.18.0-develop26
1.18.0-develop27

View file

@ -423,6 +423,7 @@ class CollectionBuilder:
self.ignore_blank_results = util.parse(self.Type, "ignore_blank_results", self.data, datatype="bool", methods=methods, default=True)
self.smart_filter_details = ""
self.smart_label_url = None
self.smart_label = {"sort_by": "random", "all": {"label": [self.name]}}
self.smart_label_collection = False
if "smart_label" in methods and not self.playlist and not self.overlay and not self.library.is_music:
@ -445,7 +446,7 @@ class CollectionBuilder:
logger.warning(f"{self.Type} Error: smart_label attribute: {self.data[methods['smart_label']]} is invalid defaulting to random")
if self.smart_label_collection and self.library.smart_label_check(self.name):
try:
_, self.smart_filter_details, _ = self.build_filter("smart_label", self.smart_label, default_sort="random")
_, self.smart_filter_details, self.smart_label_url = self.build_filter("smart_label", self.smart_label, default_sort="random")
except FilterFailed as e:
if self.ignore_blank_results:
raise
@ -649,7 +650,7 @@ class CollectionBuilder:
if isinstance(self.custom_sort, list) and not self.custom_sort:
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")
if self.smart_url or self.smart_label_collection:
if self.smart:
self.custom_sort = False
for method_key, method_data in self.data.items():
@ -810,14 +811,18 @@ class CollectionBuilder:
self.obj = None
except Failed:
self.obj = None
if self.smart:
check_url = self.smart_url if self.smart_url else self.smart_label_url
if self.obj and check_url != self.library.smart_filter(self.obj):
self.library.update_smart_collection(self.obj, check_url)
logger.info(f"Detail: Smart Collection updated to {check_url}")
self.beginning_count = len(self.library.get_filter_items(check_url))
if self.obj:
self.exists = True
if self.sync or self.playlist:
self.remove_item_map = {i.ratingKey: i for i in self.library.get_collection_items(self.obj, self.smart_label_collection)}
self.beginning_count = len(self.remove_item_map) if self.playlist else self.obj.childCount
elif self.smart_label_collection:
self.beginning_count = len(self.library.search(label=self.name))
if not self.smart:
self.beginning_count = len(self.remove_item_map) if self.playlist else self.obj.childCount
else:
self.obj = None
self.sync = False
@ -2553,10 +2558,6 @@ class CollectionBuilder:
logger.info("")
logger.separator(f"Updating Details of {self.name} {self.Type}", space=False, border=False)
logger.info("")
if self.smart_url and self.smart_url != self.library.smart_filter(self.obj):
self.library.update_smart_collection(self.obj, self.smart_url)
logger.info(f"Detail: Smart Filter updated to {self.smart_url}")
updated_details.append("Smart Filter")
if "summary" in self.summaries: summary = ("summary", self.summaries["summary"])
elif "tmdb_description" in self.summaries: summary = ("tmdb_description", self.summaries["tmdb_description"])
elif "letterboxd_description" in self.summaries: summary = ("letterboxd_description", self.summaries["letterboxd_description"])

View file

@ -226,7 +226,7 @@ class MyLogger:
self.spacing = 0
def secret(self, text):
if str(text) not in self.secrets:
if text and str(text) not in self.secrets:
self.secrets.append(str(text))
def _log(self, level, msg, args, exc_info=None, extra=None, stack_info=False, stacklevel=1):

View file

@ -183,12 +183,12 @@ def start(attrs):
logger.info_center(" |___/ ")
system_ver = "Docker" if is_docker else f"Python {platform.python_version()}"
logger.info(f" Version: {version[0]} ({system_ver})")
logger.info(f" Platform: {platform.platform()}")
logger.info(f" Memory: {round(psutil.virtual_memory().total / (1024.0 ** 3))} GB")
latest_version = util.current_version(version)
new_version = latest_version[0] if latest_version and (version[1] != latest_version[1] or (version[2] and version[2] < latest_version[2])) else None
if new_version:
logger.info(f" Newest Version: {new_version}")
logger.info(f" Platform: {platform.platform()}")
logger.info(f" Memory: {round(psutil.virtual_memory().total / (1024.0 ** 3))} GB")
if "time" in attrs and attrs["time"]: start_type = f"{attrs['time']} "
elif "test" in attrs and attrs["test"]: start_type = "Test "
elif "collections" in attrs and attrs["collections"]: start_type = "Collections "
@ -604,6 +604,8 @@ def run_collection(config, library, metadata, requested_collections):
if len(builder.smart_filter_details) > 0:
logger.info("")
logger.info(builder.smart_filter_details)
logger.info("")
logger.info(f"Items Found: {builder.beginning_count}")
items_added = 0
items_removed = 0
@ -648,10 +650,7 @@ def run_collection(config, library, metadata, requested_collections):
library.status[str(mapping_name)]["sonarr"] += sonarr_add
valid = True
if builder.build_collection and not builder.blank_collection and (
(not builder.smart_url and items_added + builder.beginning_count < builder.minimum)
or (builder.smart_url and len(library.get_filter_items(builder.smart_url)) < builder.minimum)
):
if builder.build_collection and not builder.blank_collection and items_added + builder.beginning_count < builder.minimum:
logger.info("")
logger.info(f"{builder.Type} Minimum: {builder.minimum} not met for {mapping_name} Collection")
delete_status = f"Minimum {builder.minimum} Not Met"