mopidy / mopidy-soundcloud

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

SoundCloudBackend backend caused an exception #60

Open robotrono opened 9 years ago

robotrono commented 9 years ago

I get this error when trying add this url playlist:

https://soundcloud.com/zeb-23/sets

ERROR    SoundCloudBackend backend caused an exception.
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/mopidy/core/library.py", line 19, in _backend_error_handling yield
  File "/usr/lib/python2.7/dist-packages/mopidy/core/library.py", line 236, in lookup result = future.get()
  File "/usr/lib/python2.7/dist-packages/pykka/threading.py", line 52, in get compat.reraise(*self._data['exc_info'])
  File "/usr/lib/python2.7/dist-packages/pykka/compat.py", line 12, in reraise exec('raise tp, value, tb')
  File "/usr/lib/python2.7/dist-packages/pykka/actor.py", line 201, in _actor_loop response = self._handle_receive(message)
  File "/usr/lib/python2.7/dist-packages/pykka/actor.py", line 295, in _handle_receive return callee(*message['args'], **message['kwargs'])
  File "/usr/local/lib/python2.7/dist-packages/mopidy_soundcloud/library.py", line 202, in lookup return self.backend.remote.resolve_url(uri)
  File "/usr/local/lib/python2.7/dist-packages/mopidy_soundcloud/soundcloud.py", line 225, in resolve_url return self.parse_results([self._get('resolve.json?url=%s' % uri)])
  File "/usr/local/lib/python2.7/dist-packages/mopidy_soundcloud/soundcloud.py", line 236, in _get res = self.http_client.get(url)
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 467, in get return self.request('GET', url, **kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 455, in request resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 558, in send r = adapter.send(request, **kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 378, in send raise ConnectionError(e)
ConnectionError: HTTPSConnectionPool(host='api.soundcloud.com', port=443): Max retries exceeded with url: /resolve.json?url=https://soundcloud.com/zeb-23/sets&client_id=93e33e327fd8a9b77becd179652272e2 (Caused by <class 'socket.error'>: [Errno 104] Connection reset by peer)
robotrono commented 9 years ago

With: https://soundcloud.com/zeb-23/sets/zeboom

INFO     'ZeBOOM' can't be streamed from SoundCloud
jodal commented 9 years ago

I'm reopening this, as Mopidy-Soundcloud should handle these exceptions better. No input should make it crash.

HazWard commented 8 years ago

I've experiencing a similar issue but it happens with every option except Explore and Stream (I can't test Groups and Sets because I don't have does on my account).

The output:

ERROR    SoundCloudBackend backend caused an exception.
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/mopidy/core/library.py", line 19, in _backend_error_handling
    yield
  File "/usr/lib/python2.7/site-packages/mopidy/core/library.py", line 112, in _browse
    result = backend.library.browse(uri).get()
  File "/usr/lib/python2.7/site-packages/pykka/future.py", line 299, in get
    exec('raise exc_info[0], exc_info[1], exc_info[2]')
  File "/usr/lib/python2.7/site-packages/pykka/actor.py", line 200, in _actor_loop
    response = self._handle_receive(message)
  File "/usr/lib/python2.7/site-packages/pykka/actor.py", line 294, in _handle_receive
    return callee(*message['args'], **message['kwargs'])
  File "/usr/lib/python2.7/site-packages/mopidy_soundcloud/library.py", line 166, in browse
    return self.list_liked()
  File "/usr/lib/python2.7/site-packages/mopidy_soundcloud/library.py", line 78, in list_liked
    logger.debug('Adding liked track %s to vfs' % data.name)
AttributeError: 'list' object has no attribute 'name'
prayerslayer commented 8 years ago

Can confirm, also for me only Explore and Stream work.

prayerslayer commented 8 years ago

Looked into Likes specifically:

Apparently the reason is that parse_track in soundcloud.py returns either a proper Track or an empty list, for instance when the track is not streamable. We could use get_track but this returns None only when there was an exception, so without one it would just return the empty list.

Not knowing what the reason for the empty list is, I’d just wrap this part of list_liked in library.py

vfs_list[data.name] = models.Ref.track(
    uri=data.uri, name=data.name
)

in a try/except.

But imo it would be better to make the output of parse_track either None or Track to reduce a) surprises and b) amount of cases to handle after calling it.

