mopidy / mopidy-spotify

Mopidy extension for playing music from Spotify
https://mopidy.com/ext/spotify/
Apache License 2.0
934 stars 108 forks source link

Search returns Albums with no Artist #99

Open fatg3erman opened 8 years ago

fatg3erman commented 8 years ago

I'm noticing that now I've upgraded to the latest mopidy and mopidy-spotify I'm getting some odd results when I search for artists on Spotify.

I'm searching using the mpd interface but I'm pretty sure mopidy-spotify is sending it models without the artist field filled in, when those are search results with just an album URI. For example:

search artist "Duran Duran"
[snip]
Album: Greatest
Title: Album: Greatest
X-AlbumUri: spotify:album:7xbWtTByfdMWFfxXmeFFl0
file: spotify:album:0PqCkTvKFJxzr9uujq7a3T
Time: 0
Album: Duran Duran [The Wedding Album]
Title: Album: Duran Duran [The Wedding Album]
X-AlbumUri: spotify:album:0PqCkTvKFJxzr9uujq7a3T
file: spotify:album:02tfQwJSOLP77oCd9U8bqm
Time: 0

This is definitely a regression from the old behaviour where the Artist field was always filled in. An album name without an artist isn't very helpful in search results.

trygveaa commented 8 years ago

This is a regression after switching from using libspotify to the Web API for search (version 2.3.1). From the changelog:

Note that search through the Spotify Web API doesn't return artists or date for albums.

The reason the switch was done, and that the regression wasn't fixed in that release was that Spotify deactivated search through libspotify, so we wanted to switch to the Web API as fast as possible, since a working search with most of the functionality is better than no search.

Apparently, search through libspotify is now working again, but Spotify hasn't communicated anything, so it may not be smart to rely on that.

I guess there are three possible fixes for this:

  1. Make additional requests to the Web API to get the artists for all the albums. This can be done with the Get Several Albums service. Unfortunately, that only supports max 20 albums at a time. This means that we have to do up to three additional requests per search request (how many we have to do depends on the config value spotify/search_album_count).
  2. Revert back to using libspotify for search. Since this may be shut down again at any moment without notice, this is probably not a good idea. We could give the user the option of which API to use, but that is probably not a good idea either, as it complicates things and is not a long-term solution.
  3. Contact Spotify and get them to add artists (at least names) to the simplified album model in the Web API. At https://developer.spotify.com/web-api/search-item/ they write this about the simplified models:

Why does Search return full objects for tracks, but only partial albums? It’s a fine balance between keeping the response small but at the same time include as much information as possible. We’ve expanded response objects previously, and we’ll definitely keep this in mind as we tweak the Search endpoint.

fatg3erman commented 8 years ago

Thanks for the explanation. Sounds like relying on libspotify for anything is not a good idea. Their API decision makes sense in the context of the way the Spotify desktop application displays things, but the whole point of an API is to support different ideas, surely? I think that the best thing to do is try to persuade Spotify to improve their API. I'll gladly help with that if I can.

LukeMcDonnell commented 8 years ago

Is there a solution in the works for this issue? I ask as a front-end dev looking at implementing a client side solution to the problem, but I'd hate to spend time working on it only to have it fixed on the server-side.