New Agents will not have the collection tag locked state altered

pull/402/head
meisnate12 3 years ago
parent b049ef0e60
commit f40da259bf

@ -1484,10 +1484,8 @@ class CollectionBuilder:
logger.info(util.adjust_space(f"{name} Collection | {current_operation} | {self.item_title(current)}"))
if current in collection_items:
self.plex_map[current.ratingKey] = None
elif self.smart_label_collection:
self.library.query_data(current.addLabel, name)
else:
self.library.query_data(current.addCollection, name)
self.library.add_to_collection(current, name, smart_label_collection=self.smart_label_collection)
util.print_end()
logger.info("")
logger.info(f"{total} {self.collection_level.capitalize()}{'s' if total > 1 else ''} Processed")
@ -2028,7 +2026,7 @@ class CollectionBuilder:
if current in collection_items:
logger.info(f"{name} Collection | = | {self.item_title(current)}")
else:
self.library.query_data(current.addLabel if self.smart_label_collection else current.addCollection, name)
self.library.add_to_collection(current, name, smart_label_collection=self.smart_label_collection)
logger.info(f"{name} Collection | + | {self.item_title(current)}")
logger.info(f"{len(rating_keys)} {self.collection_level.capitalize()}{'s' if len(rating_keys) > 1 else ''} Processed")

@ -302,6 +302,10 @@ class Plex(Library):
def query_data(self, method, data):
return method(data)
@retry(stop_max_attempt_number=6, wait_fixed=10000, retry_on_exception=util.retry_if_not_failed)
def query_collection(self, item, collection, locked=True):
item.addCollection(collection, locked=locked)
@retry(stop_max_attempt_number=6, wait_fixed=10000, retry_on_exception=util.retry_if_not_plex)
def collection_mode_query(self, collection, data):
collection.modeUpdate(mode=data)
@ -380,6 +384,16 @@ class Plex(Library):
else: method = None
return self.Plex._server.query(key, method=method)
def add_to_collection(self, item, collection, smart_label_collection=False):
if smart_label_collection:
self.query_data(item.addLabel, collection)
else:
locked = True
if self.agent in ["tv.plex.agents.movie", "tv.plex.agents.series"]:
field = next((f for f in item.fields if f.name == "collection"), None)
locked = field is not None
self.query_collection(item, collection, locked=locked)
def move_item(self, collection, item, after=None):
key = f"{collection.key}/items/{item}/move"
if after:

@ -115,7 +115,7 @@ def start(config_path, is_test=False, time_scheduled=None, requested_collections
logger.info(util.centered("| __/| | __/> < | | | | __/ || (_| | | | | | (_| | | | | (_| | (_| | __/ | "))
logger.info(util.centered("|_| |_|\\___/_/\\_\\ |_| |_|\\___|\\__\\__,_| |_| |_|\\__,_|_| |_|\\__,_|\\__, |\\___|_| "))
logger.info(util.centered(" |___/ "))
logger.info(util.centered(" Version: 1.12.2 "))
logger.info(util.centered(" Version: 1.12.2-develop0930 "))
if time_scheduled: start_type = f"{time_scheduled} "
elif is_test: start_type = "Test "
elif requested_collections: start_type = "Collections "

Loading…
Cancel
Save