jodal commented 8 years ago

It should be noted that PR #69 only fixes the second of two unrelated issues in this bug. The first and stack trace listed here seems totally unrelated.

dtila commented 8 years ago

Hi,

I have the same error when I start the daemon:

2016-09-10 16:58:11,575 INFO [590:MainThread] mopidy.commands: Starting Mopidy backends: SoundCloudBackend, StreamBackend, M3UBackend, FileBackend, LocalBackend, YouTubeBackend 2016-09-10 16:58:11,611 ERROR [590:MainThread] mopidy.commands: Got un-handled exception from SoundCloudBackend Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/mopidy/commands.py", line 237, in _actor_error_handling yield File "/usr/lib/python2.7/site-packages/mopidy/commands.py", line 385, in start_backends config=config, audio=audio).proxy() File "/usr/lib/python2.7/site-packages/pykka/actor.py", line 93, in start obj = cls(_args, _kwargs) File "/usr/lib/python2.7/site-packages/mopidy_soundcloud/actor.py", line 21, in init self.remote = SoundCloudClient(config['soundcloud']) File "/usr/lib/python2.7/site-packages/mopidy_soundcloud/soundcloud.py", line 78, in init self._get('me.json') File "/usr/lib/python2.7/site-packages/mopidy_soundcloud/soundcloud.py", line 234, in _get res = self.http_client.get(url) File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 488, in get return self.request('GET', url, _kwargs) File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 475, in request resp = self.send(prep, *_send_kwargs) File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 596, in send r = adapter.send(request, **kwargs) File "/usr/lib/python2.7/site-packages/requests/adapters.py", line 487, in send raise ConnectionError(e, request=request) ConnectionError: HTTPSConnectionPool(host='api.soundcloud.com', port=443): Max retries exceeded with url: /me.json?client_id=myclientsecret (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7fde53ed27d0>: Failed to establish a new connection: [Errno -2] Name or service not known',))

I can mention that I have an Arch linux, I have just upgrade the system to the latest and the python pip to the latest one

ghost commented 7 years ago

Please look into this ­– I have an issue similar to prayerslayer, except only Stream is able to load a playlist, and even then, none of the songs can be played.

Trying to enter Explore:

ERROR    SoundCloudBackend backend caused an exception.
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/mopidy/core/library.py", line 19, in _backend_error_handling
    yield
  File "/usr/lib/python2.7/dist-packages/mopidy/core/library.py", line 112, in _browse
    result = backend.library.browse(uri).get()
  File "/usr/lib/python2.7/dist-packages/pykka/threading.py", line 52, in get
    compat.reraise(*self._data['exc_info'])
  File "/usr/lib/python2.7/dist-packages/pykka/compat.py", line 12, in reraise
    exec('raise tp, value, tb')
  File "/usr/lib/python2.7/dist-packages/pykka/actor.py", line 201, in _actor_loop
    response = self._handle_receive(message)
  File "/usr/lib/python2.7/dist-packages/pykka/actor.py", line 295, in _handle_receive
    return callee(*message['args'], **message['kwargs'])
  File "/usr/lib/python2.7/dist-packages/mopidy_soundcloud/library.py", line 155, in browse
    return self.list_explore()
  File "/usr/lib/python2.7/dist-packages/mopidy_soundcloud/library.py", line 97, in list_explore
    for eid, name in enumerate(self.backend.remote.get_explore()):
  File "/usr/lib/python2.7/dist-packages/mopidy_soundcloud/soundcloud.py", line 116, in get_explore
    explore = self.get_explore_categories()
  File "/usr/lib/python2.7/dist-packages/mopidy_soundcloud/soundcloud.py", line 57, in _memoized
    value = self.func(*args)
  File "/usr/lib/python2.7/dist-packages/mopidy_soundcloud/soundcloud.py", line 113, in get_explore_categories
    return self._get('explore/categories', 'api-v2').get('music')
  File "/usr/lib/python2.7/dist-packages/mopidy_soundcloud/soundcloud.py", line 235, in _get
    res.raise_for_status()
  File "/home/pwnage/.local/lib/python2.7/site-packages/requests/models.py", line 831, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
