|
|
@ -107,14 +107,14 @@ end
|
|
|
|
|
|
|
|
|
|
|
|
proxies = {} of String => Array({ip: String, port: Int32})
|
|
|
|
proxies = {} of String => Array({ip: String, port: Int32})
|
|
|
|
if CONFIG.geo_bypass
|
|
|
|
if CONFIG.geo_bypass
|
|
|
|
spawn do
|
|
|
|
spawn do
|
|
|
|
find_working_proxies(BYPASS_REGIONS) do |region, list|
|
|
|
|
find_working_proxies(BYPASS_REGIONS) do |region, list|
|
|
|
|
if !list.empty?
|
|
|
|
if !list.empty?
|
|
|
|
proxies[region] = list
|
|
|
|
proxies[region] = list
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
before_all do |env|
|
|
|
|
before_all do |env|
|
|
|
|
env.response.headers["X-XSS-Protection"] = "1; mode=block;"
|
|
|
|
env.response.headers["X-XSS-Protection"] = "1; mode=block;"
|
|
|
@ -1876,6 +1876,8 @@ get "/api/v1/comments/:id" do |env|
|
|
|
|
|
|
|
|
|
|
|
|
proxies.each do |region, list|
|
|
|
|
proxies.each do |region, list|
|
|
|
|
spawn do
|
|
|
|
spawn do
|
|
|
|
|
|
|
|
proxy_html = %(<meta itemprop="regionsAllowed" content="">)
|
|
|
|
|
|
|
|
|
|
|
|
list.each do |proxy|
|
|
|
|
list.each do |proxy|
|
|
|
|
begin
|
|
|
|
begin
|
|
|
|
proxy_client = HTTPClient.new(YT_URL)
|
|
|
|
proxy_client = HTTPClient.new(YT_URL)
|
|
|
@ -1886,10 +1888,10 @@ get "/api/v1/comments/:id" do |env|
|
|
|
|
proxy = HTTPProxy.new(proxy_host: proxy[:ip], proxy_port: proxy[:port])
|
|
|
|
proxy = HTTPProxy.new(proxy_host: proxy[:ip], proxy_port: proxy[:port])
|
|
|
|
proxy_client.set_proxy(proxy)
|
|
|
|
proxy_client.set_proxy(proxy)
|
|
|
|
|
|
|
|
|
|
|
|
proxy_html = proxy_client.get("/watch?v=#{id}&bpctr=#{Time.new.epoch + 2000}&gl=US&hl=en&disable_polymer=1")
|
|
|
|
response = proxy_client.get("/watch?v=#{id}&bpctr=#{Time.new.epoch + 2000}&gl=US&hl=en&disable_polymer=1")
|
|
|
|
proxy_headers = HTTP::Headers.new
|
|
|
|
proxy_headers = HTTP::Headers.new
|
|
|
|
proxy_headers["cookie"] = proxy_html.cookies.add_request_headers(headers)["cookie"]
|
|
|
|
proxy_headers["cookie"] = response.cookies.add_request_headers(headers)["cookie"]
|
|
|
|
proxy_html = proxy_html.body
|
|
|
|
proxy_html = response.body
|
|
|
|
|
|
|
|
|
|
|
|
if proxy_html.match(/<meta itemprop="regionsAllowed" content="">/)
|
|
|
|
if proxy_html.match(/<meta itemprop="regionsAllowed" content="">/)
|
|
|
|
bypass_channel.send(nil)
|
|
|
|
bypass_channel.send(nil)
|
|
|
@ -1901,6 +1903,11 @@ get "/api/v1/comments/:id" do |env|
|
|
|
|
rescue ex
|
|
|
|
rescue ex
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# If none of the proxies we tried returned a valid response
|
|
|
|
|
|
|
|
if proxy_html.match(/<meta itemprop="regionsAllowed" content="">/)
|
|
|
|
|
|
|
|
bypass_channel.send(nil)
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|