small bug fixes and packaging
This commit is contained in:
+56
-48
@@ -18,6 +18,7 @@
|
||||
(define (audio-manager music-path opus-path #:log-level [log-level 'debug])
|
||||
(let* ((ini-config-file (build-path music-path ".audio-manager.ini"))
|
||||
(ini (file->ini ini-config-file))
|
||||
(mail-oke (check-mail-config))
|
||||
(report-flacs-with-id3 "FLAC files with id3 tags\n\n")
|
||||
(report-flac "")
|
||||
(report-opus "")
|
||||
@@ -206,54 +207,56 @@
|
||||
)
|
||||
(values base-path path info))
|
||||
|
||||
;; Converteer naar opus indien nodig en flac.
|
||||
(define (to-opus base-path path info)
|
||||
(when (or (needs-processing? path info)
|
||||
(needs-copying? info))
|
||||
(if (flac? path info)
|
||||
(let ((path-part (get-path-part info)))
|
||||
(unless (eq? path-part #f)
|
||||
(let ((opus-file (path-replace-extension
|
||||
(build-path opus-path path-part)
|
||||
#".opus")))
|
||||
(set! processed-opus (+ processed-opus 1))
|
||||
(unless (file-exists? opus-file)
|
||||
(info-am "Converting flac to opus: ~a" opus-file)
|
||||
(rep-opus
|
||||
(format "Converting flac to opus: ~a" (basename opus-file)))
|
||||
(with-handlers ([exn? (λ (e)
|
||||
(set! failed-converts (+ failed-converts 1))
|
||||
(err-am "Conversion of ~a: ~a" path e))])
|
||||
(unless (directory-exists? (basedir opus-file))
|
||||
(make-directory* (basedir opus-file)))
|
||||
(if (convert-to-opus path opus-file ini)
|
||||
(begin
|
||||
(set! converted-files (+ converted-files 1))
|
||||
(info-am " Converted")
|
||||
)
|
||||
(begin
|
||||
(info-am " CONVERSION PROBLEM")
|
||||
(rep-opus " Conversion failed!")
|
||||
(set! failed-converts (+ failed-converts 1))
|
||||
)
|
||||
)
|
||||
(when (and (needs-processing? path info)
|
||||
(flac? path info))
|
||||
(let ((path-part (get-path-part info)))
|
||||
(unless (eq? path-part #f)
|
||||
(let ((opus-file (path-replace-extension
|
||||
(build-path opus-path path-part)
|
||||
#".opus")))
|
||||
(set! processed-opus (+ processed-opus 1))
|
||||
(info-am "Converting flac to opus: ~a" opus-file)
|
||||
(rep-opus
|
||||
(format "Converting flac to opus: ~a" (basename opus-file)))
|
||||
(with-handlers ([exn? (λ (e)
|
||||
(set! failed-converts (+ failed-converts 1))
|
||||
(err-am "Conversion of ~a: ~a" path e))])
|
||||
(unless (directory-exists? (basedir opus-file))
|
||||
(make-directory* (basedir opus-file)))
|
||||
(if (convert-to-opus path opus-file ini)
|
||||
(begin
|
||||
(set! converted-files (+ converted-files 1))
|
||||
(info-am " Converted")
|
||||
)
|
||||
(begin
|
||||
(info-am " CONVERSION PROBLEM")
|
||||
(rep-opus " Conversion failed!")
|
||||
(set! failed-converts (+ failed-converts 1))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(begin ; copy files rechtstreeks indien nodig
|
||||
(with-handlers ([exn? (λ (e)
|
||||
(set! failed-copies (+ failed-copies 1))
|
||||
(err-am "Copy file ~a: ~a" path e))])
|
||||
(let ((path-part (get-path-part info)))
|
||||
(unless (eq? path-part #f)
|
||||
(let ((dest-path (build-path opus-path path-part)))
|
||||
(unless (directory-exists? (basedir dest-path))
|
||||
(make-directory* (basedir dest-path)))
|
||||
(copy-file path dest-path #:exists-ok? #t)
|
||||
(set! copied-files (+ copied-files 1)))))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(values base-path path info))
|
||||
|
||||
;; Kopieer bestanden rechtstreeks indien nodig en geen flac
|
||||
(define (copy-other base-path path info)
|
||||
(when (and (needs-copying? info)
|
||||
(not (flac? path info)))
|
||||
(with-handlers ([exn? (λ (e)
|
||||
(set! failed-copies (+ failed-copies 1))
|
||||
(err-am "Copy file ~a: ~a" path e))])
|
||||
(let ((path-part (get-path-part info)))
|
||||
(unless (eq? path-part #f)
|
||||
(let ((dest-path (build-path opus-path path-part)))
|
||||
(unless (directory-exists? (basedir dest-path))
|
||||
(make-directory* (basedir dest-path)))
|
||||
(copy-file path dest-path #:exists-ok? #t)
|
||||
(set! copied-files (+ copied-files 1)))))
|
||||
)
|
||||
)
|
||||
(values base-path path info))
|
||||
@@ -262,11 +265,12 @@
|
||||
(when (deleted? info)
|
||||
(let ((path-part (get-path-part info)))
|
||||
(unless (eq? path-part #f)
|
||||
(let ((rm-path (if (flac? info)
|
||||
(path-replace-extension
|
||||
(build-path opus-path path-part)
|
||||
#".opus")
|
||||
(build-path opus-path path-part))))
|
||||
(let ((rm-path (build-path opus-path
|
||||
(if (flac? path info)
|
||||
(path-replace-extension
|
||||
(build-path opus-path path-part)
|
||||
#".opus")
|
||||
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))
|
||||
@@ -360,12 +364,16 @@
|
||||
(sl-set-log-level log-level)
|
||||
|
||||
(let ((fw (make-file-admin music-path file-db-hash)))
|
||||
;; Enrichement phase
|
||||
(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))
|
||||
;; Conversion phase
|
||||
(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 copy-other))
|
||||
;; Cleanup/Logging phase
|
||||
(set! fw (fw-add-step fw deleter))
|
||||
(set! fw (fw-add-step fw log-processed-file))
|
||||
(let loop ()
|
||||
|
||||
Reference in New Issue
Block a user