|
|
|
@ -249,15 +249,34 @@ def bypass_captcha(captcha_key, logger)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
headers = response.cookies.add_request_headers(HTTP::Headers.new)
|
|
|
|
|
|
|
|
|
|
response = JSON.parse(HTTP::Client.post("https://api.anti-captcha.com/createTask", body: {
|
|
|
|
|
captcha_client = HTTPClient.new(URI.parse("https://api.anti-captcha.com"))
|
|
|
|
|
captcha_client.family = CONFIG.force_resolve || Socket::Family::INET
|
|
|
|
|
if !CONFIG.proxy_address.empty?
|
|
|
|
|
response = JSON.parse(captcha_client.post("/createTask", body: {
|
|
|
|
|
"clientKey" => CONFIG.captcha_key,
|
|
|
|
|
"task" => {
|
|
|
|
|
"type" => "NoCaptchaTask",
|
|
|
|
|
"websiteURL" => "https://www.youtube.com#{path}",
|
|
|
|
|
"websiteKey" => site_key,
|
|
|
|
|
"proxyType" => "http",
|
|
|
|
|
"proxyAddress" => CONFIG.proxy_address,
|
|
|
|
|
"proxyPort" => CONFIG.proxy_port,
|
|
|
|
|
"proxyLogin" => CONFIG.proxy_user,
|
|
|
|
|
"proxyPassword" => CONFIG.proxy_pass,
|
|
|
|
|
"userAgent" => headers["user-agent"],
|
|
|
|
|
},
|
|
|
|
|
}.to_json).body)
|
|
|
|
|
else
|
|
|
|
|
response = JSON.parse(captcha_client.post("/createTask", body: {
|
|
|
|
|
"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,
|
|
|
|
|
"userAgent" => headers["user-agent"],
|
|
|
|
|
},
|
|
|
|
|
}.to_json).body)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
raise response["error"].as_s if response["error"]?
|
|
|
|
|
task_id = response["taskId"].as_i
|
|
|
|
@ -265,7 +284,7 @@ def bypass_captcha(captcha_key, logger)
|
|
|
|
|
loop do
|
|
|
|
|
sleep 10.seconds
|
|
|
|
|
|
|
|
|
|
response = JSON.parse(HTTP::Client.post("https://api.anti-captcha.com/getTaskResult", body: {
|
|
|
|
|
response = JSON.parse(captcha_client.post("/getTaskResult", body: {
|
|
|
|
|
"clientKey" => CONFIG.captcha_key,
|
|
|
|
|
"taskId" => task_id,
|
|
|
|
|
}.to_json).body)
|
|
|
|
@ -283,7 +302,11 @@ def bypass_captcha(captcha_key, logger)
|
|
|
|
|
yield response.cookies.select { |cookie| cookie.name != "PREF" }
|
|
|
|
|
elsif response.headers["Location"]?.try &.includes?("/sorry/index")
|
|
|
|
|
location = response.headers["Location"].try { |u| URI.parse(u) }
|
|
|
|
|
headers = HTTP::Headers{":authority" => location.host.not_nil!}
|
|
|
|
|
headers = HTTP::Headers{
|
|
|
|
|
":authority" => location.host.not_nil!,
|
|
|
|
|
"origin" => "https://www.google.com",
|
|
|
|
|
"user-agent" => "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36",
|
|
|
|
|
}
|
|
|
|
|
response = YT_POOL.client &.get(location.full_path, headers)
|
|
|
|
|
|
|
|
|
|
html = XML.parse_html(response.body)
|
|
|
|
@ -297,14 +320,32 @@ def bypass_captcha(captcha_key, logger)
|
|
|
|
|
|
|
|
|
|
captcha_client = HTTPClient.new(URI.parse("https://api.anti-captcha.com"))
|
|
|
|
|
captcha_client.family = CONFIG.force_resolve || Socket::Family::INET
|
|
|
|
|
if !CONFIG.proxy_address.empty?
|
|
|
|
|
response = JSON.parse(captcha_client.post("/createTask", body: {
|
|
|
|
|
"clientKey" => CONFIG.captcha_key,
|
|
|
|
|
"task" => {
|
|
|
|
|
"type" => "NoCaptchaTask",
|
|
|
|
|
"websiteURL" => location.to_s,
|
|
|
|
|
"websiteKey" => site_key,
|
|
|
|
|
"proxyType" => "http",
|
|
|
|
|
"proxyAddress" => CONFIG.proxy_address,
|
|
|
|
|
"proxyPort" => CONFIG.proxy_port,
|
|
|
|
|
"proxyLogin" => CONFIG.proxy_user,
|
|
|
|
|
"proxyPassword" => CONFIG.proxy_pass,
|
|
|
|
|
"userAgent" => headers["user-agent"],
|
|
|
|
|
},
|
|
|
|
|
}.to_json).body)
|
|
|
|
|
else
|
|
|
|
|
response = JSON.parse(captcha_client.post("/createTask", body: {
|
|
|
|
|
"clientKey" => CONFIG.captcha_key,
|
|
|
|
|
"task" => {
|
|
|
|
|
"type" => "NoCaptchaTaskProxyless",
|
|
|
|
|
"websiteURL" => location.to_s,
|
|
|
|
|
"websiteKey" => site_key,
|
|
|
|
|
"userAgent" => headers["user-agent"],
|
|
|
|
|
},
|
|
|
|
|
}.to_json).body)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
raise response["error"].as_s if response["error"]?
|
|
|
|
|
task_id = response["taskId"].as_i
|
|
|
|
@ -326,8 +367,7 @@ def bypass_captcha(captcha_key, logger)
|
|
|
|
|
|
|
|
|
|
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["referer"] = location.to_s
|
|
|
|
|
|
|
|
|
|
response = YT_POOL.client &.post("/sorry/index", headers: headers, form: inputs)
|
|
|
|
|
headers = HTTP::Headers{
|
|
|
|
|