Last active
March 11, 2020 14:32
-
-
Save kyle-west/e7939645f4bc49b0a9a4531928f13b52 to your computer and use it in GitHub Desktop.
Get the latest stats on on the COVID-19 (Coronavirus) for your state on the command line (with notifications on Mac OSX)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| url='https://services1.arcgis.com/0MSEUqKaxRlEPj5g/arcgis/rest/services/ncov_cases/FeatureServer/1/query?f=json&where=(Confirmed%20%3E%200)%20AND%20(Country_Region%3D%27US%27)&returnGeometry=false&spatialRel=esriSpatialRelIntersects&outFields=*&orderByFields=Confirmed%20desc%2CCountry_Region%20asc%2CProvince_State%20asc&outSR=102100&resultOffset=0&resultRecordCount=250&cacheHint=true' | |
| __getStats () { | |
| json <(curl -s "$url") " | |
| const data = \$.features.filter(x => x && x.attributes && x.attributes.Province_State && x.attributes.Province_State.includes && x.attributes.Province_State.includes('$1')) | |
| const { Confirmed, Deaths, Recovered } = (data && data[0] && data[0].attributes) || {}; | |
| Confirmed && console.log('Confirmed: ' + Confirmed, 'Recovered: ' + Recovered, 'Deaths: ' + Deaths); | |
| !Confirmed && console.log('No Data Found on $1') | |
| " | |
| } | |
| if [ "$2" == "--watch" ]; then | |
| while [ 1 ]; do | |
| currentStats=`__getStats "$1"` | |
| osascript -e "display notification \"$currentStats\" with title \"Latest COVID-19 $1 Stats\" subtitle \"$(date)\"" | |
| sleep 3600 # 1 hr | |
| done | |
| else | |
| __getStats "$1" | |
| fi |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Install
Installed with the
bashfulCLI.Usage
covid-19takes a single argument for the state you want the get the latest stats on for the COVID-19 (Coronavirus).Example
covid-19 California # --> Confirmed: 144 Recovered: 2 Deaths: 2If you want a notification every hour on you Mac, run the following command in the background:
Credits
The data for this script is collected from this dashboard from the Johns Hopkins University.