Cleanup of vibe code and replacement by self coded audio manager.
This commit is contained in:
+36
-22
@@ -41,7 +41,9 @@
|
||||
(processed-kind (make-hash))
|
||||
(base-rate (ini-get ini 'flac 'max-khz 48000))
|
||||
(dirs-logged -1)
|
||||
(known-exts '(mp3 flac opus mp4 m4a mpg jpg jpeg png pdf))
|
||||
(known-audio-exts '(mp3 flac opus mp4 mp4a mpg ape wav))
|
||||
(known-exts (append known-audio-exts
|
||||
'(jpg jpeg png pdf)))
|
||||
(unknown-exts '())
|
||||
)
|
||||
|
||||
@@ -123,17 +125,19 @@
|
||||
(values base-path path info)))
|
||||
|
||||
(define (flac-with-id3 base-path path info)
|
||||
(if (needs-processing? path info)
|
||||
(when (eq? (hash-ref info 'ext) 'flac)
|
||||
(let ((sniffed (audio-sniff-format path)))
|
||||
(hash-set! info 'sniffed sniffed)
|
||||
(when (flac-id3? info)
|
||||
(rep-id3 path))
|
||||
)
|
||||
)
|
||||
(when (flac-id3? info)
|
||||
(rep-id3 path))
|
||||
)
|
||||
(if (or (needs-processing? path info)
|
||||
(eq? (hash-ref info 'sniffed #f) #f))
|
||||
(let ((ext (hash-ref info 'ext)))
|
||||
(when (memq ext known-audio-exts)
|
||||
(let ((sniffed (audio-sniff-format path)))
|
||||
(hash-set! info 'sniffed sniffed)
|
||||
(when (flac-id3? info)
|
||||
(rep-id3 path))
|
||||
)
|
||||
))
|
||||
(when (flac-id3? info)
|
||||
(rep-id3 path))
|
||||
)
|
||||
(values base-path path info))
|
||||
|
||||
(define (flac-khz-bits base-path path info)
|
||||
@@ -156,7 +160,11 @@
|
||||
(info-am "Need to convert flac file ~a (rate = ~a)" path rate)
|
||||
(rep-flac (format "Convert ~a from ~a to ~a\n" path rate base-rate))
|
||||
(if (convert-flac-to-rate path base-rate)
|
||||
(hash-set! info 'khz base-rate)
|
||||
(begin
|
||||
(hash-set! info 'khz base-rate)
|
||||
(hash-set! info 'size (file-size path))
|
||||
(hash-set! info 'mtime (file-or-directory-modify-seconds path))
|
||||
)
|
||||
(begin
|
||||
(err-am " Cannot convert!")
|
||||
(rep-flac " CANNOT CONVERT!")))
|
||||
@@ -187,6 +195,8 @@
|
||||
(tags-picture! tags cover)
|
||||
(tags-save! tags))
|
||||
#:mode 'read-write))
|
||||
(hash-set! info 'size (file-size path))
|
||||
(hash-set! info 'mtime (file-or-directory-modify-seconds path))
|
||||
(info-am " Picture set")
|
||||
(set! pictures-set (+ pictures-set 1))
|
||||
)
|
||||
@@ -252,7 +262,11 @@
|
||||
(when (deleted? info)
|
||||
(let ((path-part (get-path-part info)))
|
||||
(unless (eq? path-part #f)
|
||||
(let ((rm-path (build-path opus-path path-part)))
|
||||
(let ((rm-path (if (flac? info)
|
||||
(path-replace-extension
|
||||
(build-path opus-path path-part)
|
||||
#".opus")
|
||||
(build-path opus-path path-part))))
|
||||
(delete-directory/files rm-path #:must-exist? #f)
|
||||
(let ((normalized-sub-path (hash-ref info 'path)))
|
||||
(hash-remove! file-db-hash normalized-sub-path))
|
||||
@@ -346,14 +360,14 @@
|
||||
(sl-set-log-level log-level)
|
||||
|
||||
(let ((fw (make-file-admin music-path file-db-hash)))
|
||||
(set! fw (fw-add-filter fw adjust-ext))
|
||||
(set! fw (fw-add-filter fw flac-with-id3))
|
||||
(set! fw (fw-add-filter fw flac-khz-bits))
|
||||
(set! fw (fw-add-filter fw flac-convert))
|
||||
(set! fw (fw-add-filter fw flac-picture))
|
||||
(set! fw (fw-add-filter fw to-opus))
|
||||
(set! fw (fw-add-filter fw deleter))
|
||||
(set! fw (fw-add-filter fw log-processed-file))
|
||||
(set! fw (fw-add-step fw adjust-ext))
|
||||
(set! fw (fw-add-step fw flac-with-id3))
|
||||
(set! fw (fw-add-step fw flac-khz-bits))
|
||||
(set! fw (fw-add-step fw flac-convert))
|
||||
(set! fw (fw-add-step fw flac-picture))
|
||||
(set! fw (fw-add-step fw to-opus))
|
||||
(set! fw (fw-add-step fw deleter))
|
||||
(set! fw (fw-add-step fw log-processed-file))
|
||||
(let loop ()
|
||||
(let-values (((base-path path info) (fw)))
|
||||
(if (eq? info #f)
|
||||
|
||||
Reference in New Issue
Block a user