Skip to content

Commit

Permalink
backend: Make bitrate attribute private
Browse files Browse the repository at this point in the history
  • Loading branch information
jodal committed Nov 13, 2014
1 parent 71803e0 commit d9e2f5c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
7 changes: 3 additions & 4 deletions mopidy_spotify/backend.py
Expand Up @@ -37,8 +37,7 @@ def __init__(self, config, audio):
self._audio = audio
self._session = None
self._event_loop = None
# TODO Make `birate` private?
self.bitrate = None
self._bitrate = None

self.library = library.SpotifyLibraryProvider(backend=self)
self.playback = playback.SpotifyPlaybackProvider(
Expand Down Expand Up @@ -70,8 +69,8 @@ def _get_session(self, config):

session.connection.allow_network = config['spotify']['allow_network']

self.bitrate = config['spotify']['bitrate']
session.preferred_bitrate = BITRATES[self.bitrate]
self._bitrate = config['spotify']['bitrate']
session.preferred_bitrate = BITRATES[self._bitrate]
session.volume_normalization = (
config['spotify']['volume_normalization'])

Expand Down
8 changes: 4 additions & 4 deletions mopidy_spotify/library.py
Expand Up @@ -46,7 +46,7 @@ def lookup(self, uri):
def _lookup_track(self, sp_link):
sp_track = sp_link.as_track()
sp_track.load()
track = translator.to_track(sp_track, bitrate=self._backend.bitrate)
track = translator.to_track(sp_track, bitrate=self._backend._bitrate)
if track is not None:
yield track

Expand All @@ -56,7 +56,7 @@ def _lookup_album(self, sp_link):
sp_album_browser.load()
for sp_track in sp_album_browser.tracks:
track = translator.to_track(
sp_track, bitrate=self._backend.bitrate)
sp_track, bitrate=self._backend._bitrate)
if track is not None:
yield track

Expand All @@ -74,7 +74,7 @@ def _lookup_artist(self, sp_link):
continue
for sp_track in sp_album_browser.tracks:
track = translator.to_track(
sp_track, bitrate=self._backend.bitrate)
sp_track, bitrate=self._backend._bitrate)
if track is not None:
yield track

Expand All @@ -83,7 +83,7 @@ def _lookup_playlist(self, sp_link):
sp_playlist.load()
for sp_track in sp_playlist.tracks:
track = translator.to_track(
sp_track, bitrate=self._backend.bitrate)
sp_track, bitrate=self._backend._bitrate)
if track is not None:
yield track

Expand Down
4 changes: 2 additions & 2 deletions mopidy_spotify/playlists.py
Expand Up @@ -51,7 +51,7 @@ def lookup(self, uri):

username = self._backend._session.user_name
return translator.to_playlist(
sp_playlist, username=username, bitrate=self._backend.bitrate)
sp_playlist, username=username, bitrate=self._backend._bitrate)

@property
def playlists(self):
Expand Down Expand Up @@ -80,7 +80,7 @@ def playlists(self):

playlist = translator.to_playlist(
sp_playlist, folders=folders, username=username,
bitrate=self._backend.bitrate)
bitrate=self._backend._bitrate)
if playlist is not None:
result.append(playlist)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_library.py
Expand Up @@ -22,7 +22,7 @@ def backend_mock(session_mock, config):
backend_mock = mock.Mock(spec=backend.SpotifyBackend)
backend_mock._config = config
backend_mock._session = session_mock
backend_mock.bitrate = 160
backend_mock._bitrate = 160
return backend_mock


Expand Down
2 changes: 1 addition & 1 deletion tests/test_playlists.py
Expand Up @@ -50,7 +50,7 @@ def session_mock(sp_playlist_mock, sp_user_mock):
def backend_mock(session_mock):
backend_mock = mock.Mock(spec=backend.SpotifyBackend)
backend_mock._session = session_mock
backend_mock.bitrate = 160
backend_mock._bitrate = 160
return backend_mock


Expand Down

0 comments on commit d9e2f5c

Please sign in to comment.