|
|
@@ -14,38 +14,42 @@
|
|
|
(loop for (path-prefix . url-prefix) in *path-url-mappings*
|
|
|
do (multiple-value-bind (foundp suffix) (starts-with-subseq path-prefix path :return-suffix t)
|
|
|
(when foundp
|
|
|
- (return-from get-url (concatenate 'string url-prefix suffix))))))))
|
|
|
+ (return-from get-url (concatenate 'string url-prefix
|
|
|
+ (format nil "~{~A~^/~}"
|
|
|
+ (mapcar #'quri:url-encode
|
|
|
+ (split-sequence:split-sequence #\/ suffix)))))))))))
|
|
|
|
|
|
-(declaim (inline js-null))
|
|
|
-(defun js-null (obj)
|
|
|
- (if obj obj
|
|
|
- :null))
|
|
|
+(defmacro maybe-key-value (key value)
|
|
|
+ `(when ,value
|
|
|
+ (write-key-value ,key ,value)))
|
|
|
|
|
|
(defmethod %to-json ((album album))
|
|
|
(with-object
|
|
|
- (write-key-value "id" (js-null (album-id album)))
|
|
|
- (write-key-value "artist" (js-null (album-artist album)))
|
|
|
- (write-key-value "year" (js-null (album-year album)))
|
|
|
- (write-key-value "album" (js-null (album-album album)))
|
|
|
- (write-key-value "original_date" (js-null (album-original-date album)))
|
|
|
- (write-key-value "genre" (js-null (album-genre album)))
|
|
|
- (write-key-value "type" (js-null (album-type album)))
|
|
|
- (write-key-value "status" (js-null (album-status album)))
|
|
|
- (write-key-value "mb_id" (js-null (album-mb-id album)))
|
|
|
- (write-key-value "track_count" (js-null (album-track-count album)))
|
|
|
- (write-key-value "total_duration" (js-null (album-total-duration album)))
|
|
|
- (write-key-value "cover" (js-null (get-url (album-cover album))))))
|
|
|
+ (maybe-key-value "id" (album-id album))
|
|
|
+ (maybe-key-value "artist" (album-artist album))
|
|
|
+ (maybe-key-value "year" (album-year album))
|
|
|
+ (maybe-key-value "album" (album-album album))
|
|
|
+ (maybe-key-value "original_date" (album-original-date album))
|
|
|
+ (maybe-key-value "publisher" (album-publisher album))
|
|
|
+ (maybe-key-value "country" (album-country album))
|
|
|
+ (maybe-key-value "genre" (album-genre album))
|
|
|
+ (maybe-key-value "type" (album-type album))
|
|
|
+ (maybe-key-value "status" (album-status album))
|
|
|
+ (maybe-key-value "mb_id" (album-mb-id album))
|
|
|
+ (maybe-key-value "track_count" (album-track-count album))
|
|
|
+ (maybe-key-value "total_duration" (album-total-duration album))
|
|
|
+ (maybe-key-value "cover" (get-url (album-cover album)))))
|
|
|
|
|
|
(defmethod %to-json ((track track))
|
|
|
(with-object
|
|
|
- (write-key-value "artist" (js-null (track-artist track)))
|
|
|
- (write-key-value "album" (js-null (album-album (track-album track))))
|
|
|
- (write-key-value "no" (js-null (clear-track-no (track-no track))))
|
|
|
- (write-key-value "title" (js-null (track-title track)))
|
|
|
- (write-key-value "bit_rate" (js-null (track-bit-rate track)))
|
|
|
- (write-key-value "vbr" (if (track-is-vbr track) :true :false))
|
|
|
- (write-key-value "duration" (js-null (track-duration track)))
|
|
|
- (write-key-value "url" (js-null (get-url (track-path track))))))
|
|
|
+ (maybe-key-value "artist" (track-artist track))
|
|
|
+ (maybe-key-value "album" (album-album (track-album track)))
|
|
|
+ (maybe-key-value "no" (clear-track-no (track-no track)))
|
|
|
+ (maybe-key-value "title" (track-title track))
|
|
|
+ (maybe-key-value "bit_rate" (track-bit-rate track))
|
|
|
+ (maybe-key-value "vbr" (if (track-is-vbr track) :true :false))
|
|
|
+ (maybe-key-value "duration" (track-duration track))
|
|
|
+ (maybe-key-value "url" (get-url (track-path track)))))
|
|
|
|
|
|
(defparameter +400+ '(400 nil #.(trivial-utf-8:string-to-utf-8-bytes "400")))
|
|
|
(defparameter +404+ '(404 nil #.(trivial-utf-8:string-to-utf-8-bytes "404")))
|
|
|
@@ -60,7 +64,7 @@
|
|
|
(defun get-category-list (params)
|
|
|
(declare #.*standard-optimize-settings*
|
|
|
(ignore params))
|
|
|
- (200-json '("artist" "year" "album" "genre" "type" "status")))
|
|
|
+ (200-json '("artist" "year" "album" "publisher" "country" "genre" "type" "status")))
|
|
|
|
|
|
(let ((db-package (find-package :chad-music.db)))
|
|
|
(defun getsym (place indicator)
|
|
|
@@ -85,7 +89,7 @@
|
|
|
(defun get-restrictions (query-params)
|
|
|
(declare #.*standard-optimize-settings*
|
|
|
(type list query-params))
|
|
|
- (loop for key in '(artist year album genre type status)
|
|
|
+ (loop for key in '(artist year album publisher country genre type status)
|
|
|
for value = (aget query-params (string-downcase (symbol-name key)))
|
|
|
when value collect (cons key (case key
|
|
|
(year (parse-integer value :junk-allowed t))
|