#661 fixed minimum_items

pull/707/head
meisnate12 3 years ago
parent 65130f9333
commit b4f1086dbc

@ -1 +1 @@
1.15.1-develop59
1.15.1-develop60

@ -288,10 +288,12 @@ class CollectionBuilder:
self.notification_additions = []
self.notification_removals = []
self.items = []
self.remove_item_map = {}
self.posters = {}
self.backgrounds = {}
self.summaries = {}
self.schedule = ""
self.beginning_count = 0
self.minimum = self.library.minimum_items
self.ignore_ids = [i for i in self.library.ignore_ids]
self.ignore_imdb_ids = [i for i in self.library.ignore_imdb_ids]
@ -689,12 +691,11 @@ class CollectionBuilder:
except Failed:
self.obj = None
self.plex_map = {}
if self.sync and self.obj:
for item in self.library.get_collection_items(self.obj, self.smart_label_collection):
self.plex_map[item.ratingKey] = item
if self.obj:
self.exists = True
self.beginning_count = self.obj.childCount
if self.sync:
self.remove_item_map = {i.ratingKey: i for i in self.library.get_collection_items(self.obj, self.smart_label_collection)}
else:
self.obj = None
self.sync = False
@ -1780,7 +1781,7 @@ class CollectionBuilder:
number_text = f"{i}/{total}"
logger.info(util.adjust_space(f"{number_text:>{spacing}} | {name} {self.Type} | {current_operation} | {util.item_title(item)}"))
if item in collection_items:
self.plex_map[item.ratingKey] = None
self.remove_item_map[item.ratingKey] = None
amount_unchanged += 1
else:
if self.playlist:
@ -1810,7 +1811,7 @@ class CollectionBuilder:
def sync_collection(self):
amount_removed = 0
playlist_removes = []
items = [item for _, item in self.plex_map.items() if item is not None]
items = [item for _, item in self.remove_item_map.items() if item is not None]
if items:
logger.info("")
util.separator(f"Removed from {self.name} {self.Type}", space=False, border=False)

@ -879,7 +879,7 @@ def run_collection(config, library, metadata, requested_collections):
logger.info("")
builder.filter_and_save_items(builder.gather_ids(method, value))
if len(builder.added_items) >= builder.minimum and builder.build_collection:
if len(builder.added_items) > 0 and len(builder.added_items) + builder.beginning_count >= builder.minimum and builder.build_collection:
items_added, items_unchanged = builder.add_to_collection()
library.stats["added"] += items_added
library.status[mapping_name]["added"] = items_added
@ -890,7 +890,7 @@ def run_collection(config, library, metadata, requested_collections):
items_removed = builder.sync_collection()
library.stats["removed"] += items_removed
library.status[mapping_name]["removed"] = items_removed
elif len(builder.added_items) < builder.minimum and builder.build_collection:
elif len(builder.added_items) + builder.beginning_count < builder.minimum and builder.build_collection:
logger.info("")
logger.info(f"Collection Minimum: {builder.minimum} not met for {mapping_name} Collection")
valid = False

Loading…
Cancel
Save