aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGrant Shangreaux <shoshin@cicadas.surf>2023-02-15 07:54:46 -0600
committerGrant Shangreaux <shoshin@cicadas.surf>2023-02-15 07:54:46 -0600
commit613ed9bdf8f826bb77ad4b0b708e176b2c775f3b (patch)
tree2738f391a3ff076c8757abb882daf65718d48f37
parent973dcf81dddee6e7d6c1bbf430ed3b4cb988ab27 (diff)
WIP: adding a few defuns for downloading audio tracks directdirect-download-audio-files
-rw-r--r--downloader.lisp23
-rw-r--r--vampire.asd4
2 files changed, 26 insertions, 1 deletions
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")