Skip to content

Commit

Permalink
Merge pull request #36 from chigley/private-session
Browse files Browse the repository at this point in the history
config: Add private_session config
  • Loading branch information
jodal committed Jan 18, 2015
2 parents a24be54 + 01bb189 commit 95d8012
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.rst
Expand Up @@ -126,6 +126,12 @@ The following configuration values are available:
domains to get toplists for. Defaults to a long list of countries which
Spotify is available in.

- ``spotify/private_session``: Whether to use a private Spotify session. Turn
on private session to disable sharing of played tracks with friends through
the Spotify activity feed, Last.fm scrobbling, and Facebook. This only
affects social sharing done by Spotify, not by other Mopidy extensions.
Defaults to ``false``.


Project resources
=================
Expand Down Expand Up @@ -163,6 +169,8 @@ v2.0.0 (UNRELEASED)
``spotify/search_album_count``, ``spotify/search_artist_count``, and
``spotify/search_track_count``.

- Add ``spotify/private_session`` config.

**Lookup**

- Adding an artist by URI will now first find all albums by the artist and
Expand Down
1 change: 1 addition & 0 deletions mopidy_spotify/__init__.py
Expand Up @@ -26,6 +26,7 @@ def get_config_schema(self):

schema['bitrate'] = config.Integer(choices=(96, 160, 320))
schema['volume_normalization'] = config.Boolean()
schema['private_session'] = config.Boolean()

schema['timeout'] = config.Integer(minimum=0)

Expand Down
2 changes: 2 additions & 0 deletions mopidy_spotify/backend.py
Expand Up @@ -73,6 +73,8 @@ def _get_session(self, config):
session.preferred_bitrate = BITRATES[self._bitrate]
session.volume_normalization = (
config['spotify']['volume_normalization'])
session.social.private_session = (
config['spotify']['private_session'])

session.on(
spotify.SessionEvent.CONNECTION_STATE_UPDATED,
Expand Down
1 change: 1 addition & 0 deletions mopidy_spotify/ext.conf
Expand Up @@ -4,6 +4,7 @@ username =
password =
bitrate = 160
volume_normalization = true
private_session = false
timeout = 10
cache_dir = $XDG_CACHE_DIR/mopidy/spotify
settings_dir = $XDG_CONFIG_DIR/mopidy/spotify
Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Expand Up @@ -17,6 +17,7 @@ def config():
'password': 'password',
'bitrate': 160,
'volume_normalization': True,
'private_session': False,
'timeout': 10,
'cache_dir': '/my/cache/dir',
'settings_dir': '/my/settings/dir',
Expand Down
11 changes: 11 additions & 0 deletions tests/test_backend.py
Expand Up @@ -77,6 +77,17 @@ def test_on_start_configures_volume_normalization(spotify_mock, config):
volume_normalization_mock.assert_called_once_with(False)


def test_on_start_configures_private_session(spotify_mock, config):
session = spotify_mock.Session.return_value
private_session_mock = mock.PropertyMock()
type(session.social).private_session = private_session_mock
config['spotify']['private_session'] = True

get_backend(config).on_start()

private_session_mock.assert_called_once_with(True)


def test_on_start_adds_connection_state_changed_handler_to_session(
spotify_mock, config):
session = spotify_mock.Session.return_value
Expand Down
1 change: 1 addition & 0 deletions tests/test_extension.py
Expand Up @@ -21,6 +21,7 @@ def test_get_config_schema():
assert 'password' in schema
assert 'bitrate' in schema
assert 'volume_normalization' in schema
assert 'private_session' in schema
assert 'timeout' in schema
assert 'cache_dir' in schema
assert 'settings_dir' in schema
Expand Down

0 comments on commit 95d8012

Please sign in to comment.