latest
This commit is contained in:
parent
60be955549
commit
65d134c4ff
38
2022-02-09-ambientweather/weatherlog.sh
Normal file
38
2022-02-09-ambientweather/weatherlog.sh
Normal file
@ -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
|
@ -15,3 +15,11 @@ fi
|
||||
if ! which pack 2>&1 >/dev/null ; then
|
||||
go install -v github.com/buildpacks/pack/cmd/pack@latest
|
||||
fi
|
||||
|
||||
if ! which golangci-lint 2>&1 >/dev/null ; then
|
||||
go install -v github.com/golangci/golangci-lint/cmd/golangci-lint@latest
|
||||
fi
|
||||
|
||||
if ! which gofumpt 2>&1 >/dev/null ; then
|
||||
go install -v mvdan.cc/gofumpt@latest
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user