vaccine-finder 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d6f7b40190749b49efbdc5af70b5ca6c6c5a64ac52047ce6ed21bb1562e70b59
4
+ data.tar.gz: '0320329b9103a665201fa67dc3cc3cfca7b2e05a25d693c57f6a8bc22b6025cb'
5
+ SHA512:
6
+ metadata.gz: 72ec7aa52dccedfaac6784d0e90f30129a7ad451c140d92492dabfc63e78aff4dbee34bbc3930917c7efb202ef5279c0bd5c3bc51dcd82533fa9efe8e86a20c4
7
+ data.tar.gz: 80cd029b37fb8874fa43beeec08e10f850a7fba083c12ed57f47ae6b13070c0b97f0bf9e6fe45f349360020652c7deeefd374e412f1f017555d240736337dc8b
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'vaccine-spotter'
@@ -0,0 +1,90 @@
1
+ #################################################################
2
+ # This is basically a wrapper around https://vaccinespotter.org #
3
+ #################################################################
4
+
5
+ require "open-uri"
6
+ require "json"
7
+ require "net/http"
8
+ require "terminal-notifier"
9
+ require "pastel"
10
+ require "toml"
11
+ require "tty-config"
12
+ require "tty-prompt"
13
+ require "launchy"
14
+
15
+ pastel = Pastel.new
16
+ config = TTY::Config.new
17
+ prompt = TTY::Prompt.new
18
+
19
+ config.filename = "vaccine-finder"
20
+ config.extname = ".toml"
21
+ config.append_path "#{Dir.home}/.config"
22
+
23
+ if !config.exist?
24
+ puts
25
+ puts pastel.bold "Hi, welcome to the unofficial vaccinespotter.org CLI notifier thing!"
26
+ puts "It looks like you don't have a configuration file yet. Would you like to create one?"
27
+ create_config = prompt.yes? "Create `~/.config/vaccine-finder.toml`?"
28
+ if create_config
29
+ set_state = prompt.ask("What state would you like to monitor? (Two-letter postal code, please)", required: true)
30
+ config.set(:state, value: set_state)
31
+ puts "Ok, time to set zip codes…"
32
+ if prompt.yes? "freemaptools.com has a really helpful tool for getting the zip codes around a radius. Would you like to open it?"
33
+ Launchy.open "https://www.freemaptools.com/find-zip-codes-inside-radius.htm"
34
+ end
35
+ set_zips = prompt.ask("What zip codes would you like to track? You can paste here from freemaptools.com, if you used it (comma-separated list of integers, please)", convert: :int_list, required: true)
36
+ config.set(:zips, value: set_zips)
37
+ set_refresh_rate = prompt.ask("How often should the script check for updates? (seconds)", convert: :int, required: true)
38
+ config.set(:refresh_rate, value: set_refresh_rate)
39
+ puts "Perfect; writing to `~/.config/vaccine-finder.toml`…"
40
+ config.write
41
+ end
42
+ end
43
+
44
+ zips = config.read["zips"]
45
+ state = config.read["state"]
46
+ refresh_rate = config.read["refresh_rate"].to_i
47
+
48
+ puts
49
+ print pastel.bold "vaccinespotter.org CLI notifier thing, by Jack MapelLentz (jltml.me)"
50
+ puts pastel.dim " v0.1.0"
51
+ puts pastel.dim "This script uses the wonderful vaccinespotter.org, by Nick Muerdter (github.com/GUI)"
52
+ puts "Checking #{pastel.underline zips.length} zip codes in #{pastel.underline state} every #{pastel.underline refresh_rate} seconds"
53
+
54
+ excluded = Array.new
55
+
56
+ loop do
57
+
58
+ number_excluded = excluded.length
59
+
60
+ json = Net::HTTP.get(URI("https://www.vaccinespotter.org/api/v0/states/#{state}.json"))
61
+ parsed_json = JSON.parse(json)
62
+
63
+ puts
64
+
65
+ if (Time.now.strftime("%M").to_i%5 == 0) && (Time.now.strftime("%S").to_i < refresh_rate)
66
+ excluded.clear
67
+ puts "List of excluded/checked stores cleared"
68
+ end
69
+
70
+ parsed_json["features"].each_index do |i|
71
+ current = parsed_json["features"][i]["properties"]
72
+ if (current["appointments_available"] == true) and (zips.include?(current["postal_code"].to_i) == true) and (!excluded.include? current["id"].to_i) and (current["appointment_vaccine_types"]["pfizer"] == true or current["appointment_vaccine_types"]["unknown"] == true)
73
+ puts "- #{pastel.green.bold current["city"]} #{pastel.green.bold current["provider_brand_name"]}: #{current["url"]}"
74
+ puts " - #{current["appointment_vaccine_types"]} as of #{Time.parse(current["appointments_last_fetched"]).localtime.strftime("%H:%M:%S")}"
75
+ TerminalNotifier.notify("#{current["provider_brand_name"]} - #{current["city"]}", :title => "vaccine-spotter", :open => "#{current["url"]}")
76
+ excluded.append current["id"].to_i
77
+ end
78
+ end
79
+
80
+ print pastel.dim "Checked at #{Time.now.strftime("%H:%M:%S")} on #{Time.now.strftime("%Y-%m-%d")}"
81
+ if number_excluded == 1
82
+ print pastel.dim " (#{number_excluded} checked location excluded)"
83
+ elsif number_excluded != 0
84
+ print pastel.dim " (#{number_excluded} checked locations excluded)"
85
+ end
86
+ puts
87
+
88
+ sleep refresh_rate
89
+
90
+ end
metadata ADDED
@@ -0,0 +1,49 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vaccine-finder
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Jack MapelLentz
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-04-13 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: This gem will notify you when COVID-19 vaccine appointments are available
14
+ matching certain criteria (a list of zip codes, type of vaccine, etc). It currently
15
+ pretty much just wraps the very beta API from the absolutely wonderful vaccinespotter.org,
16
+ though I hope to add my own website scraping soon too so as to improve response
17
+ times.
18
+ email:
19
+ executables:
20
+ - vaccine-finder
21
+ extensions: []
22
+ extra_rdoc_files: []
23
+ files:
24
+ - bin/vaccine-finder
25
+ - lib/vaccine-spotter.rb
26
+ homepage: https://github.com/jltml/covid-vaccine-finders
27
+ licenses:
28
+ - MIT
29
+ metadata: {}
30
+ post_install_message:
31
+ rdoc_options: []
32
+ require_paths:
33
+ - lib
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ required_rubygems_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ requirements: []
45
+ rubygems_version: 3.2.15
46
+ signing_key:
47
+ specification_version: 4
48
+ summary: Get notified of vaccine availability
49
+ test_files: []