ini file support and cover art

This commit is contained in:
2026-08-27 13:33:34 +02:00
parent 744a2815f1
commit 84891adb89
13 changed files with 422 additions and 79 deletions
+41 -10
View File
@@ -3,6 +3,7 @@
(require racket/cmdline
racket/contract
racket/list
racket/mpair
racket/string
simple-ini
simple-log
@@ -14,29 +15,47 @@
(sl-def-log rkt-web-player)
(define library-spec/c
(or/c path-string?
(list/c string? path-string?)))
(define (ini-section-key-values config section-name)
(let ((section (assoc section-name (mcdr config))))
(if section
(for/list ((line (in-list (cdr section)))
#:when (and (pair? line)
(eq? (car line) 'keyval)))
(cons (symbol->string (cadr line))
(caddr line)))
'())))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Provided functions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; goal : Start the audio player and its web interface.
; pre : The ports are valid TCP ports; every music path is an existing directory.
; pre : Ports are valid; every library spec names an existing directory.
; post : Libraries are browsed lazily; player resources close with the server.
; result : The result returned by serve/servlet.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define/contract (run-web-player music-paths
#:allowed-agent-ids [allowed-agent-ids '()]
#:listen-ip [listen-ip "127.0.0.1"]
#:port [port 8080]
#:dlna-port [dlna-port 8734]
#:launch-browser? [launch-browser? #t])
(->* ((listof path-string?))
(#:listen-ip string?
(->* ((listof library-spec/c))
(#:allowed-agent-ids (listof string?)
#:listen-ip string?
#:port exact-positive-integer?
#:dlna-port exact-positive-integer?
#:launch-browser? boolean?)
any)
(let* ((libraries (make-music-libraries music-paths))
(player (make-player libraries #:dlna-port dlna-port)))
(player (make-player libraries
#:allowed-agent-ids allowed-agent-ids
#:dlna-port dlna-port)))
(info-rkt-web-player
"Starting with ~a music library/libraries on http://~a:~a/"
(length libraries)
@@ -103,15 +122,27 @@
(string-split configured-paths-value ";")))
(else '())))
(define all-paths
(remove-duplicates
(append music-paths
configured-paths)
equal?))
(define configured-libraries
(for/list ((entry (in-list
(ini-section-key-values config 'libraries)))
#:when (path-string? (cdr entry)))
(list (car entry) (cdr entry))))
(define allowed-agent-ids
(for/list ((entry (in-list
(ini-section-key-values config 'playback-agents)))
#:when (not (eq? (cdr entry) #f)))
(car entry)))
(define all-libraries
(append configured-libraries
music-paths
configured-paths))
(sl-log-to-display)
(run-web-player
all-paths
all-libraries
#:allowed-agent-ids allowed-agent-ids
#:listen-ip (or listen-ip
(ini-get config 'server 'listen-ip "127.0.0.1"))
#:port (or port