mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Separation now on all relevant functions
This commit is contained in:
parent
de02c53e52
commit
e4b9ca1d81
37
database.py
37
database.py
@ -478,9 +478,15 @@ def getNext(time,unit="auto",step=1):
|
||||
return getNext(time,"day",step * 7)
|
||||
|
||||
@dbserver.route("/artistinfo")
|
||||
def artistInfo():
|
||||
def artistInfo_external():
|
||||
keys = FormsDict.decode(request.query)
|
||||
artist = keys.get("artist")
|
||||
ckeys = {}
|
||||
ckeys["artist"] = keys.get("artist")
|
||||
|
||||
results = artistInfo(**ckeys)
|
||||
return results
|
||||
|
||||
def artistInfo(artist):
|
||||
|
||||
charts = db_aggregate(by="ARTIST")
|
||||
scrobbles = len(db_query(artists=[artist])) #we cant take the scrobble number from the charts because that includes all countas scrobbles
|
||||
@ -494,19 +500,28 @@ def artistInfo():
|
||||
c = [e for e in charts if e["artist"] == artist][0]
|
||||
return {"replace":artist,"scrobbles":scrobbles,"position":charts.index(c) + 1}
|
||||
|
||||
@dbserver.route("/trackinfo")
|
||||
def trackInfo():
|
||||
keys = FormsDict.decode(request.query)
|
||||
artists = keys.getall("artist")
|
||||
title = keys.get("title")
|
||||
|
||||
|
||||
|
||||
|
||||
@dbserver.route("/trackinfo")
|
||||
def trackInfo_external():
|
||||
keys = FormsDict.decode(request.query)
|
||||
ckeys = {}
|
||||
ckeys["artists"],ckeys["title"] = keys.getall("artist"), keys.get("title")
|
||||
|
||||
results = trackInfo(**ckeys)
|
||||
return results
|
||||
|
||||
def trackInfo(artists,title):
|
||||
charts = db_aggregate(by="TRACK")
|
||||
scrobbles = len(db_query(artists=artists,title=title)) #we cant take the scrobble number from the charts because that includes all countas scrobbles
|
||||
|
||||
|
||||
c = [e for e in charts if set(e["track"]["artists"]) == set(artists) and e["track"]["title"] == title][0]
|
||||
return {"scrobbles":scrobbles,"position":charts.index(c) + 1}
|
||||
|
||||
|
||||
|
||||
def isPast(date,limit):
|
||||
if not date[0] == limit[0]:
|
||||
return date[0] > limit[0]
|
||||
@ -514,6 +529,12 @@ def isPast(date,limit):
|
||||
return date[1] > limit[1]
|
||||
return (date[2] > limit[2])
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@dbserver.get("/newscrobble")
|
||||
def pseudo_post_scrobble():
|
||||
keys = FormsDict.decode(request.query) # The Dal★Shabet handler
|
||||
|
Loading…
Reference in New Issue
Block a user