spotify: Support search by track URI (fixes #233)

This commit is contained in:
Stein Magnus Jodal 2012-11-13 11:53:20 +01:00
parent 7ec156e373
commit 0dd09bce82
2 changed files with 12 additions and 2 deletions

View File

@ -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

View File

@ -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]