parent
60be955549
commit
65d134c4ff
@ -0,0 +1,38 @@ |
||||
#!/bin/bash |
||||
|
||||
API='https://lightning.ambientweather.net/devices' |
||||
OUTDIR="$HOME/tmp/weatherfetch" |
||||
|
||||
function fetchWeather() { |
||||
curl "$API"?'%24publicBox%5B0%5D%5B0%5D=-115.37389456264378&%24publicBox%5B0%5D%5B1%5D=36.1098453902911&%24publicBox%5B1%5D%5B0%5D=-115.1709572152316&%24publicBox%5B1%5D%5B1%5D=36.24422733946878&%24limit=500' \ |
||||
-H 'authority: lightning.ambientweather.net' \ |
||||
-H 'accept: application/json' \ |
||||
-H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.80 Safari/537.36' \ |
||||
-H 'origin: https://ambientweather.net' \ |
||||
-H 'sec-fetch-site: same-site' \ |
||||
-H 'sec-fetch-mode: cors' \ |
||||
-H 'sec-fetch-dest: empty' \ |
||||
-H 'referer: https://ambientweather.net/' \ |
||||
-H 'accept-language: en-US,en;q=0.9' \ |
||||
--compressed | jq . |
||||
} |
||||
|
||||
function main() { |
||||
if [[ ! -d $OUTDIR ]]; then |
||||
mkdir -p $OUTDIR |
||||
fi |
||||
|
||||
while sleep 1; do |
||||
oneLoop |
||||
sleep 3600 |
||||
done |
||||
} |
||||
|
||||
function oneLoop() { |
||||
NOW="$(date -u +"%Y%m%dT%H%M%SZ")" |
||||
JSON="$(fetchWeather)" |
||||
cat <<< "$JSON" > $OUTDIR/latest.json |
||||
cp $OUTDIR/latest.json $OUTDIR/$NOW.json |
||||
} |
||||
|
||||
main |
Loading…
Reference in new issue