Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Uniquify spotify playlist names #351

Closed
wants to merge 2 commits into from

2 participants

@kingosticks
Collaborator

Implements #114 (comment)

  • Appends the playlist owner to those playlists owned by other users i.e. followed playlists
    • Left playlists owned by the current Spotify user alone - presumably they shouldn't appear any different to LocalBackend playlists
  • Appends an incrementing number to playlists with the same name
    • First occurrence of a name is unchanged
    • Looking again I've realised this isn't the place to do this when dealing with multiple backends, perhaps I should remove this bit?
@jodal
Owner

I also think that identically named playlists isn't the Spotify backend's problem as it identifies playlists uniquely by URI. It's an issue the MPD frontend should solve on its own.

You don't have to do anything to remove the identical name part. I'll just merge the first commit tonight and let the other one be.

@kingosticks
Collaborator

OK great, thanks!

@jodal
Owner

Merged in 1c0601e.

@jodal jodal closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 13 additions and 2 deletions.
  1. +13 −2 mopidy/backends/spotify/translator.py
View
15 mopidy/backends/spotify/translator.py
@@ -9,6 +9,7 @@
artist_cache = {}
album_cache = {}
track_cache = {}
+playlist_names = {}
def to_mopidy_artist(spotify_artist):
@@ -70,13 +71,23 @@ def to_mopidy_playlist(spotify_playlist):
uri = str(Link.from_playlist(spotify_playlist))
if not spotify_playlist.is_loaded():
return Playlist(uri=uri, name='[loading...]')
- if not spotify_playlist.name():
+ name = spotify_playlist.name()
+ if not name:
# Other user's "starred" playlists isn't handled properly by pyspotify
# See https://github.com/mopidy/pyspotify/issues/81
return
+ if spotify_playlist.owner().canonical_name() != settings.SPOTIFY_USERNAME:
+ name += ' by ' + spotify_playlist.owner().canonical_name()
+ if name in playlist_names:
+ if uri not in playlist_names[name]:
+ playlist_names[name][uri] = len(playlist_names[name])
+ if playlist_names[name][uri] > 0:
+ name += '[' + str(playlist_names[name][uri]) + ']'
+ else:
+ playlist_names[name] = { uri : 0 }
return Playlist(
uri=uri,
- name=spotify_playlist.name(),
+ name=name,
tracks=[
to_mopidy_track(spotify_track)
for spotify_track in spotify_playlist
Something went wrong with that request. Please try again.