From f938e34b0a81d7807526ca03922b6c3940d92232 Mon Sep 17 00:00:00 2001 From: Alban Date: Sun, 9 Dec 2012 16:13:50 +0100 Subject: [PATCH] Fix LastFM support on tracks with non ASCII info --- api/media.py | 5 ++++- lastfm.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/api/media.py b/api/media.py index e540fbc..79d11c7 100755 --- a/api/media.py +++ b/api/media.py @@ -87,7 +87,10 @@ def scrobble(): else: time = int(now()) - user = User.query.filter(User.name == u).one() + if u: + user = User.query.filter(User.name == u).one() + else: + user = User.query.filter(User.name == request.authorization.username).one() lfm = LastFm(user, app.logger) if submission in (None, '', True, 'true', 'True', 1, '1'): diff --git a/lastfm.py b/lastfm.py index 82e2247..17324ee 100755 --- a/lastfm.py +++ b/lastfm.py @@ -57,7 +57,10 @@ class LastFm: sig_str = '' for k, v in sorted(kwargs.iteritems()): - sig_str += k + str(v) + if type(v) is unicode: + sig_str += k + v.encode('utf-8') + else: + sig_str += k + str(v) sig = hashlib.md5(sig_str + self.__api_secret).hexdigest() kwargs['api_sig'] = sig