Added search syntax
(key:value, for example author:vXtreniusX)
This commit is contained in:
parent
04d4a1fa2c
commit
51a52736a4
1 changed files with 22 additions and 5 deletions
|
@ -49,7 +49,6 @@ async def search(
|
||||||
|
|
||||||
searchResults = None
|
searchResults = None
|
||||||
if q is not None:
|
if q is not None:
|
||||||
print(level_code_regex.match(q))
|
|
||||||
if level_code_regex.match(q):
|
if level_code_regex.match(q):
|
||||||
levelCode = q.upper().replace("-", "")
|
levelCode = q.upper().replace("-", "")
|
||||||
searchValue = q
|
searchValue = q
|
||||||
|
@ -63,6 +62,24 @@ async def search(
|
||||||
except httpx.ReadTimeout:
|
except httpx.ReadTimeout:
|
||||||
return "Server timed out"
|
return "Server timed out"
|
||||||
else:
|
else:
|
||||||
|
author = {}
|
||||||
|
min_diff = 0.00
|
||||||
|
max_diff = 5.00
|
||||||
|
|
||||||
|
params = re.findall("[a-z\-\_]*:[a-zA-Z0-9_\-]*", q)
|
||||||
|
search = re.sub("[a-z\-\_]*:[a-zA-Z0-9_\-]*", "", q)
|
||||||
|
|
||||||
|
for i in params:
|
||||||
|
split = i.split(':')
|
||||||
|
if split[0] == "author":
|
||||||
|
author = {"author": split[1]}
|
||||||
|
|
||||||
|
elif split[0] == "min_diff":
|
||||||
|
min_diff = float(split[1])
|
||||||
|
|
||||||
|
elif split[0] == "max_diff":
|
||||||
|
max_diff = float(split[1])
|
||||||
|
|
||||||
order = {"Dir": dir, "Name": sort}
|
order = {"Dir": dir, "Name": sort}
|
||||||
if date == -1:
|
if date == -1:
|
||||||
last_x_hours = {}
|
last_x_hours = {}
|
||||||
|
@ -74,11 +91,11 @@ async def search(
|
||||||
rq = httpx.get(BASE_URL + "/api/v1/map", params={
|
rq = httpx.get(BASE_URL + "/api/v1/map", params={
|
||||||
"start": p * limit,
|
"start": p * limit,
|
||||||
"limit": limit,
|
"limit": limit,
|
||||||
"min_diff": 0.00,
|
"min_diff": min_diff,
|
||||||
"max_diff": 5.00,
|
"max_diff": max_diff,
|
||||||
"order": json.dumps([order]),
|
"order": json.dumps([order]),
|
||||||
"name": q,
|
"name": search,
|
||||||
**last_x_hours
|
**last_x_hours, **author
|
||||||
}, timeout=10)
|
}, timeout=10)
|
||||||
searchResults = rq.json()
|
searchResults = rq.json()
|
||||||
print(rq.url, p * limit)
|
print(rq.url, p * limit)
|
||||||
|
|
Loading…
Reference in a new issue