mopidy-soundcloud icon indicating copy to clipboard operation
mopidy-soundcloud copied to clipboard

When browsing the SoundCloud stream less than ten songs are displayed

Open baumgartnerniels opened this issue 9 years ago • 2 comments

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 avatar Mar 01 '15 22:03 baumgartnerniels

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

baumgartnerniels avatar Mar 02 '15 18:03 baumgartnerniels

Any update on this?

ghost avatar Jun 22 '17 17:06 ghost