diff --git a/docs/changelog.rst b/docs/changelog.rst index 7dd3fb1c..7761d8ea 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -10,10 +10,12 @@ v1.0.6 (unreleased) Bug fix release. +- Core/MPD/Local: Add support for ``title`` in + :meth:`mopidy.core.LibraryController.get_distinct`. (Fixes: :issue:`1181`) + - Core: Make sure track changes make it to audio while paused. (Fixes: :issuse:`1177`) - v1.0.5 (2015-05-19) =================== diff --git a/mopidy/backend.py b/mopidy/backend.py index 2bbc1eea..4503a9ee 100644 --- a/mopidy/backend.py +++ b/mopidy/backend.py @@ -97,6 +97,9 @@ class LibraryProvider(object): *MAY be implemented by subclass.* Default implementation will simply return an empty set. + + Note that backends should always return an empty set for unexpected + field types. """ return set() diff --git a/mopidy/core/library.py b/mopidy/core/library.py index 89a2037a..3cfb390c 100644 --- a/mopidy/core/library.py +++ b/mopidy/core/library.py @@ -85,8 +85,8 @@ class LibraryController(object): protocol supports in a more sane fashion. Other frontends are not recommended to use this method. - :param string field: One of ``artist``, ``albumartist``, ``album``, - ``composer``, ``performer``, ``date``or ``genre``. + :param string field: One of ``track``, ``artist``, ``albumartist``, + ``album``, ``composer``, ``performer``, ``date``or ``genre``. :param dict query: Query to use for limiting results, see :meth:`search` for details about the query format. :rtype: set of values corresponding to the requested field type. diff --git a/mopidy/local/json.py b/mopidy/local/json.py index 22fcfa5b..0945f86f 100644 --- a/mopidy/local/json.py +++ b/mopidy/local/json.py @@ -141,7 +141,10 @@ class JsonLibrary(local.Library): return [] def get_distinct(self, field, query=None): - if field == 'artist': + if field == 'track': + def distinct(track): + return {track.name} + elif field == 'artist': def distinct(track): return {a.name for a in track.artists} elif field == 'albumartist': diff --git a/mopidy/mpd/protocol/music_db.py b/mopidy/mpd/protocol/music_db.py index a942abf5..de800f4b 100644 --- a/mopidy/mpd/protocol/music_db.py +++ b/mopidy/mpd/protocol/music_db.py @@ -22,6 +22,7 @@ _SEARCH_MAPPING = { 'track': 'track_no'} _LIST_MAPPING = { + 'title': 'track', 'album': 'album', 'albumartist': 'albumartist', 'artist': 'artist', @@ -31,6 +32,7 @@ _LIST_MAPPING = { 'performer': 'performer'} _LIST_NAME_MAPPING = { + 'title': 'Title', 'album': 'Album', 'albumartist': 'AlbumArtist', 'artist': 'Artist', diff --git a/tests/mpd/protocol/test_music_db.py b/tests/mpd/protocol/test_music_db.py index b9fbcdf6..32fb3e25 100644 --- a/tests/mpd/protocol/test_music_db.py +++ b/tests/mpd/protocol/test_music_db.py @@ -624,6 +624,11 @@ class MusicDatabaseListTest(protocol.BaseTestCase): self.send_request('list "foo"') self.assertEqualResponse('ACK [2@0] {list} incorrect arguments') + # Track title + def test_list_title(self): + self.send_request('list "title"') + self.assertInResponse('OK') + # Artist def test_list_artist_with_quotes(self):