mopidy / mopidy-soundcloud

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

Plugin broken #3

Closed buchinho closed 10 years ago

buchinho commented 11 years ago

Just started using the plugin but it does not seem to work for me. Here's my config:

[soundcloud] auth_token = XXXXXXXXXXXXXXXXXXXXXXXXx explore = world/Cumbia, world/Bhangra, world/African

and it crashes: http://pastebin.com/46bNXdwJ

buchinho commented 11 years ago

INFO Audio mixer set to "alsamixer" using track "Master" INFO Starting new HTTPS connection (1): api.soundcloud.com ERROR SoundCloud Authentication error: 'dict' object is not callable ERROR 'NoneType' object has no attribute 'get'

buchinho commented 11 years ago

Nope. This is a different issue! mopidy crashes. Please have a look at the pastebin URL.

dz0ny commented 11 years ago

That means your auth token is invalid. Did you get yours at http://www.mopidy.com/authenticate#soundcloud?

jodal commented 11 years ago

Could you make it log an error message instead of printing a traceback when authentication fails?

buchinho commented 11 years ago

Nope. Still not working. Maybe the problem is that my authentication key has letters in it? It looks like similar to this: auth_token = 1-84732-5433994-6f9665fc26157dd0

dz0ny commented 11 years ago

try this one

auth_token = 1-35204-52832692-ce16393164b23ee

Tested and it works. If it doesn't work, maybe you are banned from soundcloud(ip address).

buchinho commented 11 years ago

Still not working properly. I'm not banned, I changed my IP, even used your auth_token. It seems to be something else. Is there a way to check the interaction between mopidy and soundcloud? (Handshake, ...)

dz0ny commented 11 years ago

http://docs.mopidy.com/en/latest/running/#cmdoption-mopidy-v also try here http://developers.soundcloud.com/console

buchinho commented 11 years ago

Good! It seems to be the Client ID! The error appears just after mopidy_soundcloud gets the URL with the client-id included. This Client ID is hardcoded in the soundcloud.py.

Starting new HTTPS connection (1): api.soundcloud.com DEBUG 2013-07-31 22:33:54,000 [5235:MainThread] requests.packages.urllib3.connectionpool "GET /me.json?client_id=93e33e327fd8a9b77becd179652272e2 HTTP/1.1" 200 758 ERROR 2013-07-31 22:33:54,005 [5235:MainThread] mopidy.backends.soundcloud.client SoundCloud error: 'dict' object is not callable

Now if I open the URL that mopidy_soundcloud wants to pick up I get this:

{"errors":[{"error_message":"401 - Unauthorized"}]}

Obviously there seems to be something wrong with the client_id. From the context I figured out that mopidy_soundcloud has this Client ID to tell Soundcloud which kind of software uses the API. But what's up with the error then?

dz0ny commented 11 years ago

If the client id was wrong, then it wouldn't load for other users including me. The url part is beacuse you are missing Authorization header(you can't just open url in browser it won't work).

buchinho commented 11 years ago

I believe that it works with other peoples installs but why on earth does it not at my place? Can you help me figure it out? I don't know where else to start looking for potential problems.

dz0ny commented 11 years ago

Try running

curl -H "Authorization: OAuth 1-35204-52832692-ce16393164b23ee" "https://api.soundcloud.com/me.json?client_id=93e33e327fd8a9b77becd179652272e2"

it should give you

{
    "id": 52832692,
    "kind": "user",
    "permalink": "user581001298",
    "username": "user581001298",
    "uri": "https://api.soundcloud.com/users/52832692",
    "permalink_url": "http://soundcloud.com/user581001298",
    "avatar_url": "https://a1.sndcdn.com/images/default_avatar_large.png?5ffe3cd",
    "country": null,
    "full_name": "",
    "description": null,
    "city": null,
    "discogs_name": null,
    "myspace_name": null,
    "website": null,
    "website_title": null,
    "online": true,
    "track_count": 0,
    "playlist_count": 0,
    "plan": "Free",
    "public_favorites_count": 0,
    "followers_count": 0,
    "followings_count": 32,
    "subscriptions": [],
    "upload_seconds_left": 7200,
    "quota": {
        "unlimited_upload_quota": false,
        "upload_seconds_used": 0,
        "upload_seconds_left": 7200
    },
    "private_tracks_count": 0,
    "private_playlists_count": 0,
    "primary_email_confirmed": false
}
igorski commented 11 years ago

Same problem here. When I start Mopidy the error I get is:

INFO Starting new HTTPS connection (1): api.soundcloud.com ERROR SoundCloud error: 'dict' object is not callable ERROR Authentication error: 'NoneType' object has no attribute 'get'. Check your auth_token! ERROR SoundCloud error: 'dict' object is not callable

The auth_token is set in mopidy.conf and requested from Soundcloud via the Mopidy site.

If I use the curl command mentioned above with my personal auth_token the JSON response is valid. But for some reason above error is thrown when starting Mopidy with Soundcloud enabled... I'm running Debian Wheezy on a Raspberry Pi. Are there any updates on this issue since the last posts above ?

FrederikP commented 11 years ago

I am having the same problem as described above.

I also get a valid response using the curl command. The response includes my username and so on.

Are there any suggestions on how to troubleshoot this issue?

woutervanwijk commented 10 years ago

A me too. Error on Ubuntu 12. I also get a valid response using curl.

dz0ny commented 10 years ago

@woutervanwijk and @FrederikP i think you have older version of requests module. Can you confirm that this branch works via pip install https://github.com/mopidy/mopidy-soundcloud/archive/bug/issue-3.zip

