update satalite-wp-update script to use the proper API ends
This commit is contained in:
@@ -4,9 +4,13 @@
|
|||||||
# set -xv
|
# set -xv
|
||||||
EUMETSAT_KEY="jdBM1PsDQUm0tCZfk9VXD6IaJoUa"
|
EUMETSAT_KEY="jdBM1PsDQUm0tCZfk9VXD6IaJoUa"
|
||||||
EUMETSAT_SECRET="SumkiqFMU3MAGpt_azb1KXKgjdMa"
|
EUMETSAT_SECRET="SumkiqFMU3MAGpt_azb1KXKgjdMa"
|
||||||
URL="https://api.eumetsat.int/data"
|
|
||||||
COL_ID="EO%3AEUM%3ADAT%3A0665"
|
|
||||||
|
|
||||||
|
error() {
|
||||||
|
printf "\033[31m%s\033[0m\n" "$1"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# verify internet
|
||||||
ping -c1 1.1.1.1 >>/dev/null || error "couldn't establish an internet connection!"
|
ping -c1 1.1.1.1 >>/dev/null || error "couldn't establish an internet connection!"
|
||||||
|
|
||||||
# acquire the output directory
|
# acquire the output directory
|
||||||
@@ -19,35 +23,29 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# acquire the API key
|
# acquire the API key
|
||||||
EUMETSAT_API=$(
|
key=$(
|
||||||
curl -k -d "grant_type=client_credentials" \
|
curl -k -d "grant_type=client_credentials" \
|
||||||
-H "Authorization: Basic $(printf "%s:%s" "$EUMETSAT_KEY" "$EUMETSAT_SECRET" | base64)" \
|
-H "Authorization: Basic $(printf "%s:%s" "$EUMETSAT_KEY" "$EUMETSAT_SECRET" | base64)" \
|
||||||
https://api.eumetsat.int/token | jq -r '.["access_token"]'
|
https://api.eumetsat.int/token | jq -r '.["access_token"]'
|
||||||
)
|
)
|
||||||
|
|
||||||
error() {
|
# set url
|
||||||
printf "\033[31m%s\033[0m\n" "$1"
|
url="https://view.eumetsat.int/geoserver/wms?"
|
||||||
exit 1
|
url+="&service=WMS"
|
||||||
}
|
url+="&request=GetMap"
|
||||||
|
url+="&version=1.3.0"
|
||||||
|
url+="&layers=mtg_fd:rgb_geocolour"
|
||||||
|
url+="&width=1080&height=1080"
|
||||||
|
url+="&bbox=-6400000,-6400000,6400000,6400000"
|
||||||
|
url+="&crs=AUTO:42003,9001,0,0"
|
||||||
|
url+="&styles="
|
||||||
|
url+="&format=image/png"
|
||||||
|
url+="&access_token=$key"
|
||||||
|
|
||||||
apireq() {
|
# process incoming data
|
||||||
curl -k -H "Authorization: Bearer $EUMETSAT_API" "$URL/$1" "${@:2}"
|
[ ! -d "$outdir" ] && { mkdir -p "$outdir" || error "failed to access '$outdir'!"; }
|
||||||
}
|
curl "$url" -o "$outdir/tmp.png" || error "failed to download from url='$url'!"
|
||||||
|
mv -f "$outdir/tmp.png" "$outdir/curr.png"
|
||||||
DATE="$(date -u +'%Y/%m/%d')"
|
|
||||||
product=$(
|
|
||||||
apireq "browse/collections/$COL_ID/dates/$DATE/products?format=json" |
|
|
||||||
jq -r '.["products"].[0].["id"] | @uri'
|
|
||||||
)
|
|
||||||
|
|
||||||
[ -z "$product" ] && error "was unable to locate the latest product!"
|
|
||||||
|
|
||||||
mkdir -p "$outdir"
|
|
||||||
apireq "download/1.0.0/collections/$COL_ID/products/$product/browse" -o "$outdir/tmp.jpeg" || error "failed to download!"
|
|
||||||
mv -f "$outdir/tmp.jpeg" "$outdir/curr.jpeg"
|
|
||||||
|
|
||||||
# negate since default is rubbish
|
|
||||||
ffmpeg -y -i photos/eumetsat/curr.jpeg -vf negate photos/eumetsat/curr.jpeg
|
|
||||||
|
|
||||||
# update the feh background
|
# update the feh background
|
||||||
. "$HOME/.fehbg"
|
. "$HOME/.fehbg"
|
||||||
|
|||||||
Reference in New Issue
Block a user