mirror of
https://github.com/meisnate12/Plex-Meta-Manager
synced 2024-11-22 20:43:07 +00:00
#661 fixed minimum_items
This commit is contained in:
parent
65130f9333
commit
b4f1086dbc
3 changed files with 10 additions and 9 deletions
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
1.15.1-develop59
|
1.15.1-develop60
|
||||||
|
|
|
@ -288,10 +288,12 @@ class CollectionBuilder:
|
||||||
self.notification_additions = []
|
self.notification_additions = []
|
||||||
self.notification_removals = []
|
self.notification_removals = []
|
||||||
self.items = []
|
self.items = []
|
||||||
|
self.remove_item_map = {}
|
||||||
self.posters = {}
|
self.posters = {}
|
||||||
self.backgrounds = {}
|
self.backgrounds = {}
|
||||||
self.summaries = {}
|
self.summaries = {}
|
||||||
self.schedule = ""
|
self.schedule = ""
|
||||||
|
self.beginning_count = 0
|
||||||
self.minimum = self.library.minimum_items
|
self.minimum = self.library.minimum_items
|
||||||
self.ignore_ids = [i for i in self.library.ignore_ids]
|
self.ignore_ids = [i for i in self.library.ignore_ids]
|
||||||
self.ignore_imdb_ids = [i for i in self.library.ignore_imdb_ids]
|
self.ignore_imdb_ids = [i for i in self.library.ignore_imdb_ids]
|
||||||
|
@ -689,12 +691,11 @@ class CollectionBuilder:
|
||||||
except Failed:
|
except Failed:
|
||||||
self.obj = None
|
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:
|
if self.obj:
|
||||||
self.exists = True
|
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:
|
else:
|
||||||
self.obj = None
|
self.obj = None
|
||||||
self.sync = False
|
self.sync = False
|
||||||
|
@ -1780,7 +1781,7 @@ class CollectionBuilder:
|
||||||
number_text = f"{i}/{total}"
|
number_text = f"{i}/{total}"
|
||||||
logger.info(util.adjust_space(f"{number_text:>{spacing}} | {name} {self.Type} | {current_operation} | {util.item_title(item)}"))
|
logger.info(util.adjust_space(f"{number_text:>{spacing}} | {name} {self.Type} | {current_operation} | {util.item_title(item)}"))
|
||||||
if item in collection_items:
|
if item in collection_items:
|
||||||
self.plex_map[item.ratingKey] = None
|
self.remove_item_map[item.ratingKey] = None
|
||||||
amount_unchanged += 1
|
amount_unchanged += 1
|
||||||
else:
|
else:
|
||||||
if self.playlist:
|
if self.playlist:
|
||||||
|
@ -1810,7 +1811,7 @@ class CollectionBuilder:
|
||||||
def sync_collection(self):
|
def sync_collection(self):
|
||||||
amount_removed = 0
|
amount_removed = 0
|
||||||
playlist_removes = []
|
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:
|
if items:
|
||||||
logger.info("")
|
logger.info("")
|
||||||
util.separator(f"Removed from {self.name} {self.Type}", space=False, border=False)
|
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("")
|
logger.info("")
|
||||||
builder.filter_and_save_items(builder.gather_ids(method, value))
|
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()
|
items_added, items_unchanged = builder.add_to_collection()
|
||||||
library.stats["added"] += items_added
|
library.stats["added"] += items_added
|
||||||
library.status[mapping_name]["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()
|
items_removed = builder.sync_collection()
|
||||||
library.stats["removed"] += items_removed
|
library.stats["removed"] += items_removed
|
||||||
library.status[mapping_name]["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("")
|
||||||
logger.info(f"Collection Minimum: {builder.minimum} not met for {mapping_name} Collection")
|
logger.info(f"Collection Minimum: {builder.minimum} not met for {mapping_name} Collection")
|
||||||
valid = False
|
valid = False
|
||||||
|
|
Loading…
Reference in a new issue