Browse Source

Add support for searches with multiple criteria

master
Leon Rische 2 years ago
parent
commit
92d6eed35b
1 changed files with 29 additions and 0 deletions
  1. +29
    -0
      libmpdel.el

+ 29
- 0
libmpdel.el View File

@ -179,6 +179,11 @@ message from the server.")
(type nil :read-only t)
(what nil :read-only t))
(cl-defstruct (libmpdel-search-criteria-list
(:constructor libmpdel-search-criteria-list-create)
(:conc-name libmpdel--search-criteria-list-))
(criteria nil :read-only t))
(defun libmpdel-artist-name (entity)
"Return artist name of ENTITY."
(libmpdel--artist-name (libmpdel-artist entity)))
@ -234,6 +239,16 @@ message from the server.")
(libmpdel--search-criteria-type search-criteria)
(libmpdel--search-criteria-what search-criteria)))
(cl-defmethod libmpdel-entity-name ((search-criteria libmpdel-search-criteria-list))
(concat "search "
(mapconcat
(lambda (search-criteria)
(format "%s: \"%s\""
(libmpdel--search-criteria-type search-criteria)
(libmpdel--search-criteria-what search-criteria)))
(libmpdel--search-criteria-list-criteria search-criteria)
", ")))
(cl-defgeneric libmpdel-entity-parent (_entity)
"Return parent of ENTITY."
nil)
@ -866,6 +881,20 @@ If HANDLER is nil, ignore response."
(lambda (data)
(funcall function (libmpdel--create-songs-from-data data)))))
(cl-defmethod libmpdel-list-songs ((search-criteria-list libmpdel-search-criteria-list) function)
(libmpdel-send-command
(concat "search "
(mapconcat
(lambda (search-criteria)
(format
"%s %S"
(libmpdel--search-criteria-type search-criteria)
(libmpdel--search-criteria-what search-criteria)))
(libmpdel--search-criteria-list-criteria search-criteria-list)
" "))
(lambda (data)
(funcall function (libmpdel--create-songs-from-data data)))))
(cl-defmethod libmpdel-list-songs ((song libmpdel-song) function)
(funcall function (list song)))


Loading…
Cancel
Save