Sortiere Hot Cues nach Start-Zeit und ändere den Namen des ersten Cues "1.1Bars" in "Start" beim Kopieren als Memory Cue.

This commit is contained in:
2025-07-19 20:11:35 +02:00
parent 6094ff45f5
commit 551d7d8948

15
main.py
View File

@@ -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