From ac4411ec83d95abc307489a8e61f7e0e905b4800 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Wed, 12 Dec 2012 16:08:16 +0100 Subject: [PATCH] spotify: Make session manager work with pyspotify 1.9 _and_ 1.10 --- mopidy/backends/spotify/session_manager.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/mopidy/backends/spotify/session_manager.py b/mopidy/backends/spotify/session_manager.py index 8112f885..288c61f2 100644 --- a/mopidy/backends/spotify/session_manager.py +++ b/mopidy/backends/spotify/session_manager.py @@ -64,15 +64,19 @@ class SpotifySessionManager(process.BaseThread, PyspotifySessionManager): logger.info('Connected to Spotify') + # To work with both pyspotify 1.9 and 1.10 + if not hasattr(self, 'session'): + self.session = session + logger.debug( 'Preferred Spotify bitrate is %s kbps', settings.SPOTIFY_BITRATE) - self.session.set_preferred_bitrate(BITRATES[settings.SPOTIFY_BITRATE]) + session.set_preferred_bitrate(BITRATES[settings.SPOTIFY_BITRATE]) self.container_manager = SpotifyContainerManager(self) self.playlist_manager = SpotifyPlaylistManager(self) - self.container_manager.watch(self.session.playlist_container()) + self.container_manager.watch(session.playlist_container()) self.connected.set() @@ -177,5 +181,7 @@ class SpotifySessionManager(process.BaseThread, PyspotifySessionManager): def logout(self): """Log out from spotify""" logger.debug('Logging out from Spotify') - if self.session: + + # To work with both pyspotify 1.9 and 1.10 + if getattr(self, 'session', None): self.session.logout()