diff --git a/iwm_browser/main.py b/iwm_browser/main.py index 1521a79..e5a0c47 100644 --- a/iwm_browser/main.py +++ b/iwm_browser/main.py @@ -49,7 +49,6 @@ async def search( searchResults = None if q is not None: - print(level_code_regex.match(q)) if level_code_regex.match(q): levelCode = q.upper().replace("-", "") searchValue = q @@ -63,6 +62,24 @@ async def search( except httpx.ReadTimeout: return "Server timed out" 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} if date == -1: last_x_hours = {} @@ -74,11 +91,11 @@ async def search( rq = httpx.get(BASE_URL + "/api/v1/map", params={ "start": p * limit, "limit": limit, - "min_diff": 0.00, - "max_diff": 5.00, + "min_diff": min_diff, + "max_diff": max_diff, "order": json.dumps([order]), - "name": q, - **last_x_hours + "name": search, + **last_x_hours, **author }, timeout=10) searchResults = rq.json() print(rq.url, p * limit)