From fa79b6dc6286030bbed9fc2bdb9256d4a6d7f80a Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Wed, 1 Apr 2026 11:45:08 -0400 Subject: [PATCH] Add album order to track picker and --list New tracks not in ALBUM_ORDER sort to the end. Co-Authored-By: Claude Opus 4.6 (1M context) --- play.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/play.py b/play.py index 516b7df..a3d9d3a 100644 --- a/play.py +++ b/play.py @@ -37,6 +37,25 @@ from pytheory import play_score TRACKS_DIR = Path(__file__).parent / "tracks" +# Album order — defines the canonical tracklist +ALBUM_ORDER = [ + "raga_midnight.py", + "culture_clash.py", + "chakra.py", + "ghost_protocol.py", + "acid_reign.py", + "silk_road.py", + "deep_time.py", + "the_interruption.py", + "the_temple.py", +] + + +def sorted_tracks(files): + """Sort track files by album order. Unknown tracks go at the end.""" + order = {name: i for i, name in enumerate(ALBUM_ORDER)} + return sorted(files, key=lambda f: order.get(f.name, 999)) + # ═══════════════════════════════════════════════════════════════════ # Score loading @@ -298,7 +317,7 @@ def list_tracks(): print("No tracks/ directory found.") return - files = sorted(TRACKS_DIR.glob("*.py")) + files = sorted_tracks(list(TRACKS_DIR.glob("*.py"))) if not files: print("No .py files in tracks/.") return @@ -334,7 +353,7 @@ def pick_track(): print("No tracks/ directory found.") return None - files = sorted(TRACKS_DIR.glob("*.py")) + files = sorted_tracks(list(TRACKS_DIR.glob("*.py"))) if not files: print("No tracks found.") return None