HTTPError: 404 Client Error: Not Found

Trying to enter Following:

ERROR    SoundCloudBackend backend caused an exception.
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/mopidy/core/library.py", line 19, in _backend_error_handling
    yield
  File "/usr/lib/python2.7/dist-packages/mopidy/core/library.py", line 112, in _browse
    result = backend.library.browse(uri).get()
  File "/usr/lib/python2.7/dist-packages/pykka/threading.py", line 52, in get
    compat.reraise(*self._data['exc_info'])
  File "/usr/lib/python2.7/dist-packages/pykka/compat.py", line 12, in reraise
    exec('raise tp, value, tb')
  File "/usr/lib/python2.7/dist-packages/pykka/actor.py", line 201, in _actor_loop
    response = self._handle_receive(message)
  File "/usr/lib/python2.7/dist-packages/pykka/actor.py", line 295, in _handle_receive
    return callee(*message['args'], **message['kwargs'])
  File "/usr/lib/python2.7/dist-packages/mopidy_soundcloud/library.py", line 147, in browse
    return self.list_user_follows()
  File "/usr/lib/python2.7/dist-packages/mopidy_soundcloud/library.py", line 89, in list_user_follows
    for (name, user_id) in self.backend.remote.get_followings():
  File "/usr/lib/python2.7/dist-packages/mopidy_soundcloud/soundcloud.py", line 148, in get_followings
    name = playlist.get('username')
AttributeError: 'unicode' object has no attribute 'get'

Trying to enter Likes:

ERROR    SoundCloudBackend backend caused an exception.
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/mopidy/core/library.py", line 19, in _backend_error_handling
    yield
  File "/usr/lib/python2.7/dist-packages/mopidy/core/library.py", line 112, in _browse
    result = backend.library.browse(uri).get()
  File "/usr/lib/python2.7/dist-packages/pykka/threading.py", line 52, in get
    compat.reraise(*self._data['exc_info'])
  File "/usr/lib/python2.7/dist-packages/pykka/compat.py", line 12, in reraise
    exec('raise tp, value, tb')
  File "/usr/lib/python2.7/dist-packages/pykka/actor.py", line 201, in _actor_loop
    response = self._handle_receive(message)
  File "/usr/lib/python2.7/dist-packages/pykka/actor.py", line 295, in _handle_receive
    return callee(*message['args'], **message['kwargs'])
  File "/usr/lib/python2.7/dist-packages/mopidy_soundcloud/library.py", line 166, in browse
    return self.list_liked()
  File "/usr/lib/python2.7/dist-packages/mopidy_soundcloud/library.py", line 78, in list_liked
    logger.debug('Adding liked track %s to vfs' % data.name)
AttributeError: 'list' object has no attribute 'name'

Entering Groups or Sets produces no output or errors (it may very well not have anything to load and actually be working properly)

Additionally, here's the error when I try to play something from Stream (in this case, Light Reading, from NMSNL):

INFO     'Light Reading' can't be streamed from SoundCloud
ERROR    SoundCloudBackend backend caused an exception.
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/mopidy/core/playback.py", line 382, in _change
    if not backend.playback.change_track(pending_tl_track.track).get():
  File "/usr/lib/python2.7/dist-packages/pykka/threading.py", line 52, in get
    compat.reraise(*self._data['exc_info'])
  File "/usr/lib/python2.7/dist-packages/pykka/compat.py", line 12, in reraise
    exec('raise tp, value, tb')
  File "/usr/lib/python2.7/dist-packages/pykka/actor.py", line 201, in _actor_loop
    response = self._handle_receive(message)
  File "/usr/lib/python2.7/dist-packages/pykka/actor.py", line 295, in _handle_receive
    return callee(*message['args'], **message['kwargs'])
  File "/usr/lib/python2.7/dist-packages/mopidy/backend.py", line 245, in change_track
    uri = self.translate_uri(track.uri)
  File "/usr/lib/python2.7/dist-packages/mopidy_soundcloud/actor.py", line 35, in translate_uri
    return track.uri
AttributeError: 'list' object has no attribute 'uri'
WARNING  Track is not playable: soundcloud:song/Light Reading.302741338