From 551d7d8948fd82034c8603fa7af1f7fc9b59bd3b Mon Sep 17 00:00:00 2001 From: Manuel Weiser Date: Sat, 19 Jul 2025 20:11:35 +0200 Subject: [PATCH] =?UTF-8?q?Sortiere=20Hot=20Cues=20nach=20Start-Zeit=20und?= =?UTF-8?q?=20=C3=A4ndere=20den=20Namen=20des=20ersten=20Cues=20"1.1Bars"?= =?UTF-8?q?=20in=20"Start"=20beim=20Kopieren=20als=20Memory=20Cue.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index ef35702..4dc8df4 100644 --- a/main.py +++ b/main.py @@ -63,9 +63,13 @@ def copy_hot_cues_to_memory_cues(xml_file_path, output_file_path=None, backup=Tr if start_time: existing_memory_positions.add(start_time) - for hot_cue in hot_cues_in_track: + # Hot Cues nach Start-Zeit sortieren, um den ersten zu identifizieren + hot_cues_sorted = sorted(hot_cues_in_track, key=lambda cue: float(cue.get("Start", "0"))) + + for i, hot_cue in enumerate(hot_cues_sorted): start_time = hot_cue.get("Start") hot_cue_num = hot_cue.get("Num", "N/A") + hot_cue_name = hot_cue.get("Name", "") # Prüfen, ob bereits ein Memory Cue an dieser Position existiert if start_time and start_time in existing_memory_positions: @@ -83,6 +87,13 @@ def copy_hot_cues_to_memory_cues(xml_file_path, output_file_path=None, backup=Tr # Num auf -1 setzen (Memory Cue) memory_cue.set("Num", "-1") + # Spezialbehandlung: Ersten Cue mit Namen "1.1Bars" in "Start" umbenennen + if i == 0 and hot_cue_name == "1.1Bars": + memory_cue.set("Name", "Start") + print(f"Hot Cue {hot_cue_num} (Start: {start_time}) als Memory Cue kopiert und Name von '1.1Bars' zu 'Start' geändert") + else: + print(f"Hot Cue {hot_cue_num} (Start: {start_time}) als Memory Cue kopiert") + # Farb-Attribute entfernen (Memory Cues haben keine Farben) for color_attr in ["Red", "Green", "Blue"]: if color_attr in memory_cue.attrib: @@ -95,8 +106,6 @@ def copy_hot_cues_to_memory_cues(xml_file_path, output_file_path=None, backup=Tr # Position zur Liste der existierenden Memory Cues hinzufügen if start_time: existing_memory_positions.add(start_time) - - print(f"Hot Cue {hot_cue_num} (Start: {start_time}) als Memory Cue kopiert") # XML speichern output_path = Path(output_file_path) if output_file_path else xml_path