mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2022-03-16.git
synced 2024-08-15 00:53:18 +00:00
Add id 'pool' for connetion pool
This commit is contained in:
parent
c36b22a16d
commit
61e3b47210
1 changed files with 13 additions and 14 deletions
|
@ -21,28 +21,27 @@ end
|
|||
# Refresh all the connections in the pool by crawling recommended
|
||||
spawn do
|
||||
# Arbitrary start value
|
||||
id = "RoEEDKwzNBw"
|
||||
loop do
|
||||
id = Deque.new(50,"0xjKNDMgE54")
|
||||
while true
|
||||
client = get_client
|
||||
time = Time.now
|
||||
|
||||
begin
|
||||
video = get_video(id)
|
||||
rescue ex
|
||||
id = "RoEEDKwzNBw"
|
||||
next
|
||||
end
|
||||
|
||||
video = get_video(id[rand(id.size)], false)
|
||||
rvs = [] of Hash(String, String)
|
||||
video.info["rvs"].split(",").each do |rv|
|
||||
rvs << HTTP::Params.parse(rv).to_h
|
||||
end
|
||||
|
||||
id = rvs[rand(rvs.size)]["id"]
|
||||
|
||||
puts "#{Time.now} 200 GET #{id} #{elapsed_text(Time.now - time)}"
|
||||
rvs.each do |rv|
|
||||
id << rv["id"]
|
||||
end
|
||||
puts "#{Time.now} 200 GET #{elapsed_text(Time.now - time)}"
|
||||
rescue ex
|
||||
next
|
||||
ensure
|
||||
POOL << client
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
macro templated(filename)
|
||||
|
|
Loading…
Reference in a new issue