2020-07-04 14:23:27 +02:00
|
|
|
#!/bin/sh
|
2021-07-14 21:43:39 +02:00
|
|
|
meteobluelink="https://www.meteoblue.com/en/weather/forecast/multimodel/zurich_switzerland_2657896"
|
|
|
|
multimodel_path="$XDG_DATA_HOME/$(date +%s)_multimodel.png"
|
2020-07-04 14:23:27 +02:00
|
|
|
|
2021-07-14 21:43:39 +02:00
|
|
|
last_downloaded_path="$(for file in "$XDG_DATA_HOME"/*_multimodel.png; do
|
|
|
|
echo "$file"
|
|
|
|
done | head -n1)"
|
|
|
|
last_downloaded="$(echo "${last_downloaded_path%_multimodel.png}" | awk 'BEGIN{FS="/"} {print $NF}')"
|
|
|
|
if [ "$last_downloaded" = "*" ]; then
|
|
|
|
FLAG_download=true
|
|
|
|
else
|
|
|
|
day_last_downloaded="$( date -d @"$last_downloaded" -I)"
|
|
|
|
if [ "$(date -I)" != "$day_last_downloaded" ]; then
|
|
|
|
echo "Last report is from another day, downloading for today..."
|
|
|
|
rm "$XDG_DATA_HOME"/*_multimodel.png
|
|
|
|
FLAG_download=true
|
|
|
|
else
|
|
|
|
FLAG_download=false
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ $FLAG_download = 'true' ]; then
|
|
|
|
mb_imagelink="$(lynx --dump --listonly --nonumbers "$meteobluelink" | grep meteogram_multiSimple_hd)"
|
|
|
|
curl -L "$mb_imagelink" -o "$multimodel_path"
|
|
|
|
else
|
|
|
|
echo "currently downloaded multimodel is from today, showing cached version"
|
2020-07-04 14:23:27 +02:00
|
|
|
fi
|
2021-07-14 21:43:39 +02:00
|
|
|
sxiv "$XDG_DATA_HOME"/*_multimodel.png
|