Add error handling for pulling monitors

This commit is contained in:
Omar Roth 2019-09-05 07:47:02 -04:00
parent e94bb4fa4a
commit 71dbbcb266
No known key found for this signature in database
GPG Key ID: B8254FB7EC3D37F2
2 changed files with 11 additions and 8 deletions

View File

@ -35,16 +35,19 @@ spawn do
loop do
begin
response = JSON.parse(HTTP::Client.get(URI.parse("https://uptime.invidio.us/api/getMonitorList/89VnzSKAn?page=#{page}")).body)
monitors += response["psp"]["monitors"].as_a
page += 1
if response["psp"]["perPage"].as_i * page > response["psp"]["totalMonitors"].as_i
break
end
rescue ex
error_message = response.try &.["errorStats"]?
error_message ||= ex.message
puts "Exception pulling monitors: #{error_message}"
next
end
monitors += response["psp"]["monitors"].as_a
page += 1
if response["psp"]["perPage"].as_i * page > response["psp"]["totalMonitors"].as_i
break
end
end
body = HTTP::Client.get(URI.parse("https://raw.githubusercontent.com/wiki/omarroth/invidious/Invidious-Instances.md")).body

View File

@ -4,7 +4,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="referrer" content="no-referrer" />
<link rel="stylesheet" href="/css/pure-min.css" />
<link rel="stylesheet" href="/css/base-min.css" />
<link rel="stylesheet" href="/css/tables-min.css" />
<title>Invidious Instances</title>
<style>