Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions libmpdel.el
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ message from the server.")
(track nil :read-only t)
(file nil :read-only t)
(album nil :read-only t)
(performers nil :read-only t)
(disc nil :read-only t)
(date nil :read-only t)
(id nil :read-only t)
Expand Down Expand Up @@ -235,6 +236,10 @@ message from the server.")
"Return SONG's album."
(libmpdel--song-album song))

(cl-defmethod libmpdel-performers ((song libmpdel-song))
"Return SONG's performers."
(libmpdel--song-performers song))

(cl-defgeneric libmpdel-entity-name (entity)
"Return the name of ENTITY.")

Expand Down Expand Up @@ -339,12 +344,19 @@ If the SONG's name is nil, return the filename instead."
(when (and (stringp pos) (not (string= pos "")))
(string-to-number pos))))

(defun libmpdel--artists-create (artist-names)
"Return a list of artists whose names are ARTIST-NAMES."
(mapcar (lambda (name)
(libmpdel--artist-create :name name))
artist-names))

(defun libmpdel--create-song-from-data (song-data)
"Return a song from SONG-DATA, a server's response."
(libmpdel--song-create
:name (cdr (assq 'Title song-data))
:track (cdr (assq 'Track song-data))
:file (cdr (assq 'file song-data))
:performers (libmpdel--artists-create (libmpdel-entries song-data 'Performer))
:album (libmpdel--album-create
:name (cdr (assq 'Album song-data))
:artist (libmpdel--artist-create :name (cdr (assq 'Artist song-data))))
Expand Down
5 changes: 5 additions & 0 deletions test/libmpdel-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,15 @@
'((Title . "The song")
(file . "foo/song.ogg")
(Album . "The Album")
(Performer . "The Violinist")
(Performer . "The Pianist")
(Performer . "The Singer")
(Artist . "The Artist")))))
(should (equal "The song" (libmpdel-entity-name song)))
(should (equal "foo/song.ogg" (libmpdel-song-file song)))
(should (equal "The Album" (libmpdel-entity-name (libmpdel-album song))))
(should (equal (list "The Violinist" "The Pianist" "The Singer")
(mapcar #'libmpdel-entity-name (libmpdel-performers song))))
(should (equal "The Artist" (libmpdel-entity-name (libmpdel-artist (libmpdel-album song)))))))

(ert-deftest libmpdel-test-current-playlist-p ()
Expand Down