Merge pull request #376 from trefis/develop
Adds "Starred" playlist to the playlists catalog
This commit is contained in:
commit
d032891246
@ -169,6 +169,7 @@ class SpotifySessionManager(process.BaseThread, PyspotifySessionManager):
|
||||
return
|
||||
playlists = map(
|
||||
translator.to_mopidy_playlist, self.session.playlist_container())
|
||||
playlists.append(translator.to_mopidy_playlist(self.session.starred()))
|
||||
playlists = filter(None, playlists)
|
||||
self.backend.playlists.playlists = playlists
|
||||
logger.info('Loaded %d Spotify playlist(s)', len(playlists))
|
||||
|
||||
@ -71,16 +71,19 @@ def to_mopidy_playlist(spotify_playlist):
|
||||
if not spotify_playlist.is_loaded():
|
||||
return Playlist(uri=uri, name='[loading...]')
|
||||
name = spotify_playlist.name()
|
||||
tracks=[
|
||||
to_mopidy_track(spotify_track)
|
||||
for spotify_track in spotify_playlist
|
||||
if not spotify_track.is_local()
|
||||
]
|
||||
if not name:
|
||||
# Other user's "starred" playlists isn't handled properly by pyspotify
|
||||
# See https://github.com/mopidy/pyspotify/issues/81
|
||||
return
|
||||
name = "Starred"
|
||||
# Tracks in the Starred playlist are in reverse order from the official
|
||||
# client.
|
||||
tracks.reverse()
|
||||
if spotify_playlist.owner().canonical_name() != settings.SPOTIFY_USERNAME:
|
||||
name += ' by ' + spotify_playlist.owner().canonical_name()
|
||||
return Playlist(
|
||||
uri=uri,
|
||||
name=name,
|
||||
tracks=[
|
||||
to_mopidy_track(spotify_track)
|
||||
for spotify_track in spotify_playlist
|
||||
if not spotify_track.is_local()])
|
||||
tracks=tracks)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user