Compare commits
2 Commits
e46d4d3b28
...
2af0e93713
Author | SHA1 | Date | |
---|---|---|---|
2af0e93713 | |||
a22bb3ef8b |
19
README.md
19
README.md
@@ -18,6 +18,10 @@ Ein Python-Skript zur automatischen Verwaltung von Hot Cues und Memory Cues in R
|
||||
- Der erste Hot Cue mit dem Namen "1.1Bars" wird automatisch zu "Start" umbenannt
|
||||
- Die Umbenennung erfolgt am Original Hot Cue vor dem Kopieren
|
||||
|
||||
### 4. **Cleanup-Modus**: Leere Hot Cues und Memory Cues löschen
|
||||
- Entfernt alle Hot Cues und Memory Cues, deren Name leer ist oder nur aus Leerzeichen besteht
|
||||
- Praktisch für die Bereinigung von XML-Dateien
|
||||
|
||||
## 🛡️ Schutzfunktionen
|
||||
|
||||
Das Skript überspringt Tracks automatisch in folgenden Fällen:
|
||||
@@ -77,12 +81,23 @@ python main.py convert rekordbox.xml
|
||||
python main.py convert rekordbox.xml -o rekordbox_converted.xml
|
||||
```
|
||||
|
||||
### Cleanup-Modus
|
||||
|
||||
```bash
|
||||
# Alle Hot Cues und Memory Cues ohne Text löschen
|
||||
python main.py cleanup rekordbox.xml
|
||||
|
||||
# In neue Datei speichern
|
||||
python main.py cleanup rekordbox.xml -o rekordbox_cleaned.xml
|
||||
```
|
||||
|
||||
### Hilfe anzeigen
|
||||
|
||||
```bash
|
||||
python main.py --help
|
||||
python main.py copy --help
|
||||
python main.py convert --help
|
||||
python main.py cleanup --help
|
||||
```
|
||||
|
||||
## 🔧 Optionen
|
||||
@@ -110,6 +125,10 @@ Kopierte Hot Cues: 42
|
||||
Übersprungene Hot Cues: 3
|
||||
(Übersprungene Tracks: bereits mehr als 1 Memory Cue vorhanden oder nur 1 Hot Cue)
|
||||
(Übersprungene Hot Cues: Memory Cue an gleicher Position bereits vorhanden)
|
||||
|
||||
Backup erstellt: rekordbox.xml.backup
|
||||
Ergebnis gespeichert in: rekordbox.xml
|
||||
Gelöschte Cues: 7
|
||||
```
|
||||
|
||||
## 🔍 XML-Struktur
|
||||
|
50
main.py
50
main.py
@@ -202,6 +202,44 @@ def convert_hot_cues_to_memory_cues(xml_file_path, output_file_path=None, backup
|
||||
raise Exception(f"Fehler beim Speichern der XML-Datei: {e}")
|
||||
|
||||
|
||||
def cleanup_empty_cues(xml_file_path, output_file_path=None, backup=True):
|
||||
"""
|
||||
Löscht alle Hot Cues und Memory Cues, deren Name leer ist oder nur aus Leerzeichen besteht.
|
||||
Args:
|
||||
xml_file_path (str): Pfad zur Rekordbox XML Datei
|
||||
output_file_path (str, optional): Ausgabedatei. Wenn None, wird die Original-Datei überschrieben
|
||||
backup (bool): Erstellt ein Backup der Original-Datei
|
||||
"""
|
||||
xml_path = Path(xml_file_path)
|
||||
if not xml_path.exists():
|
||||
raise FileNotFoundError(f"XML-Datei nicht gefunden: {xml_file_path}")
|
||||
if backup:
|
||||
backup_path = xml_path.with_suffix(xml_path.suffix + '.backup')
|
||||
shutil.copy2(xml_path, backup_path)
|
||||
print(f"Backup erstellt: {backup_path}")
|
||||
try:
|
||||
tree = ET.parse(xml_path)
|
||||
root = tree.getroot()
|
||||
except ET.ParseError as e:
|
||||
raise Exception(f"Fehler beim Parsen der XML-Datei: {e}")
|
||||
|
||||
cues_deleted = 0
|
||||
for track in root.findall(".//TRACK"):
|
||||
position_marks = list(track.findall(".//POSITION_MARK"))
|
||||
for position_mark in position_marks:
|
||||
name = position_mark.get("Name", "")
|
||||
if name.strip() == "":
|
||||
track.remove(position_mark)
|
||||
cues_deleted += 1
|
||||
output_path = Path(output_file_path) if output_file_path else xml_path
|
||||
try:
|
||||
tree.write(output_path, encoding="utf-8", xml_declaration=True)
|
||||
print(f"\nErgebnis gespeichert in: {output_path}")
|
||||
print(f"Gelöschte Cues: {cues_deleted}")
|
||||
except Exception as e:
|
||||
raise Exception(f"Fehler beim Speichern der XML-Datei: {e}")
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Rekordbox XML Hot Cue Tools",
|
||||
@@ -235,6 +273,12 @@ Beispiele:
|
||||
convert_parser.add_argument("xml_file", help="Pfad zur Rekordbox XML Datei")
|
||||
convert_parser.add_argument("-o", "--output", help="Ausgabedatei (optional)")
|
||||
convert_parser.add_argument("--no-backup", action="store_true", help="Kein Backup erstellen")
|
||||
|
||||
# Cleanup command
|
||||
cleanup_parser = subparsers.add_parser("cleanup", help="Leere Hot Cues und Memory Cues löschen")
|
||||
cleanup_parser.add_argument("xml_file", help="Pfad zur Rekordbox XML Datei")
|
||||
cleanup_parser.add_argument("-o", "--output", help="Ausgabedatei (optional)")
|
||||
cleanup_parser.add_argument("--no-backup", action="store_true", help="Kein Backup erstellen")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
@@ -255,6 +299,12 @@ Beispiele:
|
||||
args.output,
|
||||
backup=not args.no_backup
|
||||
)
|
||||
elif args.command == "cleanup":
|
||||
cleanup_empty_cues(
|
||||
args.xml_file,
|
||||
args.output,
|
||||
backup=not args.no_backup
|
||||
)
|
||||
except Exception as e:
|
||||
print(f"Fehler: {e}")
|
||||
return 1
|
||||
|
Reference in New Issue
Block a user