From 476012cf8e0b6bc5f8444400e8d0e3736c56306b Mon Sep 17 00:00:00 2001 From: dz0ny Date: Tue, 24 Jun 2014 12:46:39 +0200 Subject: [PATCH] Support new explore api --- README.rst | 5 +++++ mopidy_soundcloud/__init__.py | 2 +- mopidy_soundcloud/soundcloud.py | 11 +++++------ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/README.rst b/README.rst index a3a66f6..982eec5 100644 --- a/README.rst +++ b/README.rst @@ -65,6 +65,11 @@ Project resources Changelog ========= +v1.2.5 (2014-06-24) +------------------- + +- Add support for new explore api + v1.2.4 (2014-05-15) ------------------- diff --git a/mopidy_soundcloud/__init__.py b/mopidy_soundcloud/__init__.py index 6b360e4..0a1511e 100644 --- a/mopidy_soundcloud/__init__.py +++ b/mopidy_soundcloud/__init__.py @@ -6,7 +6,7 @@ from mopidy.exceptions import ExtensionError -__version__ = '1.2.4' +__version__ = '1.2.5' __url__ = 'https://github.com/mopidy/mopidy-soundcloud' diff --git a/mopidy_soundcloud/soundcloud.py b/mopidy_soundcloud/soundcloud.py index b12586e..4ca1519 100644 --- a/mopidy_soundcloud/soundcloud.py +++ b/mopidy_soundcloud/soundcloud.py @@ -105,12 +105,12 @@ def get_user_stream(self): return self.sanitize_tracks(tracks) def get_explore(self, query_explore_id=None): - explore = self._get('/explore/v2') + explore = self._get('explore/categories', 'api-v2').get('music') if query_explore_id: - urn = explore.get('categories').get('music')[int(query_explore_id)] + urn = explore[int(query_explore_id)] web_tracks = self._get( 'explore/%s?tag=%s&limit=%s&offset=0&linked_partitioning=1' % - (urn, quote_plus(explore.get('tag')), self.explore_songs), + (urn, 'out-of-experiment', self.explore_songs), 'api-v2' ) tracks = [] @@ -118,7 +118,7 @@ def get_explore(self, query_explore_id=None): tracks.append(self.get_track(track.get('id'))) return tracks - return explore.get('categories').get('music') + return explore def get_groups(self, query_group_id=None): @@ -233,7 +233,7 @@ def _get(self, url, endpoint='api'): url = 'https://%s.soundcloud.com/%s' % (endpoint, url) - logger.info('Requesting %s' % url) + logger.debug('Requesting %s' % url) res = self.http_client.get(url) res.raise_for_status() return res.json() @@ -307,7 +307,6 @@ def parse_track(self, data, remote_url=False): track_kwargs[b'album'] = album track = Track(**track_kwargs) - print track return track @cache()