1
0
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:
Krateng 2020-09-13 10:26:05 +02:00
commit 2da9f154be
No known key found for this signature in database
GPG Key ID: 46735607861C6FCE

View File

@ -40,26 +40,28 @@ class Listenbrainz(APIHandler):
try:
listentype = keys["listen_type"]
payload = keys["payload"]
if listentype in ["single","import"]:
for listen in payload:
except:
raise MalformedJSONException()
if listentype == "playing_now":
return 200,{"status":"ok"}
elif listentype in ["single","import"]:
for listen in payload:
try:
metadata = listen["track_metadata"]
artiststr, titlestr = metadata["artist_name"], metadata["track_name"]
#(artists,title) = cla.fullclean(artiststr,titlestr)
try:
timestamp = int(listen["listened_at"])
except:
timestamp = None
elif listentype == "playing_now":
pass
except:
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"}
def validate_token(self,pathnodes,keys):
try:
token = keys.get("token").strip()