mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
API improvements
This commit is contained in:
parent
ac29f9728e
commit
e70cb3e037
@ -5,7 +5,7 @@ author = {
|
|||||||
"email":"maloja@krateng.dev",
|
"email":"maloja@krateng.dev",
|
||||||
"github": "krateng"
|
"github": "krateng"
|
||||||
}
|
}
|
||||||
version = 2,10,1
|
version = 2,10,2
|
||||||
versionstr = ".".join(str(n) for n in version)
|
versionstr = ".".join(str(n) for n in version)
|
||||||
links = {
|
links = {
|
||||||
"pypi":"malojaserver",
|
"pypi":"malojaserver",
|
||||||
|
@ -4,7 +4,7 @@ from .audioscrobbler_legacy import AudioscrobblerLegacy
|
|||||||
from .listenbrainz import Listenbrainz
|
from .listenbrainz import Listenbrainz
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
from bottle import redirect, request
|
from bottle import redirect, request, response
|
||||||
from urllib.parse import urlencode
|
from urllib.parse import urlencode
|
||||||
|
|
||||||
native_apis = [
|
native_apis = [
|
||||||
@ -40,3 +40,10 @@ def init_apis(server):
|
|||||||
server.post(altpath_empty)(alias_api)
|
server.post(altpath_empty)(alias_api)
|
||||||
server.get(altpath_empty_cl)(alias_api)
|
server.get(altpath_empty_cl)(alias_api)
|
||||||
server.post(altpath_empty_cl)(alias_api)
|
server.post(altpath_empty_cl)(alias_api)
|
||||||
|
|
||||||
|
def invalid_api(pth):
|
||||||
|
response.status = 404
|
||||||
|
return {"error":"Invalid API"}
|
||||||
|
|
||||||
|
server.get("/apis/<pth:path>")(invalid_api)
|
||||||
|
server.post("/apis/<pth:path>")(invalid_api)
|
||||||
|
@ -20,11 +20,11 @@ class AudioscrobblerLegacy(APIHandler):
|
|||||||
"scrobble":self.submit_scrobble
|
"scrobble":self.submit_scrobble
|
||||||
}
|
}
|
||||||
self.errors = {
|
self.errors = {
|
||||||
BadAuthException:(200,"BADAUTH"),
|
BadAuthException:(403,"BADAUTH\n"),
|
||||||
InvalidAuthException:(200,"BADAUTH"),
|
InvalidAuthException:(403,"BADAUTH\n"),
|
||||||
InvalidMethodException:(200,"FAILED"),
|
InvalidMethodException:(400,"FAILED\n"),
|
||||||
InvalidSessionKey:(200,"BADSESSION"),
|
InvalidSessionKey:(403,"BADSESSION\n"),
|
||||||
ScrobblingException:(500,"FAILED")
|
ScrobblingException:(500,"FAILED\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_method(self,pathnodes,keys):
|
def get_method(self,pathnodes,keys):
|
||||||
@ -61,7 +61,7 @@ class AudioscrobblerLegacy(APIHandler):
|
|||||||
if keys.get("s") is None or keys.get("s") not in self.mobile_sessions:
|
if keys.get("s") is None or keys.get("s") not in self.mobile_sessions:
|
||||||
raise InvalidSessionKey()
|
raise InvalidSessionKey()
|
||||||
else:
|
else:
|
||||||
return "OK"
|
return 200,"OK\n"
|
||||||
|
|
||||||
def submit_scrobble(self,pathnodes,keys):
|
def submit_scrobble(self,pathnodes,keys):
|
||||||
if keys.get("s") is None or keys.get("s") not in self.mobile_sessions:
|
if keys.get("s") is None or keys.get("s") not in self.mobile_sessions:
|
||||||
@ -80,8 +80,8 @@ class AudioscrobblerLegacy(APIHandler):
|
|||||||
#database.createScrobble(artists,title,timestamp)
|
#database.createScrobble(artists,title,timestamp)
|
||||||
self.scrobble(artiststr,titlestr,time=timestamp)
|
self.scrobble(artiststr,titlestr,time=timestamp)
|
||||||
else:
|
else:
|
||||||
return 200,"OK"
|
return 200,"OK\n"
|
||||||
return 200,"OK"
|
return 200,"OK\n"
|
||||||
|
|
||||||
|
|
||||||
import hashlib
|
import hashlib
|
||||||
|
Loading…
x
Reference in New Issue
Block a user