Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Spotify albums now have duplicate tracks #3429
From cincoden...@gmail.com on January 14, 2013 21:51:05
I love the new better-unified search, BUT since upgrading to 1.1, my many Spotify albums I search for end up with duplicate tracks that are added to the playlist and play through. What steps will reproduce the problem? 1. Sign in with Spotify and search for an album (e.g. Mylo Xyloto by Coldplay)
I expect this kind of nonsense from Grooveshark, whose album data is pretty horrendous, but Spotify's data is much cleaner, and as stated, previous versions didn't have this issue. I haven't looked into the issue enough yet to determine if it is a problem actually within Clementine, or something upstream with the plugin or Spotify, but in the latter case if a workaround is possible, it would make Spotify much less frustrating again.
Original issue: http://code.google.com/p/clementine-player/issues/detail?id=3429
From cincoden...@gmail.com on February 01, 2013 21:10:55
I've been investigating this issue, and here's what I've found so far:
From what I've discerned, the Spotify service sends a list of albums and a list of free-floating tracks. The previous global search box would properly list each track and album independently, and if there were multiple versions of the same album, it would group them into one entry in the list, and then show them independently on mouse-over.
What appears to be happening now is that the Spotify search provider now just takes each song individually, appends it into one big list, and groups them by album name. This results in duplicates, triplicates, and even quadruplicates as Spotify has a couple versions of the album, as well individual entries for the song.
I've partially confirmed this by commenting out the section of code that adds the individual results from the list, which eliminated duplicates from the Foo Fighters' Greatest Hits, as shown in the attached screenshot.
From cincoden...@gmail.com on February 01, 2013 21:34:47
Here is a clearer picture of what is happening. I modified the search provider so that when it was looping through the albums from the Spotify service, it prepended the album loop index to the album title for each track - so that each album provided by the Spotify service would have a unique title. As expected, this resulted in multiple albums of the same title, but each with a complete, non-duplicated tracklist. There is also an non-prepended album with a few selected tracks - these are the ones provided in the result() list. I've attached a screenshot showing the difference, and a diff file showing the changes I made to the source.
Attachment: onedirection.png indexed.diff
From cincoden...@gmail.com on February 02, 2013 02:24:39
Okay, I've managed to get what I think is a pretty clean, sensible solution to this. I added a field to the Song struct called album_id_ that holds an (optional) unique identifier for an album, so that for a service like Spotify we can differentiate between different albums with the same title. This unique ID is appended to the album title for grouping purposes, but not displayed anywhere, so the results are exactly what I was looking for. I've attached my patch and an updated screenshot, and also uploaded my changes to my github at https://github.com/cincodenada/clementine-player
Attachment: onedirection_fixed.png spotify_dup_patch.diff