Remove FlareSolverr session management
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Michel Roux 2022-12-21 17:12:18 +00:00
parent 068aebdaaf
commit 8dc0b49e18

View File

@ -8,25 +8,10 @@ class FlareRequests(Session):
if not CLOUDPROXY_ENDPOINT: if not CLOUDPROXY_ENDPOINT:
return super().request(method, url, params, timeout=timeout, **kwargs) return super().request(method, url, params, timeout=timeout, **kwargs)
sessions = post(CLOUDPROXY_ENDPOINT, json={"cmd": "sessions.list"}).json()
if "sessions" in sessions and len(sessions["sessions"]) > 0:
FLARESESSION = sessions["sessions"][0]
else:
response = post(CLOUDPROXY_ENDPOINT, json={"cmd": "sessions.create"})
session = response.json()
if "session" in session:
FLARESESSION = session["session"]
else:
raise RequestException(response)
try:
response = post( response = post(
CLOUDPROXY_ENDPOINT, CLOUDPROXY_ENDPOINT,
json={ json={
"cmd": f"request.{method.lower()}", "cmd": f"request.{method.lower()}",
"session": FLARESESSION,
"url": url, "url": url,
"postData": parse.urlencode(params) if params else "", "postData": parse.urlencode(params) if params else "",
"maxTimeout": timeout * 1000, "maxTimeout": timeout * 1000,
@ -47,10 +32,3 @@ class FlareRequests(Session):
return resolved return resolved
raise RequestException(response) raise RequestException(response)
except RequestException:
session = post(
CLOUDPROXY_ENDPOINT,
json={"cmd": "sessions.destroy", "session": FLARESESSION},
)
raise RequestException(solution)