From f3b4182317ff3f41a1614218b6e91fcc4b699268 Mon Sep 17 00:00:00 2001 From: Amr Hassan Date: Fri, 19 Feb 2010 06:34:27 +0000 Subject: [PATCH] Fixed scrobbling with webservices authentication --- .build | 2 +- pylast.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.build b/.build index b5045cc..8fdd954 100644 --- a/.build +++ b/.build @@ -1 +1 @@ -21 \ No newline at end of file +22 \ No newline at end of file diff --git a/pylast.py b/pylast.py index 030e7f2..dc1e27e 100644 --- a/pylast.py +++ b/pylast.py @@ -3580,11 +3580,17 @@ class Scrobbler(object): """Handshakes with the server""" timestamp = str(int(time.time())) - token = md5(self.password + timestamp) + + if self.password and self.username: + token = md5(self.password + timestamp) + elif self.network.api_key and self.network.api_secret and self.network.session_key: + if not self.username: + self.username = self.network.get_authenticated_user().get_name() + token = md5(self.network.api_secret + timestamp) params = {"hs": "true", "p": "1.2.1", "c": self.client_id, "v": self.client_version, "u": self.username, "t": timestamp, - "a": token} + "a": token, "sk": self.network.session_key, "api_key": self.network.api_key} server = self.network.submission_server response = _ScrobblerRequest(server, params, self.network, "GET").execute().split("\n")