mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Merge branch 'master' of github.com:krateng/maloja
This commit is contained in:
commit
2da9f154be
@ -40,26 +40,28 @@ class Listenbrainz(APIHandler):
|
|||||||
try:
|
try:
|
||||||
listentype = keys["listen_type"]
|
listentype = keys["listen_type"]
|
||||||
payload = keys["payload"]
|
payload = keys["payload"]
|
||||||
if listentype in ["single","import"]:
|
except:
|
||||||
for listen in payload:
|
raise MalformedJSONException()
|
||||||
|
|
||||||
|
if listentype == "playing_now":
|
||||||
|
return 200,{"status":"ok"}
|
||||||
|
elif listentype in ["single","import"]:
|
||||||
|
for listen in payload:
|
||||||
|
try:
|
||||||
metadata = listen["track_metadata"]
|
metadata = listen["track_metadata"]
|
||||||
artiststr, titlestr = metadata["artist_name"], metadata["track_name"]
|
artiststr, titlestr = metadata["artist_name"], metadata["track_name"]
|
||||||
#(artists,title) = cla.fullclean(artiststr,titlestr)
|
|
||||||
try:
|
try:
|
||||||
timestamp = int(listen["listened_at"])
|
timestamp = int(listen["listened_at"])
|
||||||
except:
|
except:
|
||||||
timestamp = None
|
timestamp = None
|
||||||
elif listentype == "playing_now":
|
except:
|
||||||
pass
|
raise MalformedJSONException()
|
||||||
except:
|
|
||||||
raise MalformedJSONException()
|
self.scrobble(artiststr,titlestr,timestamp)
|
||||||
|
|
||||||
|
|
||||||
if listentype == "playing_now": return 200,{"status":"ok"}
|
|
||||||
else:
|
|
||||||
self.scrobble(artiststr,titlestr,timestamp)
|
|
||||||
return 200,{"status":"ok"}
|
return 200,{"status":"ok"}
|
||||||
|
|
||||||
|
|
||||||
def validate_token(self,pathnodes,keys):
|
def validate_token(self,pathnodes,keys):
|
||||||
try:
|
try:
|
||||||
token = keys.get("token").strip()
|
token = keys.get("token").strip()
|
||||||
|
Loading…
Reference in New Issue
Block a user