Fix proxying for videos

This commit is contained in:
Omar Roth 2018-10-14 09:53:40 -05:00
parent b49623f90f
commit e46e6183ae
3 changed files with 4 additions and 11 deletions

View file

@ -1885,7 +1885,6 @@ get "/api/v1/comments/:id" do |env|
proxy_client.read_timeout = 10.seconds proxy_client.read_timeout = 10.seconds
proxy_client.connect_timeout = 10.seconds proxy_client.connect_timeout = 10.seconds
proxy = list.sample(1)[0]
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)
@ -1894,13 +1893,10 @@ get "/api/v1/comments/:id" do |env|
proxy_headers["cookie"] = response.cookies.add_request_headers(headers)["cookie"] proxy_headers["cookie"] = response.cookies.add_request_headers(headers)["cookie"]
proxy_html = response.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)
else
bypass_channel.send({proxy_html, proxy_client, proxy_headers}) bypass_channel.send({proxy_html, proxy_client, proxy_headers})
end
break break
end
rescue ex rescue ex
end end
end end

View file

@ -176,7 +176,7 @@ def produce_channel_videos_url(ucid, page = 1, auto_generated = nil)
continuation = Base64.urlsafe_encode(continuation) continuation = Base64.urlsafe_encode(continuation)
continuation = URI.escape(continuation) continuation = URI.escape(continuation)
url = "/browse_ajax?continuation=#{continuation}" url = "/browse_ajax?continuation=#{continuation}&gl=US&hl=en"
return url return url
end end

View file

@ -573,11 +573,8 @@ def fetch_video(id, proxies)
info = HTTP::Params.parse(client.get("/get_video_info?video_id=#{id}&ps=default&eurl=&gl=US&hl=en&disable_polymer=1").body) info = HTTP::Params.parse(client.get("/get_video_info?video_id=#{id}&ps=default&eurl=&gl=US&hl=en&disable_polymer=1").body)
if !info["reason"]? if !info["reason"]?
bypass_channel.send(proxy) bypass_channel.send(proxy)
else
bypass_channel.send(nil)
end
break break
end
rescue ex rescue ex
end end
end end