mopidy / mopidy-soundcloud

Mopidy extension for playing music from SoundCloud
https://mopidy.com/ext/soundcloud/
MIT License
185 stars 59 forks source link

Removed/Non-existant SoundCloud liked tracks are still listed in playlists & queues #58

Open colinnuk opened 9 years ago

colinnuk commented 9 years ago

It seems the call to get liked tracks from a SoundCloud account still returns tracks which have been removed, but the subsequent request to get the proper track details from the given Soundcloud URI then fails. Eg, in my "liked" tracks I get the below JSON track returned:

{u'username': u'BOILER ROOM', u'permalink': u'platform', u'avatar_url': u'https://i1.sndcdn.com/avatars-000148237176-ws6zkk-large.jpg', u'kind': u'user', u'uri': u'https://api.soundcloud.com/users/752705', u'last_modified': u'2015/07/17 11:42:15 +0000', u'permalink_url': u'http://soundcloud.com/platform', u'id': 752705}, u'genre': u'Boiler Room', u'isrc': u'', u'permalink_url': u'http://soundcloud.com/platform/jamie-xx-55-min-boiler-room', u'kind': u'track', u'release_year': None, u'license': u'all-rights-reserved', u'monetization_model': u'NOT_APPLICABLE', u'artwork_url': u'https://i1.sndcdn.com/artworks-000035639414-mc3ylb-large.jpg', u'created_at': u'2012/12/06 17:27:19 +0000', u'bpm': None, u'uri': u'https://api.soundcloud.com/tracks/70225661', u'original_content_size': 121006339, u'key_signature': u'', u'user_playback_count': 1, u'release': u'', u'tag_list': u'"Boiler Room" "Jamie XX"', u'embeddable_by': u'all'}

However the actual URI (https://api.soundcloud.com/tracks/70225661?client_id=....) returns a 404 error.

This doesn't then play nicely with the musicbox_webclient software as the Queue page appears empty due to an undefined entry in the returned array to the client!

colinnuk commented 9 years ago

I'm thinking that this also exposes a problem on the mopidy side, it doesn't seem to handle empty "Track()" objects like it should.

Changing soundcloud.py's "get_tracks()" to return None (below) fixes the main issue I see - that of unavailable tracks appearing in the queue.

def get_track(self, track_id, streamable=False):
    logger.debug('Getting info for track with id %s' % track_id)
    try:
        return self.parse_track(self._get('tracks/%s.json' % track_id),
                                streamable)
    except Exception:
        logger.info('Song %s was removed' % track_id)
        return None