From 99eed0e6b8da06de8c5259299b7f1fe87c6ceec0 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Tue, 9 Jul 2013 11:22:45 +0200 Subject: [PATCH] mpd: Allow 'count' without quotes around the 'tag' param Fix hechtus/mopidy-gmusic#1 --- mopidy/frontends/mpd/protocol/music_db.py | 6 +++++- tests/frontends/mpd/protocol/music_db_test.py | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/mopidy/frontends/mpd/protocol/music_db.py b/mopidy/frontends/mpd/protocol/music_db.py index ff79c33a..4eb0e47d 100644 --- a/mopidy/frontends/mpd/protocol/music_db.py +++ b/mopidy/frontends/mpd/protocol/music_db.py @@ -39,7 +39,7 @@ def _artist_as_track(artist): artists=[artist]) -@handle_request(r'^count "(?P[^"]+)" "(?P[^"]*)"$') +@handle_request(r'^count "?(?P[^"]+)"? "(?P[^"]*)"$') def count(context, tag, needle): """ *musicpd.org, music database section:* @@ -48,6 +48,10 @@ def count(context, tag, needle): Counts the number of songs and their total playtime in the db matching ``TAG`` exactly. + + *GMPC:* + + - does not add quotes around the tag argument. """ return [('songs', 0), ('playtime', 0)] # TODO diff --git a/tests/frontends/mpd/protocol/music_db_test.py b/tests/frontends/mpd/protocol/music_db_test.py index d16a636b..a155072e 100644 --- a/tests/frontends/mpd/protocol/music_db_test.py +++ b/tests/frontends/mpd/protocol/music_db_test.py @@ -12,6 +12,12 @@ class MusicDatabaseHandlerTest(protocol.BaseTestCase): self.assertInResponse('playtime: 0') self.assertInResponse('OK') + def test_count_without_quotes(self): + self.sendRequest('count tag "needle"') + self.assertInResponse('songs: 0') + self.assertInResponse('playtime: 0') + self.assertInResponse('OK') + def test_findadd(self): self.backend.library.dummy_find_exact_result = SearchResult( tracks=[Track(uri='dummy:a', name='A')])