summaryrefslogtreecommitdiff
path: root/urititle
diff options
context:
space:
mode:
authorepoch <epoch@hack.thebackupbox.net>2020-10-19 01:48:04 +0000
committerepoch <epoch@hack.thebackupbox.net>2020-10-19 01:48:04 +0000
commit82f7fe701000a5de6c753ef572621dad51e1eace (patch)
tree2b5ae56352d4758955fc5941b8b0436453cb306f /urititle
parent840a373b74a8202801126af195177b9964e8377a (diff)
downloaduritools-82f7fe701000a5de6c753ef572621dad51e1eace.tar.gz
uritools-82f7fe701000a5de6c753ef572621dad51e1eace.zip
added html over gemini title support
Diffstat (limited to 'urititle')
-rwxr-xr-xurititle9
1 files changed, 7 insertions, 2 deletions
diff --git a/urititle b/urititle
index 7b159da..85f3259 100755
--- a/urititle
+++ b/urititle
@@ -45,8 +45,13 @@ gemini)
gemini-get "$1" | while read -r line;do
if [ "$first" ];then
unset first
- if ! printf "%s\n" "$line" | grep '^[^ ]* text/gemini' 2>&1 >/dev/null;then
- printf "title: %s\n" "$(printf "%s\n" "$line" | tr '\t' ' ' | tr -s ' ' | cut '-d ' -f2-)"
+ type="$(printf "%s\n" "$line" | tr -s ' ' | cut '-d ' -f2 | tr -d '\r')"
+ if [ "$type" != 'text/gemini' ];then
+ if [ "$type" = "text/html" ];then
+ head -c 1000000 | tr -d '\n' | tr '<' '\n' | grep -iA 10 '^title' | grep -iB 10 '^\/title>' | cut '-d>' -f2 | tr '\t' ' ' | sed 's/^ *//g' | sed 's/ *$//g' | grep .
+ else
+ printf "title: %s\n" "$(printf "%s\n" "$line" | tr '\t' ' ' | tr -s ' ' | cut '-d ' -f2-)"
+ fi
fi
else
printf "title: %s\n" "$(printf "%s\n" "$line" | grep '^#' | sed 's/^#* *//g')"