forked from midou/invidious
Fix reCaptcha
This commit is contained in:
parent
80941eacbd
commit
6435c7b921
@ -241,7 +241,8 @@ def bypass_captcha(captcha_key, logger)
|
||||
if response.body.includes?("To continue with your YouTube experience, please fill out the form below.")
|
||||
html = XML.parse_html(response.body)
|
||||
form = html.xpath_node(%(//form[@action="/das_captcha"])).not_nil!
|
||||
site_key = form.xpath_node(%(.//div[@class="g-recaptcha"])).try &.["data-sitekey"]
|
||||
site_key = form.xpath_node(%(.//div[@id="recaptcha"])).try &.["data-sitekey"]
|
||||
s_value = form.xpath_node(%(.//div[@id="recaptcha"])).try &.["data-s"]
|
||||
|
||||
inputs = {} of String => String
|
||||
form.xpath_nodes(%(.//input[@name])).map do |node|
|
||||
@ -254,8 +255,9 @@ def bypass_captcha(captcha_key, logger)
|
||||
"clientKey" => CONFIG.captcha_key,
|
||||
"task" => {
|
||||
"type" => "NoCaptchaTaskProxyless",
|
||||
"websiteURL" => "https://www.youtube.com/watch?v=CvFH_6DNRCY&gl=US&hl=en&disable_polymer=1&has_verified=1&bpctr=9999999999",
|
||||
"websiteURL" => "https://www.youtube.com#{path}",
|
||||
"websiteKey" => site_key,
|
||||
"recaptchaDataSValue" => s_value,
|
||||
},
|
||||
}.to_json).body)
|
||||
|
||||
@ -278,6 +280,7 @@ def bypass_captcha(captcha_key, logger)
|
||||
end
|
||||
|
||||
inputs["g-recaptcha-response"] = response["solution"]["gRecaptchaResponse"].as_s
|
||||
headers["Cookies"] = response["solution"]["cookies"].as_h.map { |k, v| "#{k}=#{v}" }.join("; ")
|
||||
response = YT_POOL.client &.post("/das_captcha", headers, form: inputs)
|
||||
|
||||
yield response.cookies.select { |cookie| cookie.name != "PREF" }
|
||||
@ -288,7 +291,8 @@ def bypass_captcha(captcha_key, logger)
|
||||
|
||||
html = XML.parse_html(response.body)
|
||||
form = html.xpath_node(%(//form[@action="index"])).not_nil!
|
||||
site_key = form.xpath_node(%(.//div[@class="g-recaptcha"])).try &.["data-sitekey"]
|
||||
site_key = form.xpath_node(%(.//div[@id="recaptcha"])).try &.["data-sitekey"]
|
||||
s_value = form.xpath_node(%(.//div[@id="recaptcha"])).try &.["data-s"]
|
||||
|
||||
inputs = {} of String => String
|
||||
form.xpath_nodes(%(.//input[@name])).map do |node|
|
||||
@ -303,6 +307,7 @@ def bypass_captcha(captcha_key, logger)
|
||||
"type" => "NoCaptchaTaskProxyless",
|
||||
"websiteURL" => location.to_s,
|
||||
"websiteKey" => site_key,
|
||||
"recaptchaDataSValue" => s_value,
|
||||
},
|
||||
}.to_json).body)
|
||||
|
||||
@ -325,10 +330,7 @@ def bypass_captcha(captcha_key, logger)
|
||||
end
|
||||
|
||||
inputs["g-recaptcha-response"] = response["solution"]["gRecaptchaResponse"].as_s
|
||||
headers["content-type"] = "application/x-www-form-urlencoded"
|
||||
headers["origin"] = "https://www.google.com"
|
||||
headers["user-agent"] = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36"
|
||||
|
||||
headers["Cookies"] = response["solution"]["cookies"].as_h.map { |k, v| "#{k}=#{v}" }.join("; ")
|
||||
response = YT_POOL.client &.post("/sorry/index", headers: headers, form: inputs)
|
||||
headers = HTTP::Headers{
|
||||
"Cookie" => URI.parse(response.headers["location"]).query_params["google_abuse"].split(";")[0],
|
||||
|
Loading…
Reference in New Issue
Block a user