aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--playlist.lisp32
1 files changed, 19 insertions, 13 deletions
diff --git a/playlist.lisp b/playlist.lisp
index a91da0d..3579c83 100644
--- a/playlist.lisp
+++ b/playlist.lisp
@@ -36,6 +36,9 @@
(setf (playlist-tracks pl) newlist
(track-playlists track) (delete pl (track-playlists track)
:test #'eq :count 1))))
+
+(defun track-with-source (source)
+ (find source (store-objects-with-class 'track) :test #'string-equal :key 'track-source))
;;; TRANSACTIONS
(defun append-track (pl tr)
@@ -277,20 +280,23 @@
(let* ((url
(value url-input))
(notice
- (create-p notice-area :content (format nil "... Fetching ~a" url))))
+ (create-p notice-area :content (format nil "... Fetching ~a" url)))
+ (on-ok
+ (lambda (track)
+ (destroy notice)
+ (append-track pl track)
+ (append-track-list-item parent track))))
(setf (value url-input) "")
- (add-fetch-track-job
- url
- (lambda (track)
- (destroy notice)
- (append-track pl track)
- (append-track-list-item parent track))
- (lambda (err)
- (destroy notice)
- (format t "~a" err)
- (alert (window (connection-body parent))
- (format nil "Error while fetching track at: ~a~%"
- url)))))))))
+ (if-let (track (track-with-source url))
+ (funcall on-ok track)
+ (add-fetch-track-job
+ url on-ok
+ (lambda (err)
+ (destroy notice)
+ (format t "~a" err)
+ (alert (window (connection-body parent))
+ (format nil "Error while fetching track at: ~a~%"
+ url))))))))))
(defun playlist-key-from-url (url)
(first (last (ppcre:split "/" (nth 4 (multiple-value-list (quri:parse-uri url)))))))