diff --git a/maloja/__pkginfo__.py b/maloja/__pkginfo__.py index 44adf1b..4d61a5b 100644 --- a/maloja/__pkginfo__.py +++ b/maloja/__pkginfo__.py @@ -5,7 +5,7 @@ author = { "email":"maloja@dev.krateng.ch", "github": "krateng" } -version = 2,12,14 +version = 2,12,15 versionstr = ".".join(str(n) for n in version) links = { "pypi":"malojaserver", diff --git a/maloja/apis/listenbrainz.py b/maloja/apis/listenbrainz.py index 5e58734..8c82f4b 100644 --- a/maloja/apis/listenbrainz.py +++ b/maloja/apis/listenbrainz.py @@ -30,7 +30,7 @@ class Listenbrainz(APIHandler): def submit(self,pathnodes,keys): try: - token = keys.get("Authorization").replace("token ","").replace("Token ","").strip() + token = self.get_token_from_request_keys(keys) except: raise BadAuthException() @@ -56,7 +56,7 @@ class Listenbrainz(APIHandler): timestamp = None except: raise MalformedJSONException() - + self.scrobble(artiststr,titlestr,timestamp) return 200,{"status":"ok"} @@ -64,10 +64,21 @@ class Listenbrainz(APIHandler): def validate_token(self,pathnodes,keys): try: - token = keys.get("token").strip() + token = self.get_token_from_request_keys(keys) except: raise BadAuthException() if token not in database.allAPIkeys(): raise InvalidAuthException() else: return 200,{"code":200,"message":"Token valid.","valid":True,"user_name":"n/a"} + + def get_token_from_request_keys(self,keys): + if 'token' in keys: + return keys.get("token").strip() + if 'Authorization' in keys: + auth = keys.get("Authorization") + if auth.startswith('token '): + return auth.replace("token ","",1).strip() + if auth.startswith('Token '): + return auth.replace("Token ","",1).strip() + raise BadAuthException() diff --git a/maloja/web/jinja/admin_setup.jinja b/maloja/web/jinja/admin_setup.jinja index 531a38e..233da8e 100644 --- a/maloja/web/jinja/admin_setup.jinja +++ b/maloja/web/jinja/admin_setup.jinja @@ -56,7 +56,7 @@ If you use Vivaldi, Brave, Iridium or any other Chromium-based browser and listen to music on Plex or YouTube Music, download the extension and simply enter the server URL as well as your API key in the relevant fields. They will turn green if the server is accessible.

- You can also use any standard-compliant scrobbler. For GNUFM (audioscrobbler) scrobblers, enter yourserver.tld/api/s/audioscrobbler as your Gnukebox server and your API key as the password. For Listenbrainz scrobblers, use yourserver.tld/api/s/listenbrainz as the API URL and your API key as token. + You can also use any standard-compliant scrobbler. For GNUFM (audioscrobbler) scrobblers, enter yourserver.tld/apis/audioscrobbler as your Gnukebox server and your API key as the password. For Listenbrainz scrobblers, use yourserver.tld/apis/listenbrainz as the API URL and your API key as token.

If you use another browser or another music player, you could try to code your own extension. The API is super simple! Just send a POST HTTP request to