From 9354ab3958d3b4474e774f755b388eae34cdeb3d Mon Sep 17 00:00:00 2001 From: Petro1990 Date: Wed, 26 Nov 2025 13:02:52 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=B7=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=BA=D1=83=20=D0=BA=D0=BE?= =?UTF-8?q?=D0=BD=D1=84=D0=B8=D0=B3=D0=BE=D0=B2=20WG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mihomo_editor.py | 50 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/mihomo_editor.py b/mihomo_editor.py index 4792d5e..7a56d8e 100644 --- a/mihomo_editor.py +++ b/mihomo_editor.py @@ -250,6 +250,7 @@ def insert_proxy_logic(content, proxy_name, target_groups): if is_new_group: if in_proxies_list and current_group_name in target_groups and current_group_name not in inserted_in_group: + # End of list section prefix = " " * (proxies_list_indent + 2) new_lines.append(prefix + '- "' + proxy_name + '"') inserted_in_group.add(current_group_name) @@ -268,6 +269,26 @@ def insert_proxy_logic(content, proxy_name, target_groups): current_group_name = raw_name.strip("'").strip('"') if current_group_name in target_groups and stripped.startswith('proxies:'): + # Check for inline list style: proxies: [a, b] + if '[' in stripped and stripped.rstrip().endswith(']'): + start = line.find('[') + end = line.rfind(']') + if start != -1 and end != -1: + content_inner = line[start + 1:end] + # Check if proxy already exists in the list + # Simple check: name in text (robust enough for simple cases) + if proxy_name not in content_inner: + sep = ", " if content_inner.strip() else "" + new_content = content_inner + sep + f'"{proxy_name}"' + new_line = line[:start + 1] + new_content + line[end:] + new_lines.append(new_line) + inserted_in_group.add(current_group_name) + continue + else: + new_lines.append(line) + inserted_in_group.add(current_group_name) + continue + in_proxies_list = True proxies_list_indent = indent new_lines.append(line) @@ -303,7 +324,7 @@ HTML_TEMPLATE = """ -Mihomo Editor v18.6 +Mihomo Editor v18.7