mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Scrobble origin is now saved
This commit is contained in:
parent
78c50d24d9
commit
fee94a88c5
@ -4,7 +4,7 @@
|
|||||||
# you know what f*ck it
|
# you know what f*ck it
|
||||||
# this is hardcoded for now because of that damn project / package name discrepancy
|
# this is hardcoded for now because of that damn project / package name discrepancy
|
||||||
# i'll fix it one day
|
# i'll fix it one day
|
||||||
VERSION = "3.0.0-dev"
|
VERSION = "3.0.0-alpha.1"
|
||||||
HOMEPAGE = "https://github.com/krateng/maloja"
|
HOMEPAGE = "https://github.com/krateng/maloja"
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ from ..globalconf import apikeystore
|
|||||||
# skip regular authentication if api key is present in request
|
# skip regular authentication if api key is present in request
|
||||||
# an api key now ONLY permits scrobbling tracks, no other admin tasks
|
# an api key now ONLY permits scrobbling tracks, no other admin tasks
|
||||||
def api_key_correct(request):
|
def api_key_correct(request):
|
||||||
|
request.malojaclient = None
|
||||||
args = request.params
|
args = request.params
|
||||||
try:
|
try:
|
||||||
args.update(request.json)
|
args.update(request.json)
|
||||||
@ -13,7 +14,13 @@ def api_key_correct(request):
|
|||||||
elif "apikey" in args:
|
elif "apikey" in args:
|
||||||
apikey = args.pop("apikey")
|
apikey = args.pop("apikey")
|
||||||
else: return False
|
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):
|
def checkAPIkey(key):
|
||||||
return apikeystore.check_key(key)
|
return apikeystore.check_key(key)
|
||||||
def allAPIkeys():
|
def allAPIkeys():
|
||||||
|
@ -234,9 +234,10 @@ def post_scrobble(artist:Multi=None,**keys):
|
|||||||
#artists = "/".join(artist)
|
#artists = "/".join(artist)
|
||||||
keys['artists'] = [artist] if artist is not None else keys.get("artists")
|
keys['artists'] = [artist] if artist is not None else keys.get("artists")
|
||||||
keys['fix'] = keys.get("nofix") is None
|
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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -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:
|
if time is None:
|
||||||
time = int(datetime.datetime.now(tz=datetime.timezone.utc).timestamp())
|
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
|
"length":None
|
||||||
},
|
},
|
||||||
"duration":duration,
|
"duration":duration,
|
||||||
"origin":"generic"
|
"origin":"client:" + client if client else "generic"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sqldb.add_scrobble(scrobbledict)
|
sqldb.add_scrobble(scrobbledict)
|
||||||
proxy_scrobble_all(artists,title,time)
|
proxy_scrobble_all(artists,title,time)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user