mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Updated listenbrainz endpoint, should fix GH-86
This commit is contained in:
parent
5157ce825e
commit
33af60ed2c
@ -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",
|
||||
|
@ -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()
|
||||
|
@ -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.
|
||||
<br/><br/>
|
||||
You can also use any standard-compliant scrobbler. For GNUFM (audioscrobbler) scrobblers, enter <span class="stats"><span name="serverurl">yourserver.tld</span>/api/s/audioscrobbler</span> as your Gnukebox server and your API key as the password. For Listenbrainz scrobblers, use <span class="stats"><span name="serverurl">yourserver.tld</span>/api/s/listenbrainz</span> as the API URL and your API key as token.
|
||||
You can also use any standard-compliant scrobbler. For GNUFM (audioscrobbler) scrobblers, enter <span class="stats"><span name="serverurl">yourserver.tld</span>/apis/audioscrobbler</span> as your Gnukebox server and your API key as the password. For Listenbrainz scrobblers, use <span class="stats"><span name="serverurl">yourserver.tld</span>/apis/listenbrainz</span> as the API URL and your API key as token.
|
||||
<br/><br/>
|
||||
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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user