woutervanwijk commented 10 years ago

That works indeed!

johntyree commented 10 years ago

@dz0ny I have requests 2.1.0 and I'm getting errors playing SoundCloud tracks and only SoundCloud tracks as well.

ERROR    Unhandled exception in MpdSession (urn:uuid:22d2adf6-dd61-4c64-8115-d8ea4c00ad14):
Traceback (most recent call last):
  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 303, in _handle_receive
    return self.on_receive(message)
  File "/usr/lib/python2.7/site-packages/mopidy/utils/network.py", line 354, in on_receive
    self.on_line_received(line)
  File "/usr/lib/python2.7/site-packages/mopidy/frontends/mpd/session.py", line 33, in on_line_received
    response = self.dispatcher.handle_request(line)
  File "/usr/lib/python2.7/site-packages/mopidy/frontends/mpd/dispatcher.py", line 46, in handle_request
    return self._call_next_filter(request, response, filter_chain)
  File "/usr/lib/python2.7/site-packages/mopidy/frontends/mpd/dispatcher.py", line 67, in _call_next_filter
    return next_filter(request, response, filter_chain)
  File "/usr/lib/python2.7/site-packages/mopidy/frontends/mpd/dispatcher.py", line 75, in _catch_mpd_ack_errors_filter
    return self._call_next_filter(request, response, filter_chain)
  File "/usr/lib/python2.7/site-packages/mopidy/frontends/mpd/dispatcher.py", line 67, in _call_next_filter
    return next_filter(request, response, filter_chain)
  File "/usr/lib/python2.7/site-packages/mopidy/frontends/mpd/dispatcher.py", line 88, in _authenticate_filter
    return self._call_next_filter(request, response, filter_chain)
  File "/usr/lib/python2.7/site-packages/mopidy/frontends/mpd/dispatcher.py", line 67, in _call_next_filter
    return next_filter(request, response, filter_chain)
  File "/usr/lib/python2.7/site-packages/mopidy/frontends/mpd/dispatcher.py", line 106, in _command_list_filter
    response = self._call_next_filter(request, response, filter_chain)
  File "/usr/lib/python2.7/site-packages/mopidy/frontends/mpd/dispatcher.py", line 67, in _call_next_filter
    return next_filter(request, response, filter_chain)
  File "/usr/lib/python2.7/site-packages/mopidy/frontends/mpd/dispatcher.py", line 135, in _idle_filter
    response = self._call_next_filter(request, response, filter_chain)
  File "/usr/lib/python2.7/site-packages/mopidy/frontends/mpd/dispatcher.py", line 67, in _call_next_filter
    return next_filter(request, response, filter_chain)
  File "/usr/lib/python2.7/site-packages/mopidy/frontends/mpd/dispatcher.py", line 148, in _add_ok_filter
    response = self._call_next_filter(request, response, filter_chain)
  File "/usr/lib/python2.7/site-packages/mopidy/frontends/mpd/dispatcher.py", line 67, in _call_next_filter
    return next_filter(request, response, filter_chain)
  File "/usr/lib/python2.7/site-packages/mopidy/frontends/mpd/dispatcher.py", line 160, in _call_handler_filter
    response = self._format_response(self._call_handler(request))
  File "/usr/lib/python2.7/site-packages/mopidy/frontends/mpd/dispatcher.py", line 168, in _call_handler
    return handler(self.context, **kwargs)
  File "/usr/lib/python2.7/site-packages/mopidy/frontends/mpd/protocol/status.py", line 192, in status
    pykka.get_all(futures.values())
  File "/usr/lib/python2.7/site-packages/pykka/future.py", line 330, in get_all
    return [future.get(timeout=timeout) for future in futures]
  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 296, in _handle_receive
    attr = self._get_attribute_from_path(message['attr_path'])
  File "/usr/lib/python2.7/site-packages/pykka/actor.py", line 325, in _get_attribute_from_path
    attr = getattr(attr, attr_name)
  File "/usr/lib/python2.7/site-packages/mopidy/core/playback.py", line 82, in get_time_position
    backend = self._get_backend()
  File "/usr/lib/python2.7/site-packages/mopidy/core/playback.py", line 29, in _get_backend
    uri = self.current_tl_track.track.uri
AttributeError: 'NoneType' object has no attribute 'uri'
johntyree commented 10 years ago

pip install https://github.com/mopidy/mopidy-soundcloud/archive/bug/issue-3.zip fails to load any songs in 'Explore ambient' playlist, but does load a personal playlist. Not sure what to make of that.

johntyree commented 10 years ago

I think it's just timing out on the Explore list. It seems to load one out of 4 or 5 tries.

johntyree commented 10 years ago

Ok scratch that. It first reports an empty playlist in ncmpcpp, but if you wait two or three minutes, it will suddenly populate. This is a great feature, but there's got to be a way to increase responsiveness...

dz0ny commented 10 years ago

@johntyree This is how their api works, for every song you need to request full data. This functionality however has been removed from their unofficial web api (they replaced playlists with simple "what's trending"). When this happens it will also be removed from extension.

johntyree commented 10 years ago

Meaning "Explore" will no longer be possible from the extension? It's the best feature :D . Do you expect to be able to do some kind of radio-style discovery+streaming through mopidy-soundcloud? I can contribute here in the future, after I get up to speed on the soundcloud api and mopidy internals (which admittedly will probably take some time and effort)

jodal commented 10 years ago

@dz0ny Anything we can fix here, or should this be closed again?