From dc3c282e6c89f867e1d23ad702d3ab1703482ed0 Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Tue, 20 Oct 2015 13:25:19 +0100 Subject: If Content-Type is text/plain, just use the first line as the title --- title.bash | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/title.bash b/title.bash index 7b917ac..4a83aa7 100755 --- a/title.bash +++ b/title.bash @@ -39,6 +39,12 @@ then else eval curl $OPTS -D /tmp/$TIME.header '$url' -o /tmp/$TIME.body.gz grep -q "Content-Encoding: gzip" /tmp/$TIME.header && gunzip /tmp/$TIME.body.gz || mv /tmp/$TIME.body.gz /tmp/$TIME.body - awk -vRS="" '//{gsub(/.*<title>|\n+/,"");print;exit}' IGNORECASE=1 /tmp/$TIME.body | sed ':a;N;$!ba;s/\n//g' | sed -e 's/^[ \t]*//' + grep -q "Content-Type: text/plain" /tmp/$TIME.header && TYPE="text/plain" + if [ "$TYPE" == "text/plain" ] + then + head -n1 /tmp/$TIME.body + else + awk -vRS="" '//{gsub(/.*<title>|\n+/,"");print;exit}' IGNORECASE=1 /tmp/$TIME.body | sed ':a;N;$!ba;s/\n//g' | sed -e 's/^[ \t]*//' + fi rm /tmp/$TIME.header /tmp/$TIME.body fi -- cgit v1.2.3