Skip to content

Commit ccecf7d

Browse files
committed
[Bug] Fix rename folders if no files to rename
1 parent 6218687 commit ccecf7d

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

modules/renameinatorr.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,11 @@ def process_instance(app, rename_folders, server_name, instance_type, count, tag
222222
tag_id = app.get_tag_id_from_name(tag_name)
223223
if tag_id:
224224
media_tmp = [item for item in media_dict if tag_id not in item['tags']][:count]
225-
225+
226226
# If all media is tagged, remove tags and fetch new data
227227
if not media_tmp:
228228
media_ids = [item['media_id'] for item in media_dict]
229+
print(f"Media IDs: {media_ids}")
229230
logger.info("All media is tagged. Removing tags...")
230231
app.remove_tags(media_ids, tag_id)
231232
media_dict = handle_starr_data(app, server_name, instance_type, include_episode=False)
@@ -241,14 +242,10 @@ def process_instance(app, rename_folders, server_name, instance_type, count, tag
241242
print("Processing data... This may take a while.")
242243
for item in tqdm(media_dict, desc=f"Processing '{server_name}' Media", unit="items", disable=None, leave=True):
243244
file_info = {}
244-
can_rename = False
245245
# Fetch rename list and sort it by existingPath
246246
rename_response = app.get_rename_list(item['media_id'])
247247
rename_response.sort(key=lambda x: x['existingPath'])
248-
249-
if rename_response:
250-
can_rename = True
251-
248+
252249
# Process each item in the rename list to get file rename information
253250
for items in rename_response:
254251
existing_path = items.get('existingPath', None)
@@ -265,15 +262,12 @@ def process_instance(app, rename_folders, server_name, instance_type, count, tag
265262
# Update item with file rename information
266263
item["new_path_name"] = None
267264
item["file_info"] = file_info
268-
item["can_rename"] = can_rename
269265

270266
# If not in dry run, perform file renaming
271267
if not dry_run:
272268
# Get media IDs and initiate file renaming
273269
media_ids = []
274-
for item in media_dict:
275-
if item["can_rename"]:
276-
media_ids.append(item['media_id'])
270+
media_ids = [item['media_id'] for item in media_dict]
277271

278272
if media_ids:
279273
# Rename files and wait for media refresh

0 commit comments

Comments
 (0)