Skip to content

Commit

Permalink
config: Add allow_playlists config
Browse files Browse the repository at this point in the history
Fixes #25
  • Loading branch information
jodal committed Nov 12, 2014
1 parent f537717 commit afb44c2
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 4 deletions.
7 changes: 7 additions & 0 deletions README.rst
Expand Up @@ -114,6 +114,9 @@ The following configuration values are available:
- ``spotify/allow_network``: Whether to allow network access or not. Defaults
to ``true``.

- ``spotify/allow_playlists``: Whether or not playlists should be exposed.
Defaults to ``true``.

This comment has been minimized.

Copy link
@adamcik

adamcik Jan 22, 2015

Member

Should this be changed to false now that we have playlist browsing?

This comment has been minimized.

Copy link
@jodal

jodal Jan 25, 2015

Author Member

So far, we only have support for browsing playlists given the playlist URI. You can't browse a list of your playlists.

Also, this config was requested as a way to remove a person's private playlists entirely from a Mopidy installation shared by multiple users, so we want this to hide playlists from the browse interface too.



Project resources
=================
Expand Down Expand Up @@ -144,6 +147,10 @@ v2.0.0 (UNRELEASED)
Mopidy-Spotify to stay offline. This is mostly useful for testing during
development.

- Add ``spotify/allow_playlists`` config which can be used to disable all
access to playlists on the Spotify account. Useful where Mopidy is shared by
multiple users. (Fixes: #25)

**Lookup**

- Adding an artist by URI will now first find all albums by the artist and
Expand Down
4 changes: 1 addition & 3 deletions mopidy_spotify/__init__.py
Expand Up @@ -35,9 +35,7 @@ def get_config_schema(self):
schema['toplist_countries'] = config.List(optional=True)

schema['allow_network'] = config.Boolean()

# TODO Add more configrations:
# - show_playlists = true/false, requested in #25
schema['allow_playlists'] = config.Boolean()

return schema

Expand Down
6 changes: 5 additions & 1 deletion mopidy_spotify/backend.py
Expand Up @@ -59,7 +59,11 @@ def __init__(self, config, audio):
self.library = library.SpotifyLibraryProvider(backend=self)
self.playback = playback.SpotifyPlaybackProvider(
audio=audio, backend=self)
self.playlists = playlists.SpotifyPlaylistsProvider(backend=self)

if config['spotify']['allow_playlists']:
self.playlists = playlists.SpotifyPlaylistsProvider(backend=self)
else:
self.playlists = None

self.uri_schemes = ['spotify']

Expand Down
1 change: 1 addition & 0 deletions mopidy_spotify/ext.conf
Expand Up @@ -9,3 +9,4 @@ cache_dir = $XDG_CACHE_DIR/mopidy/spotify
settings_dir = $XDG_CONFIG_DIR/mopidy/spotify
toplist_countries = AD,AR,AU,AT,BE,CO,CY,DK,EE,FI,FR,DE,GR,HK,IS,IE,IT,LV,LI,LT,LU,MY,MX,MC,NL,NZ,NO,PT,ES,SG,SE,CH,TW,TR,GB,US
allow_network = true
allow_playlists = true
1 change: 1 addition & 0 deletions tests/conftest.py
Expand Up @@ -21,6 +21,7 @@ def config():
'cache_dir': '/my/cache/dir',
'settings_dir': '/my/settings/dir',
'allow_network': True,
'allow_playlists': True,
}
}

Expand Down
8 changes: 8 additions & 0 deletions tests/test_backend.py
Expand Up @@ -92,6 +92,14 @@ def test_init_sets_up_the_providers(spotify_mock, config):
assert isinstance(backend.playlists, playlists.SpotifyPlaylistsProvider)


def test_init_disables_playlists_provider_if_not_allowed(spotify_mock, config):
config['spotify']['allow_playlists'] = False

backend = get_backend(config)

assert backend.playlists is None


def test_on_start_starts_the_pyspotify_event_loop(spotify_mock, config):
backend = get_backend(config)
backend.on_start()
Expand Down
1 change: 1 addition & 0 deletions tests/test_extension.py
Expand Up @@ -26,6 +26,7 @@ def test_get_config_schema():
assert 'settings_dir' in schema
assert 'toplist_countries' in schema
assert 'allow_network' in schema
assert 'allow_playlists' in schema


def test_setup():
Expand Down

0 comments on commit afb44c2

Please sign in to comment.