From 39df8ab200afe9556ad01a1553607a04f1ff9f38 Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Fri, 16 Mar 2018 23:57:31 -0500 Subject: [PATCH] Add rescue for video ranking --- src/helpers.cr | 2 +- src/invidious.cr | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/helpers.cr b/src/helpers.cr index 6a707734..2f8b90b9 100644 --- a/src/helpers.cr +++ b/src/helpers.cr @@ -234,7 +234,7 @@ end def rank_videos(db, n, pool, filter) top = [] of {Float64, String} - db.query("SELECT id, wilson_score, published FROM videos WHERE views > 5000 ORDER BY published DESC LIMIT 10000") do |rs| + db.query("SELECT id, wilson_score, published FROM videos WHERE views > 5000 ORDER BY published DESC LIMIT 1000") do |rs| rs.each do id = rs.read(String) wilson_score = rs.read(Float64) diff --git a/src/invidious.cr b/src/invidious.cr index 41544f9e..d8a07421 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -147,7 +147,11 @@ spawn do top.each do |id| client = get_client(youtube_pool) - videos << get_video(id, client, PG_DB) + begin + videos << get_video(id, client, PG_DB) + rescue ex + STDOUT << Time.now << " : " << ex.message << "\n" + end youtube_pool << client end