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