summaryrefslogtreecommitdiff
path: root/title.bash
diff options
context:
space:
mode:
Diffstat (limited to 'title.bash')
-rwxr-xr-xtitle.bash8
1 files changed, 7 insertions, 1 deletions
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="</title>" '/<title>/{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="</title>" '/<title>/{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