mpd: listplaylists should not return playlists without a name

This commit is contained in:
Stein Magnus Jodal 2012-11-21 00:32:46 +01:00
parent f313d9d446
commit 72574c1ae0
3 changed files with 19 additions and 0 deletions

View File

@ -79,6 +79,9 @@ long time been our most requested feature. Finally, it's here!
- The MPD commands ``search`` and ``find`` now allows the key ``file``, which
is used by ncmpcpp instead of ``filename``.
- The MPD command ``listplaylists`` will no longer return playlists without a
name. This could crash ncmpcpp.
**MPRIS frontend**
- The MPRIS playlists interface is now supported by our MPRIS frontend. This

View File

@ -70,9 +70,16 @@ def listplaylists(context):
Last-Modified: 2010-02-06T02:10:25Z
playlist: b
Last-Modified: 2010-02-06T02:11:08Z
*Clarifications:*
- ncmpcpp 0.5.10 segfaults if we return 'playlist: ' on a line, so we must
ignore playlists without names, which isn't very useful anyway.
"""
result = []
for playlist in context.core.playlists.playlists.get():
if not playlist.name:
continue
result.append(('playlist', playlist.name))
last_modified = (
playlist.last_modified or dt.datetime.now()).isoformat()

View File

@ -64,6 +64,15 @@ class PlaylistsHandlerTest(protocol.BaseTestCase):
self.assertInResponse('Last-Modified: 2001-03-17T13:41:17Z')
self.assertInResponse('OK')
def test_listplaylists_ignores_playlists_without_name(self):
last_modified = datetime.datetime(2001, 3, 17, 13, 41, 17, 12345)
self.backend.playlists.playlists = [
Playlist(name='', last_modified=last_modified)]
self.sendRequest('listplaylists')
self.assertNotInResponse('playlist: ')
self.assertInResponse('OK')
def test_load_known_playlist_appends_to_tracklist(self):
self.core.tracklist.add([Track(uri='a'), Track(uri='b')])
self.assertEqual(len(self.core.tracklist.tracks.get()), 2)