From 16f3592e97048c43ab71cd8144cec193634f08f0 Mon Sep 17 00:00:00 2001 From: Brian O'Reilly Date: Sun, 14 Sep 2025 15:43:33 -0400 Subject: [PATCH] recursively scan the music directory to implicit depth 2 it is likely that the music library will contain directories of albums, read the files inside those dirs. --- asteroid.lisp | 2 ++ stream-media.lisp | 7 ++++++- template/admin.chtml | 6 +++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/asteroid.lisp b/asteroid.lisp index 7256537..d3f6624 100644 --- a/asteroid.lisp +++ b/asteroid.lisp @@ -285,7 +285,9 @@ ("listeners" . 0) ("stream-url" . "http://localhost:8000/asteroid")))) + ;; RADIANCE server management functions + (defun start-server (&key (port *server-port*)) "Start the Asteroid Radio RADIANCE server" (format t "Starting Asteroid Radio RADIANCE server on port ~a~%" port) diff --git a/stream-media.lisp b/stream-media.lisp index c1145b6..437c1c0 100644 --- a/stream-media.lisp +++ b/stream-media.lisp @@ -12,6 +12,11 @@ (remove-if-not #'supported-audio-file-p (cl-fad:list-directory directory :follow-symlinks nil)))) +(defun scan-directory-for-music-recursively (path) + (loop for directory in (uiop:subdirectories path) + with music = (scan-directory-for-music path) + appending (scan-directory-for-music directory))) + (defun extract-metadata-with-taglib (file-path) "Extract metadata using taglib library" (handler-case @@ -68,7 +73,7 @@ (defun scan-music-library (&optional (directory *music-library-path*)) "Scan music library directory and add tracks to database" (format t "Scanning music library: ~a~%" directory) - (let ((audio-files (scan-directory-for-music directory)) + (let ((audio-files (scan-directory-for-music-recursively directory)) (added-count 0)) (dolist (file audio-files) (let ((metadata (extract-metadata-with-taglib file))) diff --git a/template/admin.chtml b/template/admin.chtml index eca9611..67ea272 100644 --- a/template/admin.chtml +++ b/template/admin.chtml @@ -47,9 +47,9 @@

To add your own MP3 files:

    -
  1. Copy your MP3/FLAC/OGG/WAV files to: /home/glenn/Projects/Code/asteroid/music/incoming/
  2. -
  3. Click "Copy Files to Library" below
  4. -
  5. Files will be moved to the library and added to the database
  6. +
  7. Copy your MP3/FLAC/OGG/WAV files to: /home/glenn/Projects/Code/asteroid/music/incoming/
  8. +
  9. Click "Copy Files to Library" below
  10. +
  11. Files will be moved to the library and added to the database

Supported formats: MP3, FLAC, OGG, WAV