Fixed up the link trigger so it actually works, I think.

This commit is contained in:
Storm Dragon 2020-08-09 20:55:19 -04:00
parent 96c4bf8c24
commit 306d9aa671

View File

@ -1,9 +1,13 @@
[ -f functions.sh ] && source functions.sh
curl="$(command -v curl) --connect-timeout 5"
for l in $3 ; do
if [[ "${l#:}" =~ http://|https://|www\.*\.* ]]; then
pageTitle="$($curl -Ls "${l#:}" | sed -n 's/<title>\(.*\)<\/title>/\1/p' | head -1 | html2text | tr -s '[:space:]' ' ')"
if [[ "${l}" =~ http://|https://|www\..* ]]; then
pageTitle="$(wget --quiet -O - "$l" | sed -n -e 'H;${x;s!.*<head[^>]*>\(.*\)</head>.*!\1!;T;s!.*<title>\(.*\)</title>.*!\1!p}')"
# Fix up pageTitle a bit.
pageTitle="${pageTitle//&#039;/\'}"
pageTitle="${pageTitle//&#8211;/-}"
shortLink="${l#*://}"
shortLink="${shortLink%%/*}"
if [ ${#pageTitle} -gt 1 ]; then