Skip to content
This repository has been archived by the owner on Dec 7, 2020. It is now read-only.

Commit

Permalink
Merge b4f7646 into 4fb9c8f
Browse files Browse the repository at this point in the history
  • Loading branch information
belak committed Jul 2, 2016
2 parents 4fb9c8f + b4f7646 commit 8bfc4ca
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 13 deletions.
3 changes: 2 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ Mopidy-GMusic. See Google's docs on `how to make an app password
<https://support.google.com/accounts/answer/185833>`_ if you're not already
familiar with this.

All Access subscribers may enable All Access integration by adding this line::
By default, All Access will be enabled automatically if you subscribe. You may
force enable or disable it by using the all_access option::

[gmusic]
all_access = true
Expand Down
1 change: 0 additions & 1 deletion mopidy_gmusic/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def on_start(self):
self.session.login(self.config['gmusic']['username'],
self.config['gmusic']['password'],
self.config['gmusic']['deviceid'])
self.library.set_all_access(self.config['gmusic']['all_access'])

# wait a few seconds to let mopidy settle
# then refresh google music content asynchronously
Expand Down
2 changes: 1 addition & 1 deletion mopidy_gmusic/ext.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ username =
password =
bitrate = 160
deviceid =
all_access = false
all_access =
refresh_library = 1440
refresh_playlists = 60
radio_stations_in_browse = true
Expand Down
6 changes: 3 additions & 3 deletions mopidy_gmusic/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def __init__(self, *args, **kwargs):
self.aa_artists = {}
self.aa_tracks = LruCache()
self.aa_albums = LruCache()
self.all_access = False
self._radio_stations_in_browse = (
self.backend.config['gmusic']['radio_stations_in_browse'])
self._radio_stations_count = (
Expand All @@ -43,8 +42,9 @@ def __init__(self, *args, **kwargs):
GMusicLibraryProvider.root_directory = Ref.directory(
uri='gmusic:directory', name='Google Music')

def set_all_access(self, all_access):
self.all_access = all_access
@property
def all_access(self):
return self.backend.session.all_access

def _browse_albums(self):
refs = []
Expand Down
9 changes: 8 additions & 1 deletion mopidy_gmusic/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def inner_wrapper(self, *args, **kwargs):
class GMusicSession(object):

def __init__(self, all_access, api=None):
self.all_access = all_access
self._all_access = all_access
if api is None:
self.api = gmusicapi.Mobileclient()
else:
Expand All @@ -65,6 +65,13 @@ def login(self, username, password, device_id):
logger.error('Failed to login to Google Music as "%s"', username)
return authenticated

@property
def all_access(self):
if self._all_access is None:
return self.api.is_subscribed

return self._all_access

@endpoint(default=None)
def logout(self):
return self.api.logout()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_get_default_config(self):

self.assertIn('[gmusic]', config)
self.assertIn('enabled = true', config)
self.assertIn('all_access = false', config)
self.assertIn('all_access =', config)
self.assertIn('radio_stations_in_browse = true', config)
self.assertIn('radio_stations_count =', config)
self.assertIn('radio_tracks_count = 25', config)
Expand Down
10 changes: 5 additions & 5 deletions tests/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def test_when_online(self, online_session):
online_session.api.get_track_info.assert_called_once_with('id')

def test_without_all_access(self, online_session, caplog):
online_session.all_access = False
online_session._all_access = False

assert online_session.get_track_info('id') is None
assert (
Expand All @@ -182,7 +182,7 @@ def test_when_online(self, online_session):
'id', include_tracks=False)

def test_without_all_access(self, online_session, caplog):
online_session.all_access = False
online_session._all_access = False

assert online_session.get_album_info('id') is None
assert (
Expand All @@ -206,7 +206,7 @@ def test_when_online(self, online_session):
'id', include_albums=False, max_rel_artist=3, max_top_tracks=4)

def test_without_all_access(self, online_session, caplog):
online_session.all_access = False
online_session._all_access = False

assert online_session.get_artist_info('id') is None
assert (
Expand All @@ -229,7 +229,7 @@ def test_when_online(self, online_session):
'abba', max_results=10)

def test_without_all_access(self, online_session, caplog):
online_session.all_access = False
online_session._all_access = False

online_session.api.search.return_value = mock.sentinel.rv

Expand Down Expand Up @@ -267,7 +267,7 @@ def test_when_online(self, online_session):
'IFL', num_tracks=5)

def test_without_all_access(self, online_session, caplog):
online_session.all_access = False
online_session._all_access = False

assert online_session.get_station_tracks('IFL') == []
assert (
Expand Down

0 comments on commit 8bfc4ca

Please sign in to comment.