google expects a valid user agent to deliver the ics file
Added test if downloaded file is a ics file
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
local icsconf_url="https://somethi.ng"
|
||||
local icsconf_output="${HOME}/my.ics"
|
||||
local icsconf_useragent="Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/110.0"
|
||||
|
||||
# icsError
|
||||
# Called if the download from ${icsconf_url} failed
|
||||
|
@@ -77,13 +77,18 @@ icscheck() {
|
||||
|
||||
mkdir -p "${ics_temp_dir}" "${ics_store_dir}"
|
||||
|
||||
wget -O "$ics_down_file" "$ics_url" >/dev/null 2>&1
|
||||
curl -L "${ics_url}" -H "User-Agent: ${icsconf_useragent:?}" -o "${ics_down_file}" >/dev/null 2>&1
|
||||
|
||||
# -s : exists and size greater zero
|
||||
if [ ! -s "$ics_down_file" ] || [ ! -r "$ics_down_file" ]; then
|
||||
icsError
|
||||
exit 1
|
||||
fi
|
||||
# check if ics file has VEVENTs
|
||||
if ! grep -qE "(BEGIN:|END:)VEVENT" "${ics_down_file}"; then
|
||||
icsError
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Delete storage if manual renew is requested
|
||||
(( renew )) && rm -f "${ics_store_file}"
|
||||
|
Reference in New Issue
Block a user