This commit is contained in:
2026-02-19 20:29:36 +01:00
parent 111042442f
commit 0fffd544c0
20 changed files with 659 additions and 114 deletions

47
music-library.rkt Normal file
View File

@@ -0,0 +1,47 @@
#lang racket
(provide music-lib-relevant?
is-music-dir?
is-music-file?
basename
library-formatter
)
(define (music-lib-relevant? f)
(let ((type (file-or-directory-type f #t)))
(if (eq? type 'directory)
(let ((name (basename f)))
(not (string-prefix? name ".")))
(if (eq? type 'file)
(let* ((fn (string-downcase (format "~a" f)))
(exts (list "flac" "mp3")))
(let ((l (filter (λ (e) (string-suffix? fn (string-append "." e))) exts)))
(not (null? l))))
#f))))
(define (is-music-dir? f)
(and (music-lib-relevant? f)
(directory-exists? f)))
(define (is-music-file? f)
(and (music-lib-relevant? f)
(file-exists? f)))
(define (basename file)
(call-with-values (λ () (split-path file))
(λ (base name is-dir)
(path->string name))))
(define (library-formatter row)
(let ((file-entry (car row))
(file-id (cadr row))
)
(list (list 'td (list (list 'class "library-entry") (list 'id file-id) (list 'file (format "~a" file-entry)))
(if (equal? file-id "lib-up")
file-entry
(basename file-entry))
))
)
)