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

21
cue2auda.py Normal file → Executable file
View File

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