From 31509ea56854523dd9dfa04be51f5ef864e04d53 Mon Sep 17 00:00:00 2001 From: Thomas Adamcik Date: Tue, 19 May 2015 22:37:35 +0200 Subject: [PATCH] core/mpd/local: Add title to get_distinct field types --- docs/changelog.rst | 8 ++++++++ mopidy/backend.py | 3 +++ mopidy/core/library.py | 4 ++-- mopidy/local/json.py | 5 ++++- mopidy/mpd/protocol/music_db.py | 2 ++ 5 files changed, 19 insertions(+), 3 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 4aad8690..4dce587c 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -5,6 +5,14 @@ Changelog This changelog is used to track all major changes to Mopidy. +v1.0.6 (unreleased) +=================== + +Bug fix release. + +- Core/MPD/Local: Add support for ``title`` in + :meth:`mopidy.core.LibraryController.get_distinct`. (Fixes: :issue:`1181`) + 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..ed0b292e 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 ``title``, ``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..a7500505 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 == 'title': + 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..9f1aaf4c 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': 'title', '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',