From 255d70d1ae105cf5fb9131a84546d7ee16c19e68 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Fri, 13 Aug 2010 12:20:14 +0200 Subject: [PATCH] MPD: Support 'plchanges "-1"' to work better with MPDroid --- docs/changes.rst | 1 + mopidy/frontends/mpd/protocol/current_playlist.py | 6 +++++- tests/frontends/mpd/current_playlist_test.py | 9 +++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/docs/changes.rst b/docs/changes.rst index c8e4c912..6f806425 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -23,6 +23,7 @@ Another great release. - Split gigantic protocol implementation into eleven modules. - Search improvements, including support for multi-word search. - Fixed ``play "-1"`` and ``playid "-1"`` behaviour when playlist is empty. + - Support ``plchanges "-1"`` to work better with MPDroid. - Backend API: diff --git a/mopidy/frontends/mpd/protocol/current_playlist.py b/mopidy/frontends/mpd/protocol/current_playlist.py index da052fff..76ae62ef 100644 --- a/mopidy/frontends/mpd/protocol/current_playlist.py +++ b/mopidy/frontends/mpd/protocol/current_playlist.py @@ -257,7 +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): """ *musicpd.org, current playlist section:* @@ -268,6 +268,10 @@ def plchanges(frontend, version): To detect songs that were deleted at the end of the playlist, use ``playlistlength`` returned by status command. + + *MPDroid:* + + - Calls ``plchanges "-1"`` two times per second to get the entire playlist. """ # XXX Naive implementation that returns all tracks as changed if int(version) < frontend.backend.current_playlist.version: diff --git a/tests/frontends/mpd/current_playlist_test.py b/tests/frontends/mpd/current_playlist_test.py index ce1e4069..062da6d4 100644 --- a/tests/frontends/mpd/current_playlist_test.py +++ b/tests/frontends/mpd/current_playlist_test.py @@ -321,6 +321,15 @@ class CurrentPlaylistHandlerTest(unittest.TestCase): self.assert_(u'Title: c' in result) self.assert_(u'OK' in result) + def test_plchanges_with_minus_one_returns_entire_playlist(self): + self.b.current_playlist.load( + [Track(name='a'), Track(name='b'), Track(name='c')]) + result = self.h.handle_request(u'plchanges "-1"') + 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"')