mirror of
https://github.com/iv-org/invidious.git
synced 2024-12-21 05:34:22 -05:00
Update captcha handler
This commit is contained in:
parent
454ae8656a
commit
750ef296c6
@ -259,10 +259,7 @@ def bypass_captcha(captcha_key, logger)
|
|||||||
},
|
},
|
||||||
}.to_json).body)
|
}.to_json).body)
|
||||||
|
|
||||||
if response["error"]?
|
raise response["error"].as_s if response["error"]?
|
||||||
raise response["error"].as_s
|
|
||||||
end
|
|
||||||
|
|
||||||
task_id = response["taskId"].as_i
|
task_id = response["taskId"].as_i
|
||||||
|
|
||||||
loop do
|
loop do
|
||||||
@ -286,8 +283,8 @@ def bypass_captcha(captcha_key, logger)
|
|||||||
yield response.cookies.select { |cookie| cookie.name != "PREF" }
|
yield response.cookies.select { |cookie| cookie.name != "PREF" }
|
||||||
elsif response.headers["Location"]?.try &.includes?("/sorry/index")
|
elsif response.headers["Location"]?.try &.includes?("/sorry/index")
|
||||||
location = response.headers["Location"].try { |u| URI.parse(u) }
|
location = response.headers["Location"].try { |u| URI.parse(u) }
|
||||||
client = QUIC::Client.new(location.host.not_nil!)
|
headers = HTTP::Headers{":authority" => location.host.not_nil!}
|
||||||
response = client.get(location.full_path)
|
response = YT_POOL.client &.get(location.full_path, headers)
|
||||||
|
|
||||||
html = XML.parse_html(response.body)
|
html = XML.parse_html(response.body)
|
||||||
form = html.xpath_node(%(//form[@action="index"])).not_nil!
|
form = html.xpath_node(%(//form[@action="index"])).not_nil!
|
||||||
@ -307,10 +304,7 @@ def bypass_captcha(captcha_key, logger)
|
|||||||
},
|
},
|
||||||
}.to_json).body)
|
}.to_json).body)
|
||||||
|
|
||||||
if response["error"]?
|
raise response["error"].as_s if response["error"]?
|
||||||
raise response["error"].as_s
|
|
||||||
end
|
|
||||||
|
|
||||||
task_id = response["taskId"].as_i
|
task_id = response["taskId"].as_i
|
||||||
|
|
||||||
loop do
|
loop do
|
||||||
@ -329,8 +323,8 @@ def bypass_captcha(captcha_key, logger)
|
|||||||
end
|
end
|
||||||
|
|
||||||
inputs["g-recaptcha-response"] = response["solution"]["gRecaptchaResponse"].as_s
|
inputs["g-recaptcha-response"] = response["solution"]["gRecaptchaResponse"].as_s
|
||||||
client.close
|
client = HTTPClient.new(location)
|
||||||
client = QUIC::Client.new("www.google.com")
|
client.family = CONFIG.force_resolve || Socket::Family::INET
|
||||||
response = client.post(location.full_path, form: inputs)
|
response = client.post(location.full_path, form: inputs)
|
||||||
headers = HTTP::Headers{
|
headers = HTTP::Headers{
|
||||||
"Cookie" => URI.parse(response.headers["location"]).query_params["google_abuse"].split(";")[0],
|
"Cookie" => URI.parse(response.headers["location"]).query_params["google_abuse"].split(";")[0],
|
||||||
|
Loading…
Reference in New Issue
Block a user