detect titles in page and prepare them for bookmarks

This commit is contained in:
Morgan Wattiez 2019-10-13 12:00:14 +02:00
parent 64c7775fda
commit fd746a7dc9

View File

@ -84,16 +84,24 @@ function aboutpage() {
year=$(curl -sSL "$*" | tr '<' '\r' | \egrep -i "date|datetime" -A 1 | \grep -Eo '\b[[:digit:]]{4}\b' | head -n1) year=$(curl -sSL "$*" | tr '<' '\r' | \egrep -i "date|datetime" -A 1 | \grep -Eo '\b[[:digit:]]{4}\b' | head -n1)
fi fi
author=$(curl -sSL "$*" | tr '<' '\r' | \egrep -i "author" -A 1 | \grep -Eo '([A-Z][A-Za-z]+\s([A-Za-z ]+)*)' | head -n1) author=$(curl -sSL "$*" | tr '<' '\r' | \egrep -i "author" -A 1 | \grep -Eo '([A-Z][A-Za-z]+\s([A-Za-z ]+)*)' | head -n1)
title=$(curl -sSL "$*" | tr '<' '<\n' | \grep title -A 1 | head -n1 | sed -E 's/.*<title>(.*)<\/title>.*/\1/' | sed "s/ [^[:alnum:]]*$author//")
yearint=$(($year + 0)) yearint=$(($year + 0))
currentyear=$(echo `date +"%Y"`) currentyear=$(echo `date +"%Y"`)
if [ ! -z "$author" ] if [ ! -z "$author" ]
then then
echo "by $author" echo "by $author"
fi fi
if [ ! -z "$title" ]
then
echo "-> $title"
fi
if [[ $yearint -ge 1970 && $yearint -le $currentyear ]] if [[ $yearint -ge 1970 && $yearint -le $currentyear ]]
then then
echo "$yearint" echo "$yearint"
fi fi
if [ ! -z "$title" ] && [ ! -z "$author" ] && [[ $yearint -ge 1970 && $yearint -le $currentyear ]]; then
echo "[$author]($*) - ($yearint) $title"
fi
} }
# Extract a column from a tabular output # Extract a column from a tabular output