Skip to content

Commit c2a95c0

Browse files
committed
Add support for multiple song artists
1 parent 7814831 commit c2a95c0

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

libmpdel.el

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ message from the server.")
184184
(album nil :read-only t)
185185
(genres nil :read-only t)
186186
(performers nil :read-only t)
187+
(artists nil :read-only t)
187188
(disc nil :read-only t)
188189
(date nil :read-only t)
189190
(id nil :read-only t)
@@ -222,7 +223,8 @@ message from the server.")
222223

223224
(cl-defgeneric libmpdel-artist (entity)
224225
"Return artist of ENTITY."
225-
(car (libmpdel-artists entity)))
226+
(or (car (libmpdel-artists entity))
227+
libmpdel--unknown-artist))
226228

227229
(cl-defmethod libmpdel-artists ((artist libmpdel-artist))
228230
"Return singleton list containing ARTIST."
@@ -232,9 +234,9 @@ message from the server.")
232234
"Return the ALBUM's artist."
233235
(libmpdel--album-artists album))
234236

235-
(cl-defmethod libmpdel-artist ((song libmpdel-song))
236-
"Return the SONG's artist."
237-
(libmpdel-artist (libmpdel--song-album song)))
237+
(cl-defmethod libmpdel-artists ((song libmpdel-song))
238+
"Return the SONG's artists."
239+
(libmpdel--song-artists song))
238240

239241
(defun libmpdel-album-name (entity)
240242
"Return album name of ENTITY."
@@ -406,6 +408,7 @@ If the SONG's name is nil, return the filename instead."
406408
:file (cdr (assq 'file song-data))
407409
:genres (libmpdel--genres-create (libmpdel-entries song-data 'Genre))
408410
:performers (libmpdel--artists-create (libmpdel-entries song-data 'Performer))
411+
:artists (libmpdel--artists-create (libmpdel-entries song-data 'Artist))
409412
:album (libmpdel--create-album-from-data song-data)
410413
:date (cdr (assq 'Date song-data))
411414
:disc (cdr (assq 'Disc song-data))
@@ -1004,7 +1007,12 @@ If HANDLER is nil, ignore response."
10041007

10051008
(cl-defmethod libmpdel-entity-to-criteria ((song libmpdel-song))
10061009
"Return search query matching SONG."
1007-
(format "%s title %S"
1010+
(format "%s %s title %S"
1011+
(string-join
1012+
(mapcar (lambda (artist)
1013+
(format "artist %S" (libmpdel-entity-name artist)))
1014+
(libmpdel-artists song))
1015+
" ")
10081016
(libmpdel-entity-to-criteria (libmpdel-album song))
10091017
(libmpdel-entity-name song)))
10101018

test/libmpdel-test.el

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
(ert-deftest libmpdel-test-artist-name ()
6464
(let* ((artist (libmpdel--artist-create :name "The Artist"))
6565
(album (libmpdel--album-create :name "The Album" :artists (list artist)))
66-
(song (libmpdel--song-create :name "The song" :album album)))
66+
(song (libmpdel--song-create :name "The song" :album album :artists (list artist))))
6767
(should (equal "The Artist" (libmpdel-artist-name artist)))
6868
(should (equal "The Artist" (libmpdel-artist-name album)))
6969
(should (equal "The Artist" (libmpdel-artist-name song)))))
@@ -127,6 +127,7 @@
127127
(should (equal "1970-01-01" (libmpdel-entity-date (libmpdel-album song))))
128128
(should (equal (list "The Genre") (mapcar #'libmpdel-entity-name (libmpdel-genres song))))
129129
(should (equal "The Album" (libmpdel-entity-name (libmpdel-album song))))
130+
(should (equal "The Artist" (libmpdel-entity-name (libmpdel-artist song))))
130131
(should (equal "The Albumartist" (libmpdel-entity-name (libmpdel-artist (libmpdel-album song)))))))
131132

132133
(ert-deftest libmpdel-test-current-playlist-p ()
@@ -290,7 +291,7 @@
290291
(Artist . "Art")))))
291292
(libmpdel-test--with-connection
292293
(libmpdel-playlist-add song 'current-playlist)
293-
(should (equal '("findadd albumartist \"Art\" albumartist \"Bart\" album \"A\" title \"S\"")
294+
(should (equal '("findadd artist \"Art\" albumartist \"Art\" albumartist \"Bart\" album \"A\" title \"S\"")
294295
(last commands))))))
295296

296297

0 commit comments

Comments
 (0)