From 613ed9bdf8f826bb77ad4b0b708e176b2c775f3b Mon Sep 17 00:00:00 2001 From: Grant Shangreaux Date: Wed, 15 Feb 2023 07:54:46 -0600 Subject: WIP: adding a few defuns for downloading audio tracks direct --- downloader.lisp | 23 +++++++++++++++++++++++ vampire.asd | 4 +++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/downloader.lisp b/downloader.lisp index e9b8ffb..043fbe7 100644 --- a/downloader.lisp +++ b/downloader.lisp @@ -78,3 +78,26 @@ media-dir))) (uiop:copy-file downloaded file) (new-track file info))))) + +;; TODO: handle servers that don't respond to HEAD +(defun url-content-type (url) + (multiple-value-bind (body status headers) (drakma:http-request url :method :head) + (drakma:header-value :content-type headers))) + +(defun audio-url-p (url) + (equal "audio" (first (cl-ppcre:split "/" (url-content-type url))))) + +(defun audio-filename (url) + (quri:url-decode (first (last (cl-ppcre:split "/" url))))) + +(defun audio-file-trackinfo (url) + (let* ((filename (audio-filename url)))) + (with-plist ((url :|url|)) (first thumbs) + (list + :source source + :title (or track-title title) + :album album + :codec codec + :artist artist + :duration dur + :thumb-url url))) diff --git a/vampire.asd b/vampire.asd index 9014aa8..962c020 100644 --- a/vampire.asd +++ b/vampire.asd @@ -13,9 +13,11 @@ #:legion #:defclass-std #:derrida + #:drakma #:ironclad #:jonathan - #:swank + #:quri + #:swank #:zippy) :components ((:file "hunchentoot-handle-static-file") (:file "package") -- cgit v1.2.3