Browse Source

Use `addid` to add elements to the current playlist when the id is available

In mopidy, search results always include the item identifier, which
works much more precisely to add them to a playlist via `addid` than
`findall`.
tags/v1.1.2
jao 4 months ago
parent
commit
97978da54e
2 changed files with 30 additions and 1 deletions
  1. +5
    -1
      libmpdel.el
  2. +25
    -0
      test/libmpdel-test.el

+ 5
- 1
libmpdel.el View File

@@ -895,7 +895,11 @@ If HANDLER is nil, ignore response."
ENTITY can also be a list of entities to add.")

(cl-defmethod libmpdel-playlist-add (entity (_ (eql current-playlist)))
(libmpdel-send-command `("findadd %s" ,(libmpdel-entity-to-criteria entity))))
(let ((id (libmpdel-entity-id entity)))
(libmpdel-send-command
(if id
`("addid %S" ,id)
`("findadd %s" ,(libmpdel-entity-to-criteria entity))))))

(cl-defmethod libmpdel-playlist-add (entity (stored-playlist libmpdel-stored-playlist))
(libmpdel-send-command


+ 25
- 0
test/libmpdel-test.el View File

@@ -247,6 +247,31 @@
(libmpdel--set-volume "50")
(should (string= (libmpdel-volume) "50")))

(ert-deftest libmpdel-test-playlist-add-sends-addid ()
(let ((gmusic-album
(libmpdel--create-song-from-data
'((Title . "Album: The Belly Of An Architect (Edicion 2007)")
(file . "gmusic:album:Bbtjr2k5632pgyabagduxcg3p4q")
(Album . "The Belly Of An Architect (Edicion 2007)")
(AlbumArtist . "Wim Mertens")
(Artist . "Wim Mertens")
(Date . "1983")
(X-AlbumUri "gmusic:album:Bbtjr2k5632pgyabagduxcg3p4q")))))
(libmpdel-test--with-connection
(libmpdel-playlist-add gmusic-album 'current-playlist)
(should (equal '("addid \"gmusic:album:Bbtjr2k5632pgyabagduxcg3p4q\"")
(last commands))))))

(ert-deftest libmpdel-test-playlist-add-sends-findadd ()
(let ((song (libmpdel--create-song-from-data
'((Title . "S")
(Album . "A")
(Artist . "Art")))))
(libmpdel-test--with-connection
(libmpdel-playlist-add song 'current-playlist)
(should (equal '("findadd artist \"Art\" album \"A\" title \"S\"")
(last commands))))))

;;; Public functions



Loading…
Cancel
Save