From 4eaca8559905fb67c8b74632ef3e276292410b3e Mon Sep 17 00:00:00 2001 From: Drazzilb <65743746+Drazzilb08@users.noreply.github.com> Date: Sat, 24 Feb 2024 10:20:23 -0800 Subject: [PATCH] Fix: Remove tag name from items if all items tagged --- modules/renameinatorr.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/renameinatorr.py b/modules/renameinatorr.py index 8a999c3..fa246d5 100755 --- a/modules/renameinatorr.py +++ b/modules/renameinatorr.py @@ -226,7 +226,19 @@ def process_instance(app, rename_folders, server_name, instance_type, count, tag if count and tag_name: tag_id = app.get_tag_id_from_name(tag_name) if tag_id: + media_tmp = [item for item in media_dict if tag_id not in item['tags']][:count] + + # If all media is tagged, remove tags and fetch new data + if not media_tmp: + media_ids = [item['media_id'] for item in media_dict] + logger.info("All media is tagged. Removing tags...") + app.remove_tags(media_ids, tag_id) + media_dict = handle_starr_data(app, server_name, instance_type) media_dict = [item for item in media_dict if tag_id not in item['tags']][:count] + else: + media_dict = media_tmp + + logger.debug(f"media dict:\n{json.dumps(media_dict, indent=4)}") # Process each item in the fetched data rename_response = []