Invidious is an alternative front-end to YouTube
allow to set a custom anti-captcha api url (#1473)
Émilien Devos3a2f4d4def32
diff --git a/src/invidious/helpers/helpers.cr b/src/invidious/helpers/helpers.crindex 62c24f3e..620d2ec8 100644--- a/src/invidious/helpers/helpers.cr+++ b/src/invidious/helpers/helpers.cr@@ -93,8 +93,9 @@ struct Configproperty admin_email : String = "[email protected]" # Email for bug reports@[YAML::Field(converter: Preferences::StringToCookies)]- property cookies : HTTP::Cookies = HTTP::Cookies.new # Saved cookies in "name1=value1; name2=value2..." format- property captcha_key : String? = nil # Key for Anti-Captcha+ property cookies : HTTP::Cookies = HTTP::Cookies.new # Saved cookies in "name1=value1; name2=value2..." format+ property captcha_key : String? = nil # Key for Anti-Captcha+ property captcha_api_url : String = "https://api.anti-captcha.com" # API URL for Anti-Captchadef disabled?(option)case disabled = CONFIG.disable_proxydiff --git a/src/invidious/jobs/bypass_captcha_job.cr b/src/invidious/jobs/bypass_captcha_job.crindex 8b69e01a..6778f7c3 100644--- a/src/invidious/jobs/bypass_captcha_job.cr+++ b/src/invidious/jobs/bypass_captcha_job.cr@@ -23,7 +23,8 @@ class Invidious::Jobs::BypassCaptchaJob < Invidious::Jobs::BaseJobheaders = response.cookies.add_request_headers(HTTP::Headers.new)- response = JSON.parse(HTTP::Client.post("https://api.anti-captcha.com/createTask", body: {+ response = JSON.parse(HTTP::Client.post(config.captcha_api_url + "/createTask",+ headers: HTTP::Headers{"Content-Type" => "application/json"}, body: {"clientKey" => config.captcha_key,"task" => {"type" => "NoCaptchaTaskProxyless",@@ -39,7 +40,8 @@ class Invidious::Jobs::BypassCaptchaJob < Invidious::Jobs::BaseJobloop dosleep 10.seconds- response = JSON.parse(HTTP::Client.post("https://api.anti-captcha.com/getTaskResult", body: {+ response = JSON.parse(HTTP::Client.post(config.captcha_api_url + "/getTaskResult",+ headers: HTTP::Headers{"Content-Type" => "application/json"}, body: {"clientKey" => config.captcha_key,"taskId" => task_id,}.to_json).body)@@ -76,9 +78,10 @@ class Invidious::Jobs::BypassCaptchaJob < Invidious::Jobs::BaseJobinputs[node["name"]] = node["value"]end- captcha_client = HTTPClient.new(URI.parse("https://api.anti-captcha.com"))+ captcha_client = HTTPClient.new(URI.parse(config.captcha_api_url))captcha_client.family = config.force_resolve || Socket::Family::INET- response = JSON.parse(captcha_client.post("/createTask", body: {+ response = JSON.parse(captcha_client.post("/createTask",+ headers: HTTP::Headers{"Content-Type" => "application/json"}, body: {"clientKey" => config.captcha_key,"task" => {"type" => "NoCaptchaTaskProxyless",@@ -94,7 +97,8 @@ class Invidious::Jobs::BypassCaptchaJob < Invidious::Jobs::BaseJobloop dosleep 10.seconds- response = JSON.parse(captcha_client.post("/getTaskResult", body: {+ response = JSON.parse(captcha_client.post("/getTaskResult",+ headers: HTTP::Headers{"Content-Type" => "application/json"}, body: {"clientKey" => config.captcha_key,"taskId" => task_id,}.to_json).body)