Scrobble origin is now saved

This commit is contained in:
krateng 2022-02-14 06:07:54 +01:00
parent 78c50d24d9
commit fee94a88c5
4 changed files with 18 additions and 6 deletions

View File

@ -4,7 +4,7 @@
# you know what f*ck it
# this is hardcoded for now because of that damn project / package name discrepancy
# i'll fix it one day
VERSION = "3.0.0-dev"
VERSION = "3.0.0-alpha.1"
HOMEPAGE = "https://github.com/krateng/maloja"

View File

@ -3,6 +3,7 @@ from ..globalconf import apikeystore
# skip regular authentication if api key is present in request
# an api key now ONLY permits scrobbling tracks, no other admin tasks
def api_key_correct(request):
request.malojaclient = None
args = request.params
try:
args.update(request.json)
@ -13,7 +14,13 @@ def api_key_correct(request):
elif "apikey" in args:
apikey = args.pop("apikey")
else: return False
return checkAPIkey(apikey)
if checkAPIkey(apikey):
request.malojaclient = [c for c in apikeystore if apikeystore[c]==apikey][0]
return True
else:
return False
def checkAPIkey(key):
return apikeystore.check_key(key)
def allAPIkeys():

View File

@ -234,9 +234,10 @@ def post_scrobble(artist:Multi=None,**keys):
#artists = "/".join(artist)
keys['artists'] = [artist] if artist is not None else keys.get("artists")
keys['fix'] = keys.get("nofix") is None
if time is not None: time = int(time)
if keys.get('time') is not None: keys['time'] = int(time)
return incoming_scrobble(**keys)
return incoming_scrobble(**keys,client=request.malojaclient)
# TODO: malojaclient needs to be converted to proper argument in doreah

View File

@ -72,7 +72,10 @@ coa = CollectorAgent()
def incoming_scrobble(artists,title,album=None,albumartists=None,duration=None,length=None,time=None,fix=True):
def incoming_scrobble(artists,title,album=None,albumartists=None,duration=None,length=None,time=None,fix=True,client=None,**kwargs):
# TODO: just collecting all extra kwargs now. at some point, rework the authenticated api with alt function
# to actually look at the converted args instead of the request object and remove the key
# so that this function right here doesnt get the key passed to it
if time is None:
time = int(datetime.datetime.now(tz=datetime.timezone.utc).timestamp())
@ -98,9 +101,10 @@ def incoming_scrobble(artists,title,album=None,albumartists=None,duration=None,l
"length":None
},
"duration":duration,
"origin":"generic"
"origin":"client:" + client if client else "generic"
}
sqldb.add_scrobble(scrobbledict)
proxy_scrobble_all(artists,title,time)