From a244761abc3f7cc514f8ef62aa6e9f3c81cd6c3b Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sun, 17 Aug 2014 23:25:09 +0200 Subject: [PATCH] mpd: Replace / with | instead of whitespace in playlist names --- docs/changelog.rst | 5 +++++ mopidy/mpd/dispatcher.py | 2 +- tests/mpd/protocol/test_stored_playlists.py | 8 ++++---- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index c75bbb27..6d7da9d4 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -13,6 +13,11 @@ v0.20.0 (UNRELEASED) - Add cover URL to all scanned files with MusicBrainz album IDs. (Fixes: :issue:`697`, PR: :issue:`802`) +**MPD frontend** + +- In stored playlist names, replace "/", which are illegal, with "|" instead of + a whitespace. Pipes are more similar to forward slash. + v0.19.4 (UNRELEASED) ==================== diff --git a/mopidy/mpd/dispatcher.py b/mopidy/mpd/dispatcher.py index 84550698..9c2f3471 100644 --- a/mopidy/mpd/dispatcher.py +++ b/mopidy/mpd/dispatcher.py @@ -269,7 +269,7 @@ class MpdContext(object): if not playlist.name: continue # TODO: add scheme to name perhaps 'foo (spotify)' etc. - name = self._invalid_playlist_chars.sub(' ', playlist.name) + name = self._invalid_playlist_chars.sub('|', playlist.name) self.insert_name_uri_mapping(name, playlist.uri) def lookup_playlist_from_name(self, name): diff --git a/tests/mpd/protocol/test_stored_playlists.py b/tests/mpd/protocol/test_stored_playlists.py index 56011435..4dc7dbbb 100644 --- a/tests/mpd/protocol/test_stored_playlists.py +++ b/tests/mpd/protocol/test_stored_playlists.py @@ -121,12 +121,12 @@ class PlaylistsHandlerTest(protocol.BaseTestCase): self.assertNotInResponse('playlist: a\r') self.assertInResponse('OK') - def test_listplaylists_replaces_forward_slash_with_space(self): + def test_listplaylists_replaces_forward_slash_with_pipe(self): self.backend.playlists.playlists = [ - Playlist(name='a/', uri='dummy:')] + Playlist(name='a/b', uri='dummy:')] self.sendRequest('listplaylists') - self.assertInResponse('playlist: a ') - self.assertNotInResponse('playlist: a/') + self.assertInResponse('playlist: a|b') + self.assertNotInResponse('playlist: a/b') self.assertInResponse('OK') def test_load_appends_to_tracklist(self):