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:
2023-02-21 22:53:12 +01:00
parent 331aa8e253
commit fbd1b543eb
2 changed files with 7 additions and 1 deletions

View File

@@ -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}"