From 9bd687901c04c9dcb448435b280ea38309a9cd93 Mon Sep 17 00:00:00 2001 From: Manuel Weiser Date: Thu, 3 Jul 2025 11:08:34 +0200 Subject: [PATCH] =?UTF-8?q?F=C3=BCge=20Unterst=C3=BCtzung=20f=C3=BCr=20die?= =?UTF-8?q?=20Verarbeitung=20von=20einzelnen=20CUE-Dateien=20hinzu=20und?= =?UTF-8?q?=20verbessere=20die=20Fehlerbehandlung?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 26 +++++++++++++++++++++++--- cue2auda.py | 21 +++++++++++++++------ 2 files changed, 38 insertions(+), 9 deletions(-) mode change 100644 => 100755 cue2auda.py diff --git a/README.md b/README.md index f2a2fc7..de77b28 100644 --- a/README.md +++ b/README.md @@ -38,15 +38,35 @@ Oder einfach die Dateien herunterladen: ## Verwendung +Das Script unterstützt zwei Modi: + +### 1. Verzeichnis verarbeiten (alle CUE-Dateien) + ```bash python cue2auda.py /pfad/zu/ihren/cue/dateien ``` -### Beispiel +### 2. Einzelne CUE-Datei verarbeiten + ```bash -python cue2auda.py . +python cue2auda.py /pfad/zur/datei.cue +``` + +### Beispiele + +```bash +# Alle CUE-Dateien im aktuellen Verzeichnis verarbeiten +python cue2auda.py . + +# Alle CUE-Dateien in einem spezifischen Verzeichnis +python cue2auda.py /Users/manuel/Music/DJ-Sets/ + +# Nur eine spezifische CUE-Datei verarbeiten +python cue2auda.py "01 REC-2025-07-02.cue" + +# Absolute Pfad zu einer einzelnen Datei +python cue2auda.py /Users/manuel/Music/mix.cue ``` -Verarbeitet alle `.cue` Dateien im aktuellen Verzeichnis. ## Ein- und Ausgabeformat diff --git a/cue2auda.py b/cue2auda.py old mode 100644 new mode 100755 index 46fd422..60c897c --- a/cue2auda.py +++ b/cue2auda.py @@ -12,11 +12,22 @@ import os # Get argument on command line parser = argparse.ArgumentParser() -parser.add_argument("thePathOfCueFiles", help="The path of the directory with the CUE files to process") +parser.add_argument("thePathOfCueFiles", help="The path of the directory with CUE files or a single CUE file to process") thePath = parser.parse_args().thePathOfCueFiles -# Read *.cue files in specified directory -for cueFileName in glob.glob(os.path.join(thePath, "*.cue")): +# Determine if input is a directory or a single file +if os.path.isfile(thePath) and thePath.lower().endswith('.cue'): + # Single CUE file + cueFiles = [thePath] +elif os.path.isdir(thePath): + # Directory - find all CUE files + cueFiles = glob.glob(os.path.join(thePath, "*.cue")) +else: + print(f"Error: '{thePath}' is neither a valid CUE file nor a directory containing CUE files.") + exit(1) + +# Process each CUE file +for cueFileName in cueFiles: #print(cueFileName) with open(cueFileName, "r", encoding="utf-8") as cueFile: cueFileContent = cueFile.readlines() @@ -86,12 +97,10 @@ for cueFileName in glob.glob(os.path.join(thePath, "*.cue")): # Add to title history lastTitles.append(theTitle) - else: - print(f"Skipping duplicate: '{theTitle}' at {theHours:02d}:{theMinutes:02d}:{theSeconds:02d} (appeared within last {maxTrackDistance} tracks)") print(f"Created {trackCount} labels in {labelFileName}") print(f"Created tracklist in {tracklistFileName}") # end for line in cueFileContent -# end for cueFileName in glob.glob(thePath + "\\*.cue") +# end for cueFileName in cueFiles