Compare commits

...

2 Commits

Author SHA1 Message Date
  Leon Rische d909e1faa0 Document `search-criteria-list` in readme 2 years ago
  Leon Rische 92d6eed35b Add support for searches with multiple criteria 2 years ago
2 changed files with 42 additions and 12 deletions
Split View
  1. +13
    -12
      README.org
  2. +29
    -0
      libmpdel.el

+ 13
- 12
README.org View File

@ -42,18 +42,19 @@ a look at it.
The library is implemented around a set of entities.
| *Name* | *Type* | *Fields* | *Description* |
|------------------+-----------+----------------------+--------------------------------------------------|
| song | structure | name, album, file, … | |
| album | structure | name, artist | |
| artist | structure | name | |
| stored-playlist | structure | name | A named user-specified sequence of songs |
| search-criteria | structure | type, what | Read the [[https://www.musicpd.org/doc/protocol/database.html][protocol documentation]] |
|------------------+-----------+----------------------+--------------------------------------------------|
| artists | symbol | /none/ | Represent the set of all artists |
| albums | symbol | /none/ | Represent the set of all albums |
| current-playlist | symbol | /none/ | Represent the currently played sequence of songs |
| stored-playlists | symbol | /none/ | Represent the set of all stored playlists |
| *Name* | *Type* | *Fields* | *Description* |
|----------------------+-----------+----------------------+--------------------------------------------------|
| song | structure | name, album, file, … | |
| album | structure | name, artist | |
| artist | structure | name | |
| stored-playlist | structure | name | A named user-specified sequence of songs |
| search-criteria | structure | type, what | Read the [[https://www.musicpd.org/doc/protocol/database.html][protocol documentation]] |
| search-criteria-list | structure | criteria | A list of multiple ~search-criteria~ |
|----------------------+-----------+----------------------+--------------------------------------------------|
| artists | symbol | /none/ | Represent the set of all artists |
| albums | symbol | /none/ | Represent the set of all albums |
| current-playlist | symbol | /none/ | Represent the currently played sequence of songs |
| stored-playlists | symbol | /none/ | Represent the set of all stored playlists |
Many functions in MPDel work on several kinds of entities (e.g.,
~libmpdel-list~). These methods are implemented with ~cl-defgeneric~


+ 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