Füge Unterstützung für die Verarbeitung von einzelnen CUE-Dateien hinzu und verbessere die Fehlerbehandlung

This commit is contained in:
2025-07-03 11:08:34 +02:00
parent 2b564a6dd3
commit 9bd687901c
2 changed files with 38 additions and 9 deletions

View File

@ -38,15 +38,35 @@ Oder einfach die Dateien herunterladen:
## Verwendung ## Verwendung
Das Script unterstützt zwei Modi:
### 1. Verzeichnis verarbeiten (alle CUE-Dateien)
```bash ```bash
python cue2auda.py /pfad/zu/ihren/cue/dateien python cue2auda.py /pfad/zu/ihren/cue/dateien
``` ```
### Beispiel ### 2. Einzelne CUE-Datei verarbeiten
```bash ```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 ## Ein- und Ausgabeformat

21
cue2auda.py Normal file → Executable file
View File

@ -12,11 +12,22 @@ import os
# Get argument on command line # Get argument on command line
parser = argparse.ArgumentParser() 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 thePath = parser.parse_args().thePathOfCueFiles
# Read *.cue files in specified directory # Determine if input is a directory or a single file
for cueFileName in glob.glob(os.path.join(thePath, "*.cue")): 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) #print(cueFileName)
with open(cueFileName, "r", encoding="utf-8") as cueFile: with open(cueFileName, "r", encoding="utf-8") as cueFile:
cueFileContent = cueFile.readlines() cueFileContent = cueFile.readlines()
@ -86,12 +97,10 @@ for cueFileName in glob.glob(os.path.join(thePath, "*.cue")):
# Add to title history # Add to title history
lastTitles.append(theTitle) 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 {trackCount} labels in {labelFileName}")
print(f"Created tracklist in {tracklistFileName}") print(f"Created tracklist in {tracklistFileName}")
# end for line in cueFileContent # end for line in cueFileContent
# end for cueFileName in glob.glob(thePath + "\\*.cue") # end for cueFileName in cueFiles