From b3bff400e6c08ed4b10148c16f6de8914c294632 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Wed, 30 Jun 2010 12:44:46 +0200 Subject: [PATCH] MPD: Accept list without quotes around field arg --- docs/changes.rst | 2 ++ mopidy/mpd/frontend.py | 6 ++++++ tests/mpd/frontend_test.py | 8 ++++++++ 3 files changed, 16 insertions(+) diff --git a/docs/changes.rst b/docs/changes.rst index bc28d4b8..20ce474a 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -24,6 +24,8 @@ We got an updated :doc:`release roadmap `! as unknown commands. - ``command_list_end`` before ``command_list_start`` now returns unknown command error instead of crashing. + - ``list`` accepts field argument without quotes and capitalized, to work + with GMPC and ncmpc. 0.1.0a2 (2010-06-02) diff --git a/mopidy/mpd/frontend.py b/mopidy/mpd/frontend.py index f80c4e2b..ff62e674 100644 --- a/mopidy/mpd/frontend.py +++ b/mopidy/mpd/frontend.py @@ -640,7 +640,9 @@ class MpdFrontend(object): # TODO Add result to current playlist #return result + @handle_pattern(r'^list (?P[Aa]rtist)$') @handle_pattern(r'^list "(?P[Aa]rtist)"$') + @handle_pattern(r'^list (?Palbum)( "(?P[^"]+)")*$') @handle_pattern(r'^list "(?Palbum)"( "(?P[^"]+)")*$') def _music_db_list(self, field, artist=None): """ @@ -654,6 +656,10 @@ class MpdFrontend(object): ``ARTIST`` is an optional parameter when type is ``album``, this specifies to list albums by an artist. + *GMPC:* + + - does not add quotes around the field argument. + *ncmpc:* - does not add quotes around the field argument. diff --git a/tests/mpd/frontend_test.py b/tests/mpd/frontend_test.py index a6faab5d..5ed4242a 100644 --- a/tests/mpd/frontend_test.py +++ b/tests/mpd/frontend_test.py @@ -998,6 +998,14 @@ class MusicDatabaseHandlerTest(unittest.TestCase): result = self.h.handle_request(u'list "artist"') self.assert_(u'OK' in result) + def test_list_artist_without_quotes(self): + result = self.h.handle_request(u'list artist') + self.assert_(u'OK' in result) + + def test_list_artist_without_quotes_and_capitalized(self): + result = self.h.handle_request(u'list Artist') + self.assert_(u'OK' in result) + def test_list_artist_with_artist_should_fail(self): result = self.h.handle_request(u'list "artist" "anartist"') self.assertEqual(result[0], u'ACK [2@0] {list} incorrect arguments')