small bug fixes and packaging

This commit is contained in:
2026-06-28 13:50:48 +02:00
parent 14bf3a1da1
commit 558895b578
6 changed files with 97 additions and 70 deletions
+8
View File
@@ -0,0 +1,8 @@
all:
@echo "make arch"
arch:
(cd ..; tar czf ../audio-manager.tar.gz --exclude .git --exclude "*.bak" --exclude "*.*~" audio-library-manager)
+4
View File
@@ -0,0 +1,4 @@
#!/bin/bash
VERSION=`cat info.rkt | grep version | sed -e 's/^[^0-9]*//' -e s'/[^0-9]*$//'`
echo VERSION=$VERSION
(cd ..; tar czf audio-manager-$VERSION.tar.gz --exclude .git --exclude "*.bak" --exclude "*.*~" audio-library-manager)
+17 -9
View File
@@ -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,17 +207,16 @@
)
(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)
(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))
(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)))
@@ -241,7 +241,12 @@
)
)
)
(begin ; copy files rechtstreeks indien nodig
(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))])
@@ -254,19 +259,18 @@
(set! copied-files (+ copied-files 1)))))
)
)
)
)
(values base-path path info))
(define (deleter base-path path info)
(when (deleted? info)
(let ((path-part (get-path-part info)))
(unless (eq? path-part #f)
(let ((rm-path (if (flac? info)
(let ((rm-path (build-path opus-path
(if (flac? path info)
(path-replace-extension
(build-path opus-path path-part)
#".opus")
(build-path opus-path path-part))))
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 ()
+2 -5
View File
@@ -2,15 +2,12 @@
(define collection "audio-library-manager")
(define deps '("base"
"db-lib"
"keystore"
"racket-audio"
"simple-ini"
"simple-log"
"smtp"
"racket-sprintf"))
))
(define scribblings '(("scribblings/audio-library-manager.scrbl" ())))
(define build-deps '("rackunit-lib" "scribble-lib" "racket-doc"))
(define pkg-desc "Audio library maintenance tools for FLAC and Opus trees")
(define version "0.1.5")
(define version "0.2.2")
(define pkg-authors '(hans-dijkema))
-5
View File
@@ -9,9 +9,4 @@
fatal-am
sync-log-am)
(define log-defined #f)
(displayln (format "log-defined: ~a" log-defined))
(set! log-defined #t)
(sl-def-log audio-manager am)
+23 -8
View File
@@ -4,25 +4,40 @@
net/head
simple-ini)
(provide mail-report)
(provide mail-report
check-mail-config)
(define (mail-report ini subject report)
(let* ((get (λ (key msg)
(define (get ini key msg)
(let ((v (ini-get ini 'mail key 'nil)))
(when (eq? v 'nil)
(error msg))
v)))
(from (get 'from "configure from address as name <email>"))
(to (get 'to "configure to address as name <email>"))
(server (get 'server "configure the smtp server"))
v))
(define (get-config ini)
(let* ((from (get ini 'from "configure from address as name <email>"))
(to (get ini 'to "configure to address as name <email>"))
(server (get ini 'server "configure the smtp server"))
(port (ini-get ini 'mail 'port 25))
(user (ini-get ini 'mail 'user #f))
(passwd (ini-get ini 'mail 'passwd #f))
)
(values from to server port user passwd)))
(define (mail-report ini subject report)
(let-values (((from to server port user auth) (get-config ini)))
(let* ((hdr (standard-message-header from (list to) '() '() subject)))
(smtp-send-message server from (list to) hdr
(if (list? report) report (list report))
#:port-no port)
#:port-no port
#:auth-user user
#:auth-pwd passwd
)
)
)
)
(define (check-mail-config ini)
(let-values (((from to server port user passwd) (get-config ini)))
#t))