diff --git a/docs/changes.rst b/docs/changes.rst index b0887deb..35877808 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -102,6 +102,9 @@ backends: - The MPD commands ``search`` and ``find`` now allows the key ``file``, which is used by ncmpcpp instead of ``filename``. +- The Spotify backend now returns the track if you search for the Spotify track + URI. (Fixes: :issue:`233`) + **Bug fixes** - :issue:`218`: The MPD commands ``listplaylist`` and ``listplaylistinfo`` now diff --git a/mopidy/backends/spotify/library.py b/mopidy/backends/spotify/library.py index 18900d28..9be6a0c1 100644 --- a/mopidy/backends/spotify/library.py +++ b/mopidy/backends/spotify/library.py @@ -75,9 +75,16 @@ class SpotifyLibraryProvider(base.BaseLibraryProvider): return Playlist(tracks=tracks) spotify_query = [] for (field, values) in query.iteritems(): - if field == 'track': + if field == 'uri': + tracks = [] + for value in values: + track = self.lookup(value) + if track: + tracks.append(track) + return Playlist(tracks=tracks) + elif field == 'track': field = 'title' - if field == 'date': + elif field == 'date': field = 'year' if not hasattr(values, '__iter__'): values = [values]