Added music.mpd.searchaddplaylist method

This commit is contained in:
Fabio Manganiello 2018-04-15 16:31:23 +02:00
parent 87fb8855b7
commit f717315136

View file

@ -121,6 +121,20 @@ class MusicMpdPlugin(MusicPlugin):
def plchanges(self, version):
return Response(output=self.client.plchanges(version))
def searchaddplaylist(self, name):
playlists = list(map(lambda _: _['playlist'],
filter(lambda playlist:
name.lower() in playlist['playlist'].lower(),
self.client.listplaylists())))
if len(playlists):
self.client.clear()
self.client.load(playlists[0])
self.client.play()
return Response(output={'playlist': playlists[0]})
return Response(output={})
def find(self, filter, *args, **kwargs):
return Response(
output=self.client.find(*filter, *args, **kwargs))