From fb4215a292d3e4b8fc70a3b5cec9c66f132cf829 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Fri, 25 Dec 2009 18:40:39 +0100 Subject: [PATCH] Rename all internal methods in SptifyBackend --- mopidy/backends/spotify.py | 62 +++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/mopidy/backends/spotify.py b/mopidy/backends/spotify.py index 7841dfcb..cd1ff35e 100644 --- a/mopidy/backends/spotify.py +++ b/mopidy/backends/spotify.py @@ -18,70 +18,70 @@ class SpotifyBackend(BaseBackend): def __init__(self, *args, **kwargs): super(SpotifyBackend, self).__init__(*args, **kwargs) logger.info(u'Connecting to Spotify') - self.spotify = spytify.Spytify(self.username, self.password) + self.spotify = spytify.Spytify(self._username, self._password) logger.info(u'Preloading data') - self.playlists - logger.info(u'Done preloading data') + self._playlists + logger.debug(u'Done preloading data') @property - def username(self): + def _username(self): username = encode(settings.SPOTIFY_USERNAME) if not username: sys.exit(u'Setting SPOTIFY_USERNAME is not set.') return username @property - def password(self): + def _password(self): password = encode(settings.SPOTIFY_PASSWORD) if not password: sys.exit(u'Setting SPOTIFY_PASSWORD is not set.') return password @property - def playlists(self): - if not hasattr(self, '_cached_playlists') or not self._cached_playlists: + def _playlists(self): + if not hasattr(self, '_x_playlists') or not self._x_playlists: logger.debug(u'Caching stored playlists') - self._cached_playlists = [] + self._x_playlists = [] for playlist in self.spotify.stored_playlists: - self._cached_playlists.append(playlist) - return self._cached_playlists + self._x_playlists.append(playlist) + return self._x_playlists @property - def current_playlist(self): - if not hasattr(self, '_current_playlist'): - self._current_playlist = [] - return self._current_playlist + def _current_playlist(self): + if not hasattr(self, '_x_current_playlist'): + self._x_current_playlist = [] + return self._x_current_playlist + + @_current_playlist.setter + def _current_playlist(self, tracks): + self._x_current_playlist = tracks + self._x_current_playlist_version += 1 @property - def current_playlist_version(self): - if not hasattr(self, '_current_playlist_version'): - self._current_playlist_version = 0 - return self._current_playlist_version - - @current_playlist.setter - def current_playlist(self, tracks): - self._current_playlist = tracks - self._current_playlist_version += 1 + def _current_playlist_version(self): + if not hasattr(self, '_x_current_playlist_version'): + self._x_current_playlist_version = 0 + return self._x_current_playlist_version ### MPD handlers def play_id(self, songid): - track = self.current_playlist[songid] + track = self._current_playlist[songid] self.spotify.play(track) def playlist_load(self, name): - playlists = filter(lambda p: decode(p.name) == name, self.playlists) + playlists = filter(lambda p: decode(p.name) == name, self._playlists) if playlists: - self.current_playlist = playlists[0].tracks + self._current_playlist = playlists[0].tracks else: - self.current_playlist = [] + self._current_playlist = [] def playlists_list(self): - return [u'playlist: %s' % decode(p.name) for p in self.playlists] + return [u'playlist: %s' % decode(p.name) for p in self._playlists] def playlist_changes(self, songpos): tracks = [] - for i, track in enumerate(self.current_playlist): + for i, track in enumerate(self._current_playlist): tracks.append(u'file: %s' % decode(track.track_id)) tracks.append(u'Time: %d' % (track.length // 1000)) tracks.append(u'Artist: %s' % decode(track.artists[0].name)) @@ -96,10 +96,10 @@ class SpotifyBackend(BaseBackend): self.spotify.stop() def status_playlist(self): - return self.current_playlist_version + return self._current_playlist_version def status_playlist_length(self): - return len(self.current_playlist) + return len(self._current_playlist) def url_handlers(self): return [u'spotify:', u'http://open.spotify.com/']