diff --git a/platypush/message/event/__init__.py b/platypush/message/event/__init__.py index 17e90f2c2..561ab2e84 100644 --- a/platypush/message/event/__init__.py +++ b/platypush/message/event/__init__.py @@ -118,12 +118,12 @@ class Event(Message): if event_token == condition_token: event_tokens.pop(0) condition_tokens.pop(0) - result.score += 1 + result.score += 1.5 elif re.search(condition_token, event_token): m = re.search('({})'.format(condition_token), event_token) if m.group(1): event_tokens.pop(0) - result.score += 1 + result.score += 1.25 condition_tokens.pop(0) else: @@ -132,7 +132,7 @@ class Event(Message): argname = m.group(1) if argname not in result.parsed_args: result.parsed_args[argname] = event_token - result.score += 1 + result.score += 1.0 else: result.parsed_args[argname] += ' ' + event_token @@ -146,7 +146,7 @@ class Event(Message): event_tokens.pop(0) else: - result.score -= 1 + result.score -= 1.0 event_tokens.pop(0) # It's a match if all the tokens in the condition string have been satisfied diff --git a/platypush/plugins/music/mpd/__init__.py b/platypush/plugins/music/mpd/__init__.py index 1528d3ec0..e73a3e9e2 100644 --- a/platypush/plugins/music/mpd/__init__.py +++ b/platypush/plugins/music/mpd/__init__.py @@ -130,8 +130,13 @@ class MusicMpdPlugin(MusicPlugin): output=self.client.findadd(*filter, *args, **kwargs)) def search(self, filter, *args, **kwargs): - return Response( - output=self.client.search(*filter, *args, **kwargs)) + items = self.client.search(*filter, *args, **kwargs) + + # Spotify results first + items = sorted(items, key=lambda item: + 0 if item['file'].startswith('spotify:') else 1) + + return Response(output=items) def searchadd(self, filter, *args, **kwargs): return Response(