From 539340757199871af92d16fdea03eb49e56c19fa Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Fri, 13 Aug 2010 13:04:56 +0200 Subject: [PATCH 1/2] MPD: Support 'plchanges' without quotes to work with BitMPC --- docs/changes.rst | 1 + mopidy/frontends/mpd/protocol/current_playlist.py | 1 + tests/frontends/mpd/current_playlist_test.py | 9 +++++++++ 3 files changed, 11 insertions(+) diff --git a/docs/changes.rst b/docs/changes.rst index 70d9390f..a59a2b5a 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -25,6 +25,7 @@ Another great release. - Fixed ``play "-1"`` and ``playid "-1"`` behaviour when playlist is empty. - Support ``plchanges "-1"`` to work better with MPDroid. - Support ``pause`` without arguments to work better with MPDroid. + - Support ``plchanges`` without quotes to work better with BitMPC. - Backend API: diff --git a/mopidy/frontends/mpd/protocol/current_playlist.py b/mopidy/frontends/mpd/protocol/current_playlist.py index 76ae62ef..1c1c1764 100644 --- a/mopidy/frontends/mpd/protocol/current_playlist.py +++ b/mopidy/frontends/mpd/protocol/current_playlist.py @@ -257,6 +257,7 @@ def playlistsearch(frontend, tag, needle): """ raise MpdNotImplemented # TODO +@handle_pattern(r'^plchanges (?P-?\d+)$') @handle_pattern(r'^plchanges "(?P-?\d+)"$') def plchanges(frontend, version): """ diff --git a/tests/frontends/mpd/current_playlist_test.py b/tests/frontends/mpd/current_playlist_test.py index 062da6d4..0d639f89 100644 --- a/tests/frontends/mpd/current_playlist_test.py +++ b/tests/frontends/mpd/current_playlist_test.py @@ -330,6 +330,15 @@ class CurrentPlaylistHandlerTest(unittest.TestCase): self.assert_(u'Title: c' in result) self.assert_(u'OK' in result) + def test_plchanges_without_quotes_works(self): + self.b.current_playlist.load( + [Track(name='a'), Track(name='b'), Track(name='c')]) + result = self.h.handle_request(u'plchanges 0') + self.assert_(u'Title: a' in result) + self.assert_(u'Title: b' in result) + self.assert_(u'Title: c' in result) + self.assert_(u'OK' in result) + def test_plchangesposid(self): self.b.current_playlist.load([Track(), Track(), Track()]) result = self.h.handle_request(u'plchangesposid "0"') From 9f71c1533a53bc9769e0fc11b5b938190316580f Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Fri, 13 Aug 2010 13:09:03 +0200 Subject: [PATCH 2/2] MPD: Support 'play' without quotes to work with BitMPC --- docs/changes.rst | 1 + mopidy/frontends/mpd/protocol/playback.py | 8 ++++++-- tests/frontends/mpd/playback_test.py | 6 ++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/docs/changes.rst b/docs/changes.rst index a59a2b5a..c8094546 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -26,6 +26,7 @@ Another great release. - Support ``plchanges "-1"`` to work better with MPDroid. - Support ``pause`` without arguments to work better with MPDroid. - Support ``plchanges`` without quotes to work better with BitMPC. + - Support ``play`` without quotes to work better with BitMPC. - Backend API: diff --git a/mopidy/frontends/mpd/protocol/playback.py b/mopidy/frontends/mpd/protocol/playback.py index 53cc2bbc..8a7243f6 100644 --- a/mopidy/frontends/mpd/protocol/playback.py +++ b/mopidy/frontends/mpd/protocol/playback.py @@ -147,8 +147,8 @@ def playid(frontend, cpid): except LookupError: raise MpdNoExistError(u'No such song', command=u'playid') -@handle_pattern(r'^play "(?P\d+)"$') -@handle_pattern(r'^play "(?P-1)"$') +@handle_pattern(r'^play (?P-?\d+)$') +@handle_pattern(r'^play "(?P-?\d+)"$') def playpos(frontend, songpos): """ *musicpd.org, playback section:* @@ -161,6 +161,10 @@ def playpos(frontend, songpos): - issues ``play "-1"`` after playlist replacement to start playback at the first track. + + *BitMPC:* + + - issues ``play 6`` without quotes around the argument. """ songpos = int(songpos) try: diff --git a/tests/frontends/mpd/playback_test.py b/tests/frontends/mpd/playback_test.py index e76cb9df..6e69375b 100644 --- a/tests/frontends/mpd/playback_test.py +++ b/tests/frontends/mpd/playback_test.py @@ -175,6 +175,12 @@ class PlaybackControlHandlerTest(unittest.TestCase): self.assert_(u'OK' in result) self.assertEqual(self.b.playback.PLAYING, self.b.playback.state) + def test_play_with_pos_without_quotes(self): + self.b.current_playlist.load([Track()]) + result = self.h.handle_request(u'play 0') + self.assert_(u'OK' in result) + self.assertEqual(self.b.playback.PLAYING, self.b.playback.state) + def test_play_with_pos_out_of_bounds(self): self.b.current_playlist.load([]) result = self.h.handle_request(u'play "0"')