Invidious is an alternative front-end to YouTube
Fix client reuse
Omar Rothfc2e10a54f21
diff --git a/src/invidious.cr b/src/invidious.crindex a95e1fce..dbd21adf 100644--- a/src/invidious.cr+++ b/src/invidious.cr@@ -66,19 +66,19 @@ threads.times doio = STDOUTids = Deque(String).newrandom = Random.new- client = get_client(youtube_pool)+ yt_client = get_client(youtube_pool)- search(random.base64(3), client) do |id|+ search(random.base64(3), yt_client) do |id|ids << idend- youtube_pool << client+ youtube_pool << yt_clientloop doyt_client = get_client(youtube_pool)if ids.empty?- search(random.base64(3), client) do |id|+ search(random.base64(3), yt_client) do |id|ids << idendend@@ -90,7 +90,7 @@ threads.times dobeginid = ids[0]- video = get_video(id, client, PG_DB)+ video = get_video(id, yt_client, PG_DB)rescue exio << id << " : " << ex.message << "\n"youtube_pool << make_client(YT_URL, CONTEXT)@@ -118,7 +118,7 @@ threads.times dosleep sleep_time.seconds- youtube_pool << client+ youtube_pool << yt_clientendendend@@ -129,8 +129,9 @@ threads.times doclient = get_client(reddit_pool)begin- client.get("/")+ client.get("/")rescue ex+ STDOUT << "Reddit client : " << ex.message << "\n"reddit_pool << make_client(URI.parse("https://api.reddit.com"), CONTEXT)nextend@@ -201,6 +202,8 @@ get "/watch" do |env|rescue exerror_message = ex.messagenext templated "error"+ ensure+ youtube_pool << yt_clientendfmt_stream = [] of HTTP::Params@@ -253,17 +256,15 @@ get "/watch" do |env|endreddit_client = get_client(reddit_pool)-beginreddit_comments, reddit_thread = get_reddit_comments(id, reddit_client)rescue exreddit_comments = JSON.parse("[]")reddit_thread = nil+ ensure+ reddit_pool << reddit_clientend- reddit_pool << reddit_client- youtube_pool << yt_client-templated "watch"end