mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2022-08-14.git
synced 2024-08-15 00:53:20 +00:00
Fix method for detecting valid info resposne
This commit is contained in:
parent
d418f50576
commit
ae2850215f
1 changed files with 18 additions and 18 deletions
|
@ -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
|
||||||
|
begin
|
||||||
client = HTTPClient.new(YT_URL)
|
client = HTTPClient.new(YT_URL)
|
||||||
client.read_timeout = 10.seconds
|
client.read_timeout = 10.seconds
|
||||||
client.connect_timeout = 10.seconds
|
client.connect_timeout = 10.seconds
|
||||||
client.set_proxy(proxy)
|
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")
|
|
||||||
html = XML.parse_html(html.body)
|
|
||||||
|
|
||||||
info = client.get("/get_video_info?video_id=#{id}&el=detailpage&ps=default&eurl=&gl=US&hl=en&disable_polymer=1")
|
|
||||||
info = HTTP::Params.parse(info.body)
|
|
||||||
|
|
||||||
if info["reason"]?
|
if info["reason"]?
|
||||||
info = client.get("/get_video_info?video_id=#{id}&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)
|
||||||
info = HTTP::Params.parse(info.body)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
info["region"] = region
|
proxy = {ip: proxy.proxy_host, port: proxy.proxy_port}
|
||||||
|
region = proxies.select { |region, list| list.includes? proxy }
|
||||||
|
if !region.empty?
|
||||||
|
info["region"] = region.keys[0]
|
||||||
|
end
|
||||||
|
rescue ex
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue