Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Take in account Spotify account permissions #8012

Merged
merged 2 commits into from Jun 13, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions homeassistant/components/media_player/spotify.py
Expand Up @@ -33,7 +33,7 @@
SUPPORT_NEXT_TRACK | SUPPORT_PREVIOUS_TRACK | SUPPORT_SELECT_SOURCE |\
SUPPORT_PLAY_MEDIA | SUPPORT_SHUFFLE_SET

SCOPE = 'user-read-playback-state user-modify-playback-state'
SCOPE = 'user-read-playback-state user-modify-playback-state user-read-private'
DEFAULT_CACHE_PATH = '.spotify-token-cache'
AUTH_CALLBACK_PATH = '/api/spotify'
AUTH_CALLBACK_NAME = 'api:spotify'
Expand Down Expand Up @@ -135,6 +135,7 @@ def __init__(self, oauth, name, aliases):
self._volume = None
self._shuffle = False
self._player = None
self._user = None
self._aliases = aliases
self._token_info = self._oauth.get_cached_token()

Expand All @@ -153,6 +154,7 @@ def refresh_spotify_instance(self):
if self._player is None or token_refreshed:
self._player = \
spotipy.Spotify(auth=self._token_info.get('access_token'))
self._user = self._player.me()

def update(self):
"""Update state and attributes."""
Expand Down Expand Up @@ -308,4 +310,7 @@ def media_title(self):
@property
def supported_features(self):
"""Return the media player features that are supported."""
return SUPPORT_SPOTIFY
if self._user is not None and self._user['product'] == 'premium':
return SUPPORT_SPOTIFY
else:
return None