1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00

Ensured API consistency to v2 for scrobbling

This commit is contained in:
krateng 2022-04-07 05:25:10 +02:00
parent 781ed66357
commit 4682914b88
2 changed files with 16 additions and 4 deletions

View File

@ -250,13 +250,24 @@ def post_scrobble(artist:Multi=None,auth_result=None,**keys):
# for logging purposes, don't pass values that we didn't actually supply # for logging purposes, don't pass values that we didn't actually supply
rawscrobble = {k:rawscrobble[k] for k in rawscrobble if rawscrobble[k]} rawscrobble = {k:rawscrobble[k] for k in rawscrobble if rawscrobble[k]}
return database.incoming_scrobble( result = database.incoming_scrobble(
rawscrobble, rawscrobble,
client='browser' if auth_result.get('doreah_native_auth_check') else auth_result.get('client'), client='browser' if auth_result.get('doreah_native_auth_check') else auth_result.get('client'),
api='native/v1', api='native/v1',
fix=(keys.get("nofix") is None) fix=(keys.get("nofix") is None)
) )
if result:
return {
'status': 'success',
'track': {
'artists':result['track']['artists'],
'title':result['track']['title']
}
}
else:
return {"status":"failure"}

View File

@ -90,7 +90,8 @@ def incoming_scrobble(rawscrobble,fix=True,client=None,api=None,dbconn=None):
if (not "track_artists" in rawscrobble) or (len(rawscrobble['track_artists']) == 0) or (not "track_title" in rawscrobble): if (not "track_artists" in rawscrobble) or (len(rawscrobble['track_artists']) == 0) or (not "track_title" in rawscrobble):
log(f"Invalid Scrobble [Client: {client} | API: {api}]: {rawscrobble} ",color='red') log(f"Invalid Scrobble [Client: {client} | API: {api}]: {rawscrobble} ",color='red')
return {"status":"failure"} #return {"status":"failure"}
return False
log(f"Incoming scrobble [Client: {client} | API: {api}]: {rawscrobble}") log(f"Incoming scrobble [Client: {client} | API: {api}]: {rawscrobble}")
@ -127,8 +128,8 @@ def incoming_scrobble(rawscrobble,fix=True,client=None,api=None,dbconn=None):
dbcache.invalidate_caches(scrobbledict['time']) dbcache.invalidate_caches(scrobbledict['time'])
return {"status":"success","scrobble":scrobbledict} #return {"status":"success","scrobble":scrobbledict}
return scrobbledict