diff options
| author | Omar Roth <omarroth@hotmail.com> | 2018-01-19 03:46:29 +0000 |
|---|---|---|
| committer | Omar Roth <omarroth@hotmail.com> | 2018-01-19 03:46:29 +0000 |
| commit | 61e3b4721050dab835156345ff597e1142113142 (patch) | |
| tree | 209ebd03c01c88f5ed73483f45b67c8380ff1a46 | |
| parent | c36b22a16d793890b05e5ac4fce6ffe31046a07a (diff) | |
| download | invidious-61e3b4721050dab835156345ff597e1142113142.tar.gz invidious-61e3b4721050dab835156345ff597e1142113142.tar.bz2 invidious-61e3b4721050dab835156345ff597e1142113142.zip | |
Add id 'pool' for connetion pool
| -rw-r--r-- | src/invidious.cr | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/invidious.cr b/src/invidious.cr index a291a4ca..a0a6a4f7 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -21,27 +21,26 @@ 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) + 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 + rvs.each do |rv| + id << rv["id"] + end + puts "#{Time.now} 200 GET #{elapsed_text(Time.now - time)}" rescue ex - id = "RoEEDKwzNBw" next + ensure + POOL << client end - - 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)}" - POOL << client end end |
