1

I want to enable the proxy, I found a method named enable_proxy, but when I do it like this:

network = pylast.LastFMNetwork(api_key = API_KEY, api_secret = API_SECRET, username = username, password_hash = password_hash)

network.enable_proxy("http//...", 8080)

I get a network error: [Errno 11004] getaddrinfo failed, because the call of pylast.LastFMNetwork tries to generate a network session key. How can I enable the proxy support of pylast? I don't find any example.

Hugo
  • 27,885
  • 8
  • 82
  • 98

1 Answers1

0

If you don't need to scrobble, you can create a network object without the session key by omitting a username/password hash, like here:

Like this:

network = pylast.LastFMNetwork(api_key, api_secret)
if proxy_enabled:
    network.enable_proxy(host = proxy_host, port = proxy_port)

Do you need to scrobble? If so, try something like this after enabling the proxy:

network.username = my_username
network.password_hash = my_password_hash
sk_gen = SessionKeyGenerator(network)
network.session_key = sk_gen.get_session_key(my_username, my_password_hash)

Note: httplib.HTTPConnection doesn't support authentication, so if you don't have to authenticate yourself, the second one should work (with the latest GitHub version of pylast; there's a bug fix not yet released).

See also: https://github.com/pylast/pylast/issues/103

Hugo
  • 27,885
  • 8
  • 82
  • 98