mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Implemented scrobbling
This commit is contained in:
parent
8cf93c3100
commit
e8c19a05e4
@ -69,7 +69,6 @@ class APIHandler:
|
|||||||
else:
|
else:
|
||||||
log("Unhandled Exception with " + self.__apiname__ + ": " + str(exceptiontype))
|
log("Unhandled Exception with " + self.__apiname__ + ": " + str(exceptiontype))
|
||||||
response.status,result = 500,{"status":"Unknown error","code":500}
|
response.status,result = 500,{"status":"Unknown error","code":500}
|
||||||
raise
|
|
||||||
|
|
||||||
return result
|
return result
|
||||||
#else:
|
#else:
|
||||||
|
@ -28,9 +28,9 @@ class AudioscrobblerLegacy(APIHandler):
|
|||||||
|
|
||||||
def get_method(self,pathnodes,keys):
|
def get_method(self,pathnodes,keys):
|
||||||
if keys.get("hs") == 'true': return 'handshake'
|
if keys.get("hs") == 'true': return 'handshake'
|
||||||
|
else: return pathnodes[0]
|
||||||
|
|
||||||
def handshake(self,pathnodes,keys):
|
def handshake(self,pathnodes,keys):
|
||||||
print(keys)
|
|
||||||
user = keys.get("u")
|
user = keys.get("u")
|
||||||
auth = keys.get("a")
|
auth = keys.get("a")
|
||||||
timestamp = keys.get("t")
|
timestamp = keys.get("t")
|
||||||
@ -66,25 +66,21 @@ 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:
|
||||||
iterating = True
|
for count in range(0,50):
|
||||||
count = 0
|
artist_key = f"a[{count}]"
|
||||||
while iterating:
|
track_key = f"t[{count}]"
|
||||||
t = "t"+str(count) # track
|
time_key = f"i[{count}]"
|
||||||
a = "a"+str(count) # artist
|
if artist_key in keys and track_key in keys:
|
||||||
i = "i"+str(count) # timestamp
|
artiststr,titlestr = keys[artist_key], keys[track_key]
|
||||||
if t in keys and a in keys:
|
|
||||||
artiststr,titlestr = keys[a], keys[t]
|
|
||||||
#(artists,title) = cla.fullclean(artiststr,titlestr)
|
|
||||||
try:
|
try:
|
||||||
timestamp = int(keys[i])
|
timestamp = int(keys[time_key])
|
||||||
except:
|
except:
|
||||||
timestamp = None
|
timestamp = None
|
||||||
#database.createScrobble(artists,title,timestamp)
|
#database.createScrobble(artists,title,timestamp)
|
||||||
self.scrobble(artiststr,titlestr,time=timestamp)
|
self.scrobble(artiststr,titlestr,time=timestamp)
|
||||||
count += 1
|
|
||||||
else:
|
else:
|
||||||
iterating = False
|
|
||||||
return 200,"OK"
|
return 200,"OK"
|
||||||
|
return 200,"OK"
|
||||||
|
|
||||||
|
|
||||||
import hashlib
|
import hashlib
|
||||||
|
Loading…
Reference in New Issue
Block a user