mirror of
https://github.com/krateng/maloja.git
synced 2025-07-09 03:04:07 -04:00
make auth.getMobileSession
return XML
This commit is contained in:
parent
44f58e31bc
commit
7dbd704c5d
@ -28,6 +28,15 @@ class Audioscrobbler(APIHandler):
|
|||||||
ScrobblingException:(500,{"error":8,"message":"Operation failed"})
|
ScrobblingException:(500,{"error":8,"message":"Operation failed"})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# xml string escaping: https://stackoverflow.com/a/28703510
|
||||||
|
def xml_escape(self, str_xml: str):
|
||||||
|
str_xml = str_xml.replace("&", "&")
|
||||||
|
str_xml = str_xml.replace("<", "<")
|
||||||
|
str_xml = str_xml.replace("<", "<")
|
||||||
|
str_xml = str_xml.replace("\"", """)
|
||||||
|
str_xml = str_xml.replace("'", "'")
|
||||||
|
return str_xml
|
||||||
|
|
||||||
def get_method(self,pathnodes,keys):
|
def get_method(self,pathnodes,keys):
|
||||||
return keys.get("method")
|
return keys.get("method")
|
||||||
|
|
||||||
@ -50,7 +59,14 @@ class Audioscrobbler(APIHandler):
|
|||||||
client = apikeystore.check_and_identify_key(password)
|
client = apikeystore.check_and_identify_key(password)
|
||||||
if client:
|
if client:
|
||||||
sessionkey = self.generate_key(client)
|
sessionkey = self.generate_key(client)
|
||||||
return 200,{"session":{"key":sessionkey}}
|
return 200,"""<lfm status="ok">
|
||||||
|
<session>
|
||||||
|
<name>%s</name>
|
||||||
|
<key>%s</key>
|
||||||
|
<subscriber>0</subscriber>
|
||||||
|
</session>
|
||||||
|
</lfm>
|
||||||
|
""" % (self.xml_escape(user), self.xml_escape(sessionkey))
|
||||||
else:
|
else:
|
||||||
raise InvalidAuthException()
|
raise InvalidAuthException()
|
||||||
# or username and token (deprecated by lastfm)
|
# or username and token (deprecated by lastfm)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user