add correct href proc, planning

This commit is contained in:
mehbark 2024-04-15 00:23:22 -04:00
parent 6128cd44f6
commit 03f0b12ea9

View file

@ -12,21 +12,28 @@
; terrible, idc ; terrible, idc
; lossy! (not surprising) ; lossy! (not surprising)
; upcase for nice interning ; upcase for nice interning
(defun normalize-name (name) (defun track->href (track)
(ppcre:regex-replace-all (or (gethash "Directory" track)
"(^TRACK:|^-+|-+$)" (let ((r (copy-array (gethash "Track" track))))
(ppcre:regex-replace-all (setf r (ppcre:regex-replace-all " " r "-"))
"[^A-Z0-9]+" (setf r (ppcre:regex-replace-all "&" r "and"))
(sb-unicode:normalize-string (string-upcase name) :nfkd) (setf r (ppcre:regex-replace-all "[^a-zA-Z0-9-]" r ""))
"-") (setf r (ppcre:regex-replace-all "-{2,}" r ""))
"")) (setf r (ppcre:regex-replace-all "^-+|-+$" r ""))
(nstring-downcase r))))
;; (defun track-ref-p) (defun track->url (track)
(format nil "https://hsmusic.wiki/track/~a" (track->href track)))
;; (defun track-ref) ; let's just store the href because that's unambiguous and links are desirable anyway
(defun track-normalized-name (track) ; string name -> href
(normalize-name (gethash "Track" track))) ; so we don't have to research over and over
; there's ambiguity here! so consult only when not given a track:!
(defparameter hrefs (make-hash-table :test 'equal))
(loop for track in tracks
do (setf (gethash (gethash "Track" track) hrefs) (track->href track)))
; a -> b <-> a references b ; a -> b <-> a references b
; screw it! let's use symbols. why not? (LKFDSJKFDJ) ; screw it! let's use symbols. why not? (LKFDSJKFDJ)