43a3ac556a
Note: not the actual initial commit. I swear I will stop repeatedly force pushing to this single commit eventually ok.
30 lines
1 KiB
Common Lisp
30 lines
1 KiB
Common Lisp
(asdf:load-system :alexandria)
|
|
(asdf:load-system :cl-fad)
|
|
|
|
(uiop:define-package #:sync-music
|
|
(:use #:cl #:alexandria)
|
|
(:export #:sync-music #:main))
|
|
|
|
(in-package #:sync-music)
|
|
|
|
(defvar *dry-run-p* nil)
|
|
(defvar *cleanupp* nil)
|
|
|
|
(defun translate-file-name (file)
|
|
(when (cl-fad:directory-pathname-p file)
|
|
(return file))
|
|
(switch ((pathname-type file) :test #'string-equal)
|
|
("flac" (make-pathname :name (pathname-name file) :type "ogg"))
|
|
(("mp3" "ogg" "cue" "m3u" "m3u8") file)))
|
|
|
|
(defun sync-directory (directory destination)
|
|
(loop :for file :in (cl-fad:list-directory directory :follow-symlinks t)
|
|
:for file-destination := (merge-pathnames destination (translate-file-name file))
|
|
:when file-destination
|
|
:collect file-destination :into destinations))
|
|
|
|
(defun sync-music (destination &key (music-directory #P"~/Music/"))
|
|
(unless (cl-fad:directory-exists-p music-directory)
|
|
(error "Music directory `~A` does not exist!" music-directory))
|
|
(sync-directory music-directory destination))
|