home/wm: ignore curl errors

This commit is contained in:
Dmitriy Pleshevskiy 2023-06-15 10:48:00 +03:00
parent 1b318bc4cf
commit b28fc78cfd
Signed by: pleshevskiy
GPG key ID: 79C4487B44403985

View file

@ -2,12 +2,14 @@
set -e set -e
curl_opts=(--silent --connect-timeout 1 --no-progress-meter -X GET)
curl_cbr () { curl_cbr () {
local today=$(date +%d/%m/%Y) local today=$(date +%d/%m/%Y)
local start_range=$(date +%d/%m/%Y -d '-14 day') local start_range=$(date +%d/%m/%Y -d '-14 day')
local usd=R01235 local usd=R01235
curl --no-progress-meter "https://www.cbr.ru/scripts/XML_dynamic.asp?date_req1=$start_range&date_req2=$today&VAL_NM_RQ=$usd" | \ curl ${curl_opts[@]} "https://www.cbr.ru/scripts/XML_dynamic.asp?date_req1=$start_range&date_req2=$today&VAL_NM_RQ=$usd" | \
sed -e "s/<[A-Z]/\n\0/g" | \ sed -e "s/<[A-Z]/\n\0/g" | \
grep Value | \ grep Value | \
sed -e "s#<\/\?\w\+>##g" | \ sed -e "s#<\/\?\w\+>##g" | \
@ -18,7 +20,7 @@ curl_exchangerate () {
local start_date=$(date +%Y-%m-%d -d '-1 day') local start_date=$(date +%Y-%m-%d -d '-1 day')
local end_date=$(date +%Y-%m-%d) local end_date=$(date +%Y-%m-%d)
curl --no-progress-meter -X GET "https://api.exchangerate.host/timeseries?start_date=$start_date&end_date=$end_date&base=USD&symbols=RUB&places=4&format=xml" | \ curl ${curl_opts[@]} "https://api.exchangerate.host/timeseries?start_date=$start_date&end_date=$end_date&base=USD&symbols=RUB&places=4&format=xml" | \
sed -e "s/<[a-z]/\n\0/g" | \ sed -e "s/<[a-z]/\n\0/g" | \
grep rate | \ grep rate | \
sed -e "s#<\/\?\w\+>##g" sed -e "s#<\/\?\w\+>##g"