python - Enable proxy support of pyLast -
i want enable proxy, found method named enable_proxy
, when this:
network = pylast.lastfmnetwork(api_key = api_key, api_secret = api_secret, username = username, password_hash = password_hash) network.enable_proxy("http//...", 8080)
i network error: [errno 11004] getaddrinfo failed
, because call of pylast.lastfmnetwork
tries generate network session key. how can enable proxy support of pylast? don't find example.
if don't need scrobble, can create network object without session key omitting username/password hash, here:
- https://github.com/ticklemynausea/mbot-shell/blob/199d65c5841cb7e0f9f2cc5aec677bcb45ffe5b4/lastfm/lastfm.py#l34
- https://github.com/devilcius/last2what/blob/8d6b0a87dc25a859c137670fee67643c99e0c78d/last2what.py#l103
like this:
network = pylast.lastfmnetwork(api_key, api_secret) if proxy_enabled: network.enable_proxy(host = proxy_host, port = proxy_port)
do need scrobble? if so, try after enabling 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, if don't have authenticate yourself, second 1 should work (with latest github version of pylast; there's bug fix not yet released).
Comments
Post a Comment