Update captcha job

このコミットが含まれているのは:
Omar Roth 2020-05-25 12:52:15 -05:00
コミット ceb252986e
この署名に対応する既知のキーがデータベースに存在しません
GPGキーID: B8254FB7EC3D37F2
3個のファイルの変更16行の追加9行の削除

ファイルの表示

@ -26,7 +26,7 @@ dependencies:
version: ~> 0.1.2
lsquic:
github: omarroth/lsquic.cr
version: ~> 0.1.9
branch: dev
crystal: 0.34.0

ファイルの表示

@ -295,7 +295,9 @@ def bypass_captcha(captcha_key, logger)
inputs[node["name"]] = node["value"]
end
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
response = JSON.parse(captcha_client.post("/createTask", body: {
"clientKey" => CONFIG.captcha_key,
"task" => {
"type" => "NoCaptchaTaskProxyless",
@ -310,7 +312,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)
@ -323,9 +325,11 @@ def bypass_captcha(captcha_key, logger)
end
inputs["g-recaptcha-response"] = response["solution"]["gRecaptchaResponse"].as_s
client = HTTPClient.new(location)
client.family = CONFIG.force_resolve || Socket::Family::INET
response = client.post(location.full_path, form: inputs)
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"
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],
}

ファイルの表示

@ -2,13 +2,16 @@ require "lsquic"
require "pool/connection"
def add_yt_headers(request)
request.headers["x-youtube-client-name"] ||= "1"
request.headers["x-youtube-client-version"] ||= "1.20180719"
request.headers["user-agent"] ||= "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 Safari/537.36"
request.headers["accept-charset"] ||= "ISO-8859-1,utf-8;q=0.7,*;q=0.7"
request.headers["accept"] ||= "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
request.headers["accept-language"] ||= "en-us,en;q=0.5"
request.headers["cookie"] = "#{(CONFIG.cookies.map { |c| "#{c.name}=#{c.value}" }).join("; ")}; #{request.headers["cookie"]?}"
return if request.resource.starts_with? "/sorry/index"
request.headers["x-youtube-client-name"] ||= "1"
request.headers["x-youtube-client-version"] ||= "1.20180719"
if !CONFIG.cookies.empty?
request.headers["cookie"] = "#{(CONFIG.cookies.map { |c| "#{c.name}=#{c.value}" }).join("; ")}; #{request.headers["cookie"]?}"
end
end
struct QUICPool