Füge .gitignore, README.md, main.py, pyproject.toml und uv.lock hinzu; implementiere Funktionen zum Kopieren und Konvertieren von Hot Cues in Memory Cues in der Rekordbox XML.
This commit is contained in:
191
.gitignore
vendored
Normal file
191
.gitignore
vendored
Normal file
@@ -0,0 +1,191 @@
|
|||||||
|
# Byte-compiled / optimized / DLL files
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
|
||||||
|
# C extensions
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Distribution / packaging
|
||||||
|
.Python
|
||||||
|
build/
|
||||||
|
develop-eggs/
|
||||||
|
dist/
|
||||||
|
downloads/
|
||||||
|
eggs/
|
||||||
|
.eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
wheels/
|
||||||
|
share/python-wheels/
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
MANIFEST
|
||||||
|
|
||||||
|
# PyInstaller
|
||||||
|
# Usually these files are written by a python script from a template
|
||||||
|
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||||
|
*.manifest
|
||||||
|
*.spec
|
||||||
|
|
||||||
|
# Installer logs
|
||||||
|
pip-log.txt
|
||||||
|
pip-delete-this-directory.txt
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.nox/
|
||||||
|
.coverage
|
||||||
|
.coverage.*
|
||||||
|
.cache
|
||||||
|
nosetests.xml
|
||||||
|
coverage.xml
|
||||||
|
*.cover
|
||||||
|
*.py,cover
|
||||||
|
.hypothesis/
|
||||||
|
.pytest_cache/
|
||||||
|
cover/
|
||||||
|
|
||||||
|
# Translations
|
||||||
|
*.mo
|
||||||
|
*.pot
|
||||||
|
|
||||||
|
# Django stuff:
|
||||||
|
*.log
|
||||||
|
local_settings.py
|
||||||
|
db.sqlite3
|
||||||
|
db.sqlite3-journal
|
||||||
|
|
||||||
|
# Flask stuff:
|
||||||
|
instance/
|
||||||
|
.webassets-cache
|
||||||
|
|
||||||
|
# Scrapy stuff:
|
||||||
|
.scrapy
|
||||||
|
|
||||||
|
# Sphinx documentation
|
||||||
|
docs/_build/
|
||||||
|
|
||||||
|
# PyBuilder
|
||||||
|
.pybuilder/
|
||||||
|
target/
|
||||||
|
|
||||||
|
# Jupyter Notebook
|
||||||
|
.ipynb_checkpoints
|
||||||
|
|
||||||
|
# IPython
|
||||||
|
profile_default/
|
||||||
|
ipython_config.py
|
||||||
|
|
||||||
|
# pyenv
|
||||||
|
# For a library or package, you might want to ignore these files since the code is
|
||||||
|
# intended to run in multiple environments; otherwise, check them in:
|
||||||
|
.python-version
|
||||||
|
|
||||||
|
# pipenv
|
||||||
|
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||||
|
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||||
|
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||||
|
# install all needed dependencies.
|
||||||
|
#Pipfile.lock
|
||||||
|
|
||||||
|
# poetry
|
||||||
|
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
||||||
|
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
||||||
|
# commonly ignored for libraries.
|
||||||
|
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
||||||
|
#poetry.lock
|
||||||
|
|
||||||
|
# pdm
|
||||||
|
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
||||||
|
#pdm.lock
|
||||||
|
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
||||||
|
# in version control.
|
||||||
|
# https://pdm.fming.dev/#use-with-ide
|
||||||
|
.pdm.toml
|
||||||
|
|
||||||
|
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
||||||
|
__pypackages__/
|
||||||
|
|
||||||
|
# Celery stuff
|
||||||
|
celerybeat-schedule
|
||||||
|
celerybeat.pid
|
||||||
|
|
||||||
|
# SageMath parsed files
|
||||||
|
*.sage.py
|
||||||
|
|
||||||
|
# Environments
|
||||||
|
.env
|
||||||
|
.venv
|
||||||
|
env/
|
||||||
|
venv/
|
||||||
|
ENV/
|
||||||
|
env.bak/
|
||||||
|
venv.bak/
|
||||||
|
|
||||||
|
# Spyder project settings
|
||||||
|
.spyderproject
|
||||||
|
.spyproject
|
||||||
|
|
||||||
|
# Rope project settings
|
||||||
|
.ropeproject
|
||||||
|
|
||||||
|
# mkdocs documentation
|
||||||
|
/site
|
||||||
|
|
||||||
|
# mypy
|
||||||
|
.mypy_cache/
|
||||||
|
.dmypy.json
|
||||||
|
dmypy.json
|
||||||
|
|
||||||
|
# Pyre type checker
|
||||||
|
.pyre/
|
||||||
|
|
||||||
|
# pytype static type analyzer
|
||||||
|
.pytype/
|
||||||
|
|
||||||
|
# Cython debug symbols
|
||||||
|
cython_debug/
|
||||||
|
|
||||||
|
# PyCharm
|
||||||
|
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
||||||
|
# be added to the global gitignore or merged into this project gitignore. For a PyCharm
|
||||||
|
# project, it is generally recommended to include the cache and other metadata directories.
|
||||||
|
.idea/
|
||||||
|
|
||||||
|
# VS Code
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
# Operating System
|
||||||
|
.DS_Store
|
||||||
|
.DS_Store?
|
||||||
|
._*
|
||||||
|
.Spotlight-V100
|
||||||
|
.Trashes
|
||||||
|
ehthumbs.db
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# Temporary files
|
||||||
|
*.tmp
|
||||||
|
*.temp
|
||||||
|
*~
|
||||||
|
.#*
|
||||||
|
|
||||||
|
# Log files
|
||||||
|
*.log
|
||||||
|
|
||||||
|
# Database files
|
||||||
|
*.db
|
||||||
|
*.sqlite
|
||||||
|
*.sqlite3
|
||||||
|
|
||||||
|
# Configuration files that may contain sensitive information
|
||||||
|
config.ini
|
||||||
|
settings.ini
|
||||||
|
secrets.json
|
||||||
|
.secrets
|
233
main.py
Normal file
233
main.py
Normal file
@@ -0,0 +1,233 @@
|
|||||||
|
import xml.etree.ElementTree as ET
|
||||||
|
import argparse
|
||||||
|
import shutil
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
|
def copy_hot_cues_to_memory_cues(xml_file_path, output_file_path=None, backup=True):
|
||||||
|
"""
|
||||||
|
Kopiert alle Hot Cues als Memory Cues in der Rekordbox XML.
|
||||||
|
|
||||||
|
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}")
|
||||||
|
|
||||||
|
# Backup erstellen
|
||||||
|
if backup:
|
||||||
|
backup_path = xml_path.with_suffix(xml_path.suffix + '.backup')
|
||||||
|
shutil.copy2(xml_path, backup_path)
|
||||||
|
print(f"Backup erstellt: {backup_path}")
|
||||||
|
|
||||||
|
# XML laden
|
||||||
|
try:
|
||||||
|
tree = ET.parse(xml_path)
|
||||||
|
root = tree.getroot()
|
||||||
|
except ET.ParseError as e:
|
||||||
|
raise Exception(f"Fehler beim Parsen der XML-Datei: {e}")
|
||||||
|
|
||||||
|
tracks_processed = 0
|
||||||
|
total_hot_cues_copied = 0
|
||||||
|
total_hot_cues_skipped = 0
|
||||||
|
|
||||||
|
# Alle TRACK Elemente finden
|
||||||
|
for track in root.findall(".//TRACK"):
|
||||||
|
hot_cues_in_track = []
|
||||||
|
memory_cues_in_track = []
|
||||||
|
|
||||||
|
# Alle POSITION_MARK Elemente in diesem Track finden
|
||||||
|
for position_mark in track.findall(".//POSITION_MARK"):
|
||||||
|
num_attr = position_mark.get("Num")
|
||||||
|
|
||||||
|
if num_attr:
|
||||||
|
if num_attr.isdigit() and int(num_attr) >= 0:
|
||||||
|
# Hot Cues haben Num >= 0
|
||||||
|
hot_cues_in_track.append(position_mark)
|
||||||
|
elif num_attr == "-1":
|
||||||
|
# Memory Cues haben Num = -1
|
||||||
|
memory_cues_in_track.append(position_mark)
|
||||||
|
|
||||||
|
# Hot Cues als Memory Cues kopieren
|
||||||
|
if hot_cues_in_track:
|
||||||
|
tracks_processed += 1
|
||||||
|
|
||||||
|
# Set mit bestehenden Memory Cue Positionen erstellen (für schnelle Suche)
|
||||||
|
existing_memory_positions = set()
|
||||||
|
for memory_cue in memory_cues_in_track:
|
||||||
|
start_time = memory_cue.get("Start")
|
||||||
|
if start_time:
|
||||||
|
existing_memory_positions.add(start_time)
|
||||||
|
|
||||||
|
for hot_cue in hot_cues_in_track:
|
||||||
|
start_time = hot_cue.get("Start")
|
||||||
|
hot_cue_num = hot_cue.get("Num", "N/A")
|
||||||
|
|
||||||
|
# Prüfen, ob bereits ein Memory Cue an dieser Position existiert
|
||||||
|
if start_time and start_time in existing_memory_positions:
|
||||||
|
print(f"Hot Cue {hot_cue_num} (Start: {start_time}) übersprungen - Memory Cue existiert bereits")
|
||||||
|
total_hot_cues_skipped += 1
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Neues POSITION_MARK Element als Memory Cue erstellen
|
||||||
|
memory_cue = ET.Element("POSITION_MARK")
|
||||||
|
|
||||||
|
# Alle Attribute kopieren
|
||||||
|
for attr_name, attr_value in hot_cue.attrib.items():
|
||||||
|
memory_cue.set(attr_name, attr_value)
|
||||||
|
|
||||||
|
# Num auf -1 setzen (Memory Cue)
|
||||||
|
memory_cue.set("Num", "-1")
|
||||||
|
|
||||||
|
# Farb-Attribute entfernen (Memory Cues haben keine Farben)
|
||||||
|
for color_attr in ["Red", "Green", "Blue"]:
|
||||||
|
if color_attr in memory_cue.attrib:
|
||||||
|
del memory_cue.attrib[color_attr]
|
||||||
|
|
||||||
|
# Memory Cue zum Track hinzufügen
|
||||||
|
track.append(memory_cue)
|
||||||
|
total_hot_cues_copied += 1
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
try:
|
||||||
|
tree.write(output_path, encoding="utf-8", xml_declaration=True)
|
||||||
|
print(f"\nErgebnis gespeichert in: {output_path}")
|
||||||
|
print(f"Verarbeitete Tracks: {tracks_processed}")
|
||||||
|
print(f"Kopierte Hot Cues: {total_hot_cues_copied}")
|
||||||
|
print(f"Übersprungene Hot Cues: {total_hot_cues_skipped}")
|
||||||
|
if total_hot_cues_skipped > 0:
|
||||||
|
print("(Übersprungene Hot Cues: Memory Cue an gleicher Position bereits vorhanden)")
|
||||||
|
except Exception as e:
|
||||||
|
raise Exception(f"Fehler beim Speichern der XML-Datei: {e}")
|
||||||
|
|
||||||
|
|
||||||
|
def convert_hot_cues_to_memory_cues(xml_file_path, output_file_path=None, backup=True):
|
||||||
|
"""
|
||||||
|
Konvertiert alle Hot Cues zu Memory Cues (ändert Num zu -1).
|
||||||
|
|
||||||
|
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}")
|
||||||
|
|
||||||
|
# Backup erstellen
|
||||||
|
if backup:
|
||||||
|
backup_path = xml_path.with_suffix(xml_path.suffix + '.backup')
|
||||||
|
shutil.copy2(xml_path, backup_path)
|
||||||
|
print(f"Backup erstellt: {backup_path}")
|
||||||
|
|
||||||
|
# XML laden
|
||||||
|
try:
|
||||||
|
tree = ET.parse(xml_path)
|
||||||
|
root = tree.getroot()
|
||||||
|
except ET.ParseError as e:
|
||||||
|
raise Exception(f"Fehler beim Parsen der XML-Datei: {e}")
|
||||||
|
|
||||||
|
converted_hot_cues = 0
|
||||||
|
|
||||||
|
# Alle POSITION_MARK Elemente finden
|
||||||
|
for position_mark in root.findall(".//POSITION_MARK"):
|
||||||
|
num_attr = position_mark.get("Num")
|
||||||
|
|
||||||
|
# Hot Cues haben Num >= 0
|
||||||
|
if num_attr and num_attr.isdigit() and int(num_attr) >= 0:
|
||||||
|
# Zu Memory Cue konvertieren
|
||||||
|
position_mark.set("Num", "-1")
|
||||||
|
|
||||||
|
# Farb-Attribute entfernen
|
||||||
|
for color_attr in ["Red", "Green", "Blue"]:
|
||||||
|
if color_attr in position_mark.attrib:
|
||||||
|
del position_mark.attrib[color_attr]
|
||||||
|
|
||||||
|
converted_hot_cues += 1
|
||||||
|
start_time = position_mark.get("Start", "N/A")
|
||||||
|
print(f"Hot Cue (Start: {start_time}) zu Memory Cue konvertiert")
|
||||||
|
|
||||||
|
# XML speichern
|
||||||
|
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"Konvertierte Hot Cues: {converted_hot_cues}")
|
||||||
|
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",
|
||||||
|
formatter_class=argparse.RawDescriptionHelpFormatter,
|
||||||
|
epilog="""
|
||||||
|
Beispiele:
|
||||||
|
# Hot Cues als Memory Cues kopieren
|
||||||
|
python main.py copy rekordbox.xml
|
||||||
|
|
||||||
|
# Hot Cues als Memory Cues kopieren und in neue Datei speichern
|
||||||
|
python main.py copy rekordbox.xml -o rekordbox_modified.xml
|
||||||
|
|
||||||
|
# Alle Hot Cues zu Memory Cues konvertieren
|
||||||
|
python main.py convert rekordbox.xml
|
||||||
|
|
||||||
|
# Ohne Backup arbeiten
|
||||||
|
python main.py copy rekordbox.xml --no-backup
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
|
subparsers = parser.add_subparsers(dest="command", help="Verfügbare Befehle")
|
||||||
|
|
||||||
|
# Copy command
|
||||||
|
copy_parser = subparsers.add_parser("copy", help="Hot Cues als Memory Cues kopieren")
|
||||||
|
copy_parser.add_argument("xml_file", help="Pfad zur Rekordbox XML Datei")
|
||||||
|
copy_parser.add_argument("-o", "--output", help="Ausgabedatei (optional)")
|
||||||
|
copy_parser.add_argument("--no-backup", action="store_true", help="Kein Backup erstellen")
|
||||||
|
|
||||||
|
# Convert command
|
||||||
|
convert_parser = subparsers.add_parser("convert", help="Hot Cues zu Memory Cues konvertieren")
|
||||||
|
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")
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
if not args.command:
|
||||||
|
parser.print_help()
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
if args.command == "copy":
|
||||||
|
copy_hot_cues_to_memory_cues(
|
||||||
|
args.xml_file,
|
||||||
|
args.output,
|
||||||
|
backup=not args.no_backup
|
||||||
|
)
|
||||||
|
elif args.command == "convert":
|
||||||
|
convert_hot_cues_to_memory_cues(
|
||||||
|
args.xml_file,
|
||||||
|
args.output,
|
||||||
|
backup=not args.no_backup
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Fehler: {e}")
|
||||||
|
return 1
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
7
pyproject.toml
Normal file
7
pyproject.toml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
[project]
|
||||||
|
name = "rekordbox"
|
||||||
|
version = "0.1.0"
|
||||||
|
description = "Add your description here"
|
||||||
|
readme = "README.md"
|
||||||
|
requires-python = ">=3.11"
|
||||||
|
dependencies = []
|
Reference in New Issue
Block a user