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

When browsing the SoundCloud stream less than ten songs are displayed #48

Open
baumgartnerniels opened this issue Mar 1, 2015 · 2 comments

Comments

@baumgartnerniels
Copy link

I'm using ncmpcpp as client. When navigating to Browse, [soundcloud], [stream], less than 10 songs appear in the list.

The (undocumented) API seems to have changed.
The problem seems to be in this function:

    def get_user_stream(self):
        # User timeline like playlist which uses undocumented api
        # https://api.soundcloud.com/e1/me/stream.json?offset=0
        # returns five elements per request
        tracks = []
        for sid in xrange(0, 2):
            stream = self._get('e1/me/stream.json?offset=%s' % sid * 5)
            for data in stream.get('collection'):
                kind = data.get('type')
                # multiple types of track with same data
                if 'track' in kind:
                    tracks.append(self.parse_track(data.get('track')))
                if kind == 'playlist':
                    playlist = data.get('playlist').get('tracks')
                    if isinstance(playlist, collections.Iterable):
                        tracks.extend(self.parse_results(playlist))

        return self.sanitize_tracks(tracks)

The offset parameter of the API call seems not to have an effect anymore.

The following works for me:

    def get_user_stream(self):
        # User timeline like playlist which uses undocumented api
        # https://api.soundcloud.com/e1/me/stream.json?limit=100
        tracks = []
        stream = self._get('e1/me/stream.json?limit=100')
        for data in stream.get('collection'):
            kind = data.get('type')
            # multiple types of track with same data
            if 'track' in kind:
                tracks.append(self.parse_track(data.get('track')))
            if kind == 'playlist':
                playlist_id = data.get('playlist').get('id')
                for track in self.get_set(playlist_id):
                    tracks.append(self.parse_track(track))

        return self.sanitize_tracks(tracks)
baumgartnerniels added a commit to baumgartnerniels/mopidy-soundcloud that referenced this issue Mar 2, 2015
@baumgartnerniels
Copy link
Author

I forgot to mention, that the playlists in the stream also seem to have a different format. The above fixes this too.

@ghost
Copy link

ghost commented Jun 22, 2017

Any update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant