MPD: Support 'plchanges "-1"' to work better with MPDroid

This commit is contained in:
Stein Magnus Jodal 2010-08-13 12:20:14 +02:00
parent 84e5b69922
commit 255d70d1ae
3 changed files with 15 additions and 1 deletions

View File

@ -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:

View File

@ -257,7 +257,7 @@ def playlistsearch(frontend, tag, needle):
"""
raise MpdNotImplemented # TODO
@handle_pattern(r'^plchanges "(?P<version>\d+)"$')
@handle_pattern(r'^plchanges "(?P<version>-?\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:

View File

@ -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"')