Skip to content

Commit

Permalink
Differentiate identially named Spotify playlists by appending a number
Browse files Browse the repository at this point in the history
  • Loading branch information
kingosticks committed Mar 26, 2013
1 parent 176d3cc commit eb65643
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions mopidy/backends/spotify/translator.py
Expand Up @@ -9,6 +9,7 @@
artist_cache = {}
album_cache = {}
track_cache = {}
playlist_names = {}


def to_mopidy_artist(spotify_artist):
Expand Down Expand Up @@ -77,6 +78,13 @@ def to_mopidy_playlist(spotify_playlist):
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=name,
Expand Down

0 comments on commit eb65643

Please sign in to comment.