write satalite connect script
This commit is contained in:
53
usr/bin/satalite-wp-update
Executable file
53
usr/bin/satalite-wp-update
Executable file
@@ -0,0 +1,53 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# shellcheck disable=SC1090,SC1091
|
||||||
|
|
||||||
|
# set -xv
|
||||||
|
EUMETSAT_KEY="jdBM1PsDQUm0tCZfk9VXD6IaJoUa"
|
||||||
|
EUMETSAT_SECRET="SumkiqFMU3MAGpt_azb1KXKgjdMa"
|
||||||
|
URL="https://api.eumetsat.int/data"
|
||||||
|
COL_ID="EO%3AEUM%3ADAT%3A0665"
|
||||||
|
|
||||||
|
ping -c1 1.1.1.1 >>/dev/null || error "couldn't establish an internet connection!"
|
||||||
|
|
||||||
|
# acquire the output directory
|
||||||
|
if command -v xdg-user-dir; then
|
||||||
|
outdir="$(xdg-user-dir PICTURES)/eumetsat"
|
||||||
|
elif [ -z "$HOME" ]; then
|
||||||
|
outdir="$HOME/.eumetsat"
|
||||||
|
else
|
||||||
|
error "couldn't connect to either 'xdg-user-dir PICTURES' or '\$HOME'"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# acquire the API key
|
||||||
|
EUMETSAT_API=$(
|
||||||
|
curl -k -d "grant_type=client_credentials" \
|
||||||
|
-H "Authorization: Basic $(printf "%s:%s" "$EUMETSAT_KEY" "$EUMETSAT_SECRET" | base64)" \
|
||||||
|
https://api.eumetsat.int/token | jq -r '.["access_token"]'
|
||||||
|
)
|
||||||
|
|
||||||
|
error() {
|
||||||
|
printf "\033[31m%s\033[0m\n" "$1"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
apireq() {
|
||||||
|
curl -k -H "Authorization: Bearer $EUMETSAT_API" "$URL/$1" "${@:2}"
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
. "$HOME/.fehbg"
|
||||||
Reference in New Issue
Block a user