From 73c74654d1ec04ae2555c7cfa237f6cf8bb0683c Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sat, 14 Apr 2018 23:58:48 +0200 Subject: [PATCH] - Better MPD filter management - you can now pass filters as arrays like ['artist', 'Led Zeppelin', 'title', 'Stairway To Heaven'] instead of relying on one single type-filter pair - Improved condition matching - don't skip the last condition token if there are still event tokens to add --- platypush/backend/http/static/js/music.mpd.js | 12 ++++-------- platypush/message/event/__init__.py | 2 +- platypush/plugins/music/mpd/__init__.py | 16 ++++++++-------- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/platypush/backend/http/static/js/music.mpd.js b/platypush/backend/http/static/js/music.mpd.js index 354f09eae7..6f646a325f 100644 --- a/platypush/backend/http/static/js/music.mpd.js +++ b/platypush/backend/http/static/js/music.mpd.js @@ -654,16 +654,14 @@ $(document).ready(function() { if ('any' in searchData) { args = { - type: 'any', - filter: searchData.any + filter: ['any', searchData.any] }; searchFilters.any = searchData.any; } else { if ('title' in searchData) { args = { - type: 'title', - filter: searchData.title + filter: ['title', searchData.title] }; searchFilters.title = searchData.title; @@ -671,8 +669,7 @@ $(document).ready(function() { if ('album' in searchData) { args = { - type: 'album', - filter: searchData.album + filter: ['album', searchData.album] }; searchFilters.album = searchData.album; @@ -680,8 +677,7 @@ $(document).ready(function() { if ('albumartist' in searchData) { args = { - type: 'albumartist', - filter: searchData.albumartist + filter: ['albumartist', searchData.albumartist] }; searchFilters.albumartist = searchData.albumartist; diff --git a/platypush/message/event/__init__.py b/platypush/message/event/__init__.py index 1e23c47656..17e90f2c24 100644 --- a/platypush/message/event/__init__.py +++ b/platypush/message/event/__init__.py @@ -137,7 +137,7 @@ class Event(Message): result.parsed_args[argname] += ' ' + event_token - if len(condition_tokens) == 1 \ + if (len(condition_tokens) == 1 and len(event_tokens) == 1) \ or (len(event_tokens) > 1 and len(condition_tokens) > 1 \ and event_tokens[1] == condition_tokens[1]): # Stop appending tokens to this argument, as the next diff --git a/platypush/plugins/music/mpd/__init__.py b/platypush/plugins/music/mpd/__init__.py index 427b983c84..1528d3ec0a 100644 --- a/platypush/plugins/music/mpd/__init__.py +++ b/platypush/plugins/music/mpd/__init__.py @@ -121,21 +121,21 @@ class MusicMpdPlugin(MusicPlugin): def plchanges(self, version): return Response(output=self.client.plchanges(version)) - def find(self, type, filter, *args, **kwargs): + def find(self, filter, *args, **kwargs): return Response( - output=self.client.find(type, filter, *args, **kwargs)) + output=self.client.find(*filter, *args, **kwargs)) - def findadd(self, type, filter, *args, **kwargs): + def findadd(self, filter, *args, **kwargs): return Response( - output=self.client.findadd(type, filter, *args, **kwargs)) + output=self.client.findadd(*filter, *args, **kwargs)) - def search(self, type, filter, *args, **kwargs): + def search(self, filter, *args, **kwargs): return Response( - output=self.client.search(type, filter, *args, **kwargs)) + output=self.client.search(*filter, *args, **kwargs)) - def searchadd(self, type, filter, *args, **kwargs): + def searchadd(self, filter, *args, **kwargs): return Response( - output=self.client.searchadd(type, filter, *args, **kwargs)) + output=self.client.searchadd(*filter, *args, **kwargs)) # vim:sw=4:ts=4:et: