From eaf24d70bae7e39b3bf1b65eaf2d1ff1309d26c5 Mon Sep 17 00:00:00 2001 From: Krateng Date: Tue, 27 Nov 2018 16:21:33 +0100 Subject: [PATCH] Small fixes --- database.py | 7 ++++++- server.py | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/database.py b/database.py index eb5f723..4992a2c 100644 --- a/database.py +++ b/database.py @@ -75,7 +75,7 @@ def getTrackID(artists,title): @route("/scrobbles") def get_scrobbles(): keys = request.query - r = db_query(artist=keys.get("artist")) + r = db_query(artist=keys.get("artist"),track=keys.get("track"),since=keys.get("since"),to=keys.get("to")) return {"list":r} ##json can't be a list apparently??? @@ -299,6 +299,11 @@ def db_query(artist=None,track=None,since=0,to=9999999999): date = [1970,1,1,0,0] date[:len(sdate)] = sdate to = int(datetime.datetime(date[0],date[1],date[2],date[3],date[4],tzinfo=datetime.timezone.utc).timestamp()) + + if (since==None): + since = 0 + if (to==None): + to = 9999999999 # this is not meant as a search function. we *can* query the db with a string, but it only works if it matches exactly (and title string simply picks the first track with that name) if isinstance(artist, str): diff --git a/server.py b/server.py index 55bd736..5cbb27d 100755 --- a/server.py +++ b/server.py @@ -4,6 +4,7 @@ import _thread import waitress import urllib.request import urllib.parse +import sys MAIN_PORT = 12345