Skip to content

Commit

Permalink
Support new explore api
Browse files Browse the repository at this point in the history
  • Loading branch information
dz0ny committed Jun 24, 2014
1 parent 73523cb commit 476012c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
5 changes: 5 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
-------------------

Expand Down
2 changes: 1 addition & 1 deletion mopidy_soundcloud/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from mopidy.exceptions import ExtensionError


__version__ = '1.2.4'
__version__ = '1.2.5'
__url__ = 'https://github.com/mopidy/mopidy-soundcloud'


Expand Down
11 changes: 5 additions & 6 deletions mopidy_soundcloud/soundcloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,20 +105,20 @@ 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 = []
for track in web_tracks.get('tracks'):
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):

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 476012c

Please sign in to comment.