This commit is contained in:
parent
136039cabe
commit
bda4f24abb
@ -37,11 +37,12 @@ class FlareRequests(requests.Session):
|
|||||||
raise requests.RequestException(response)
|
raise requests.RequestException(response)
|
||||||
|
|
||||||
url += "&" if len(url.split("?")) > 1 else "?"
|
url += "&" if len(url.split("?")) > 1 else "?"
|
||||||
|
url = f"{url}{urllib.parse.urlencode(params)}"
|
||||||
|
|
||||||
post_data = {
|
post_data = {
|
||||||
"cmd": f"request.{method.lower()}",
|
"cmd": f"request.{method.lower()}",
|
||||||
"session": FLARESESSION,
|
"session": FLARESESSION,
|
||||||
"url": f"{url}{urllib.parse.urlencode(params)}",
|
"url": url,
|
||||||
}
|
}
|
||||||
|
|
||||||
if data:
|
if data:
|
||||||
@ -56,12 +57,22 @@ class FlareRequests(requests.Session):
|
|||||||
solution = response.json()
|
solution = response.json()
|
||||||
|
|
||||||
if "solution" in solution:
|
if "solution" in solution:
|
||||||
|
if "content-type" in solution["solution"]["headers"]:
|
||||||
|
content_type = solution["solution"]["headers"][
|
||||||
|
"content-type"
|
||||||
|
].split(";")
|
||||||
|
if len(content_type) > 1:
|
||||||
|
charset = content_type[1].split("=")
|
||||||
|
if len(charset) > 1:
|
||||||
|
encoding = charset[1]
|
||||||
|
|
||||||
resolved = requests.Response()
|
resolved = requests.Response()
|
||||||
|
|
||||||
resolved.raw = io.BytesIO(solution["solution"]["response"].encode())
|
|
||||||
resolved.status_code = solution["solution"]["status"]
|
resolved.status_code = solution["solution"]["status"]
|
||||||
resolved.headers = solution["solution"]["headers"]
|
resolved.headers = solution["solution"]["headers"]
|
||||||
|
resolved.raw = io.BytesIO(solution["solution"]["response"].encode())
|
||||||
resolved.url = url
|
resolved.url = url
|
||||||
|
resolved.encoding = encoding or None
|
||||||
resolved.reason = solution["status"]
|
resolved.reason = solution["status"]
|
||||||
resolved.cookies = solution["solution"]["cookies"]
|
resolved.cookies = solution["solution"]["cookies"]
|
||||||
|
|
||||||
@ -128,7 +139,10 @@ def search_ygg(query, multi, full):
|
|||||||
ygg_params["option_langue:multiple[]"] = "4"
|
ygg_params["option_langue:multiple[]"] = "4"
|
||||||
|
|
||||||
req = session.get(f"{YGGTORRENT_BASE_URL}/engine/search", params=ygg_params)
|
req = session.get(f"{YGGTORRENT_BASE_URL}/engine/search", params=ygg_params)
|
||||||
html = bs4.BeautifulSoup(req.text, "html.parser")
|
html = bs4.BeautifulSoup(
|
||||||
|
req.text,
|
||||||
|
"html.parser",
|
||||||
|
)
|
||||||
trs = html.select("table.table tr")
|
trs = html.select("table.table tr")
|
||||||
|
|
||||||
if len(trs) > 1:
|
if len(trs) > 1:
|
||||||
|
Loading…
Reference in New Issue
Block a user