mirror of
https://gitea.invidious.io/iv-org/instances-api.git
synced 2024-08-15 00:53:15 +00:00
Update dependencies
This commit is contained in:
parent
1a07a52113
commit
44415c1c62
2 changed files with 10 additions and 7 deletions
|
@ -11,8 +11,8 @@ targets:
|
||||||
dependencies:
|
dependencies:
|
||||||
kemal:
|
kemal:
|
||||||
github: kemalcr/kemal
|
github: kemalcr/kemal
|
||||||
version: ~> 0.26.1
|
branch: master
|
||||||
|
|
||||||
crystal: 0.34.0
|
crystal: 0.35.1
|
||||||
|
|
||||||
license: AGPLv3
|
license: AGPLv3
|
||||||
|
|
|
@ -42,13 +42,11 @@ spawn do
|
||||||
monitors += response["psp"]["monitors"].as_a
|
monitors += response["psp"]["monitors"].as_a
|
||||||
page += 1
|
page += 1
|
||||||
|
|
||||||
if response["psp"]["perPage"].as_i * page > response["psp"]["totalMonitors"].as_i
|
break if response["psp"]["perPage"].as_i * page > response["psp"]["totalMonitors"].as_i
|
||||||
break
|
|
||||||
end
|
|
||||||
rescue ex
|
rescue ex
|
||||||
error_message = response.try &.as?(String).try &.["errorStats"]?
|
error_message = response.try &.as?(String).try &.["errorStats"]?
|
||||||
error_message ||= ex.message
|
error_message ||= ex.message
|
||||||
puts "Exception pulling monitors: #{error_message}"
|
puts "Error pulling monitors: #{error_message}"
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -56,6 +54,8 @@ spawn do
|
||||||
body = HTTP::Client.get(URI.parse("https://raw.githubusercontent.com/wiki/omarroth/invidious/Invidious-Instances.md")).body
|
body = HTTP::Client.get(URI.parse("https://raw.githubusercontent.com/wiki/omarroth/invidious/Invidious-Instances.md")).body
|
||||||
headers = HTTP::Headers.new
|
headers = HTTP::Headers.new
|
||||||
|
|
||||||
|
instances = {} of String => Instance
|
||||||
|
|
||||||
body = body.split("### Blocked:")[0]
|
body = body.split("### Blocked:")[0]
|
||||||
body.scan(/\[(?<host>[^ \]]+)\]\((?<uri>[^\)]+)\)( .(?<region>[\x{1f100}-\x{1f1ff}]{2}))?/mx).each do |md|
|
body.scan(/\[(?<host>[^ \]]+)\]\((?<uri>[^\)]+)\)( .(?<region>[\x{1f100}-\x{1f1ff}]{2}))?/mx).each do |md|
|
||||||
region = md["region"]?.try { |region| region.codepoints.map { |codepoint| (codepoint - 0x1f1a5).chr }.join("") }
|
region = md["region"]?.try { |region| region.codepoints.map { |codepoint| (codepoint - 0x1f1a5).chr }.join("") }
|
||||||
|
@ -80,9 +80,12 @@ spawn do
|
||||||
end
|
end
|
||||||
|
|
||||||
monitor = monitors.try &.select { |monitor| monitor["name"].try &.as_s == host }[0]?
|
monitor = monitors.try &.select { |monitor| monitor["name"].try &.as_s == host }[0]?
|
||||||
INSTANCES[host] = {flag: flag, region: region, stats: stats, type: type, uri: uri.to_s, monitor: monitor || INSTANCES[host]?.try &.[:monitor]?}
|
instances[host] = {flag: flag, region: region, stats: stats, type: type, uri: uri.to_s, monitor: monitor || instances[host]?.try &.[:monitor]?}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
INSTANCES.clear
|
||||||
|
INSTANCES.merge! instances
|
||||||
|
|
||||||
sleep 5.minutes
|
sleep 5.minutes
|
||||||
Fiber.yield
|
Fiber.yield
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue