2024-04-14 21:43:35 -04:00
|
|
|
(ql:quickload '(:cl-yaml :alexandria :cl-ppcre))
|
2024-04-14 21:21:53 -04:00
|
|
|
(defpackage :hsmusic
|
2024-04-14 21:43:35 -04:00
|
|
|
(:use :common-lisp :alexandria))
|
2024-04-14 21:21:53 -04:00
|
|
|
(in-package :hsmusic)
|
|
|
|
|
|
|
|
(defparameter tracks
|
|
|
|
(loop for path in (directory #p"album/*.yaml")
|
|
|
|
appending (loop for entry in (yaml:parse path :multi-document-p t)
|
|
|
|
when (and (not (symbolp entry)) (gethash "Track" entry))
|
|
|
|
collect entry)))
|
|
|
|
|
|
|
|
; terrible, idc
|
|
|
|
; lossy! (not surprising)
|
|
|
|
(defun normalize-name (name)
|
|
|
|
(ppcre:regex-replace-all
|
|
|
|
"(^track:|\W)"
|
|
|
|
(sb-unicode:normalize-string (string-downcase name) :nfkd)
|
|
|
|
""))
|
|
|
|
|
2024-04-14 21:43:35 -04:00
|
|
|
(defun track-normalized-name (track)
|
|
|
|
(normalize-name (gethash "Track" track)))
|
2024-04-14 21:21:53 -04:00
|
|
|
|
2024-04-14 21:43:35 -04:00
|
|
|
(defparameter edges (make-hash-table :test 'equal))
|
|
|
|
; (from . to)
|
|
|
|
; conceptually, from -> to
|
2024-04-14 21:21:53 -04:00
|
|
|
|
2024-04-14 21:43:35 -04:00
|
|
|
(loop for track in tracks
|
|
|
|
do (let ((name (track-normalized-name track)))
|
|
|
|
(loop for ref in (append (gethash "Referenced Tracks" track) (gethash "Sampled Tracks" track))
|
|
|
|
do (setf (gethash (cons (normalize-name ref) name) edges) t))))
|