diff options
Diffstat (limited to 'downloader.lisp')
-rw-r--r-- | downloader.lisp | 23 |
1 files changed, 23 insertions, 0 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))) |