From 53cad05cd99a7be0cf4082a85445d315445893cd Mon Sep 17 00:00:00 2001 From: "Roncero Blanco, Edgar" Date: Mon, 26 May 2025 13:51:24 +0200 Subject: [PATCH] Add handling for files without BPM: group into [Unknown BPM] folder; keep balanced CD splits and timestamped output folder --- src/app.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/app.py b/src/app.py index 6c68489..ec35c4e 100644 --- a/src/app.py +++ b/src/app.py @@ -35,16 +35,21 @@ def get_bpm(file_path): print(f"Skipping {file_path.name} (no BPM): {e}") return None -# Collect all tracks +# Collect all tracks, grouping unknown BPM separately all_tracks = [] for file in source_media_path.glob("*.mp3"): bpm = get_bpm(file) - if bpm is None: - continue size = file.stat().st_size - bpm_range = f"{(bpm // GROUP_SIZE) * GROUP_SIZE}-to-{((bpm // GROUP_SIZE) * GROUP_SIZE) + GROUP_SIZE - 1}" + if bpm is None: + bpm_range = "[Unknown BPM]" + else: + bpm_range = f"{(bpm // GROUP_SIZE) * GROUP_SIZE}-to-{((bpm // GROUP_SIZE) * GROUP_SIZE) + GROUP_SIZE - 1}" all_tracks.append({"file": file, "size": size, "bpm_range": bpm_range}) +if not all_tracks: + print("No MP3 files found.") + exit(0) + # Calculate total size and number of CDs needed total_size = sum(t["size"] for t in all_tracks) num_cds = max(1, (total_size + CD_SIZE - 1) // CD_SIZE) @@ -89,3 +94,5 @@ for i, tracks in enumerate(cd_contents, start=1): size_accum += track["size"] print(f"[WRITE] CD-{i:02}: {len(tracks)} tracks, approx {size_accum/1024**2:.2f} MB") +print("\n✅ Done!") +