From f71731513672074b2d4fec88d7905b7ac29b48ab Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 15 Apr 2018 16:31:23 +0200 Subject: [PATCH] Added music.mpd.searchaddplaylist method --- platypush/plugins/music/mpd/__init__.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/platypush/plugins/music/mpd/__init__.py b/platypush/plugins/music/mpd/__init__.py index e73a3e9e2a..18fc8ae208 100644 --- a/platypush/plugins/music/mpd/__init__.py +++ b/platypush/plugins/music/mpd/__init__.py @@ -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))