forked from midou/invidious
Fix method for detecting valid info resposne
This commit is contained in:
parent
d418f50576
commit
ae2850215f
@ -552,8 +552,8 @@ def fetch_video(id, proxies)
|
|||||||
proxy = HTTPProxy.new(proxy_host: proxy[:ip], proxy_port: proxy[:port])
|
proxy = HTTPProxy.new(proxy_host: proxy[:ip], proxy_port: proxy[:port])
|
||||||
client.set_proxy(proxy)
|
client.set_proxy(proxy)
|
||||||
|
|
||||||
response = client.head("/get_video_info?video_id=#{id}&el=detailpage&ps=default&eurl=&gl=US&hl=en&disable_polymer=1")
|
info = HTTP::Params.parse(client.get("/get_video_info?video_id=#{id}&ps=default&eurl=&gl=US&hl=en&disable_polymer=1").body)
|
||||||
if response.status_code == 200
|
if !info["reason"]?
|
||||||
bypass_channel.send(proxy)
|
bypass_channel.send(proxy)
|
||||||
else
|
else
|
||||||
bypass_channel.send(nil)
|
bypass_channel.send(nil)
|
||||||
@ -569,26 +569,26 @@ def fetch_video(id, proxies)
|
|||||||
proxies.size.times do
|
proxies.size.times do
|
||||||
proxy = bypass_channel.receive
|
proxy = bypass_channel.receive
|
||||||
if proxy
|
if proxy
|
||||||
client = HTTPClient.new(YT_URL)
|
begin
|
||||||
client.read_timeout = 10.seconds
|
client = HTTPClient.new(YT_URL)
|
||||||
client.connect_timeout = 10.seconds
|
client.read_timeout = 10.seconds
|
||||||
client.set_proxy(proxy)
|
client.connect_timeout = 10.seconds
|
||||||
|
client.set_proxy(proxy)
|
||||||
|
|
||||||
proxy = {ip: proxy.proxy_host, port: proxy.proxy_port}
|
html = XML.parse_html(client.get("/watch?v=#{id}&bpctr=#{Time.new.epoch + 2000}&gl=US&hl=en&disable_polymer=1").body)
|
||||||
region = proxies.select { |region, list| list.includes? proxy }.keys[0]
|
info = HTTP::Params.parse(client.get("/get_video_info?video_id=#{id}&el=detailpage&ps=default&eurl=&gl=US&hl=en&disable_polymer=1").body)
|
||||||
|
|
||||||
html = client.get("/watch?v=#{id}&bpctr=#{Time.new.epoch + 2000}&gl=US&hl=en&disable_polymer=1")
|
if info["reason"]?
|
||||||
html = XML.parse_html(html.body)
|
info = HTTP::Params.parse(client.get("/get_video_info?video_id=#{id}&ps=default&eurl=&gl=US&hl=en&disable_polymer=1").body)
|
||||||
|
end
|
||||||
|
|
||||||
info = client.get("/get_video_info?video_id=#{id}&el=detailpage&ps=default&eurl=&gl=US&hl=en&disable_polymer=1")
|
proxy = {ip: proxy.proxy_host, port: proxy.proxy_port}
|
||||||
info = HTTP::Params.parse(info.body)
|
region = proxies.select { |region, list| list.includes? proxy }
|
||||||
|
if !region.empty?
|
||||||
if info["reason"]?
|
info["region"] = region.keys[0]
|
||||||
info = client.get("/get_video_info?video_id=#{id}&ps=default&eurl=&gl=US&hl=en&disable_polymer=1")
|
end
|
||||||
info = HTTP::Params.parse(info.body)
|
rescue ex
|
||||||
end
|
end
|
||||||
|
|
||||||
info["region"] = region
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user