forked from midou/invidious
Add id 'pool' for connetion pool
This commit is contained in:
parent
c36b22a16d
commit
61e3b47210
@ -21,28 +21,27 @@ end
|
|||||||
# Refresh all the connections in the pool by crawling recommended
|
# Refresh all the connections in the pool by crawling recommended
|
||||||
spawn do
|
spawn do
|
||||||
# Arbitrary start value
|
# Arbitrary start value
|
||||||
id = "RoEEDKwzNBw"
|
id = Deque.new(50,"0xjKNDMgE54")
|
||||||
loop do
|
while true
|
||||||
client = get_client
|
client = get_client
|
||||||
time = Time.now
|
time = Time.now
|
||||||
|
|
||||||
begin
|
begin
|
||||||
video = get_video(id)
|
video = get_video(id[rand(id.size)], false)
|
||||||
rescue ex
|
|
||||||
id = "RoEEDKwzNBw"
|
|
||||||
next
|
|
||||||
end
|
|
||||||
|
|
||||||
rvs = [] of Hash(String, String)
|
rvs = [] of Hash(String, String)
|
||||||
video.info["rvs"].split(",").each do |rv|
|
video.info["rvs"].split(",").each do |rv|
|
||||||
rvs << HTTP::Params.parse(rv).to_h
|
rvs << HTTP::Params.parse(rv).to_h
|
||||||
end
|
end
|
||||||
|
rvs.each do |rv|
|
||||||
id = rvs[rand(rvs.size)]["id"]
|
id << rv["id"]
|
||||||
|
end
|
||||||
puts "#{Time.now} 200 GET #{id} #{elapsed_text(Time.now - time)}"
|
puts "#{Time.now} 200 GET #{elapsed_text(Time.now - time)}"
|
||||||
|
rescue ex
|
||||||
|
next
|
||||||
|
ensure
|
||||||
POOL << client
|
POOL << client
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
macro templated(filename)
|
macro templated(filename)
|
||||||
|
Loading…
Reference in New Issue
Block a user