From 4682914b8888a2960751983f4f50ea83fae36cfe Mon Sep 17 00:00:00 2001 From: krateng Date: Thu, 7 Apr 2022 05:25:10 +0200 Subject: [PATCH] Ensured API consistency to v2 for scrobbling --- maloja/apis/native_v1.py | 13 ++++++++++++- maloja/database/__init__.py | 7 ++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/maloja/apis/native_v1.py b/maloja/apis/native_v1.py index 3d7a924..0e972b4 100644 --- a/maloja/apis/native_v1.py +++ b/maloja/apis/native_v1.py @@ -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 rawscrobble = {k:rawscrobble[k] for k in rawscrobble if rawscrobble[k]} - return database.incoming_scrobble( + result = database.incoming_scrobble( rawscrobble, client='browser' if auth_result.get('doreah_native_auth_check') else auth_result.get('client'), api='native/v1', fix=(keys.get("nofix") is None) ) + if result: + return { + 'status': 'success', + 'track': { + 'artists':result['track']['artists'], + 'title':result['track']['title'] + } + } + else: + return {"status":"failure"} + diff --git a/maloja/database/__init__.py b/maloja/database/__init__.py index bd42963..267a4a3 100644 --- a/maloja/database/__init__.py +++ b/maloja/database/__init__.py @@ -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): 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}") @@ -127,8 +128,8 @@ def incoming_scrobble(rawscrobble,fix=True,client=None,api=None,dbconn=None): dbcache.invalidate_caches(scrobbledict['time']) - return {"status":"success","scrobble":scrobbledict} - + #return {"status":"success","scrobble":scrobbledict} + return scrobbledict