diff options
author | epoch <epoch@hack.thebackupbox.net> | 2020-10-04 05:41:55 +0000 |
---|---|---|
committer | epoch <epoch@hack.thebackupbox.net> | 2020-10-04 05:41:55 +0000 |
commit | 29ec2d6b6dccab65335be8bf203f0f139d876f97 (patch) | |
tree | 607d6503bba511b1013635df59ee1e7b66c3da48 | |
parent | 6005986e73e3fd1ef0b761d01ad37891ed4bff6e (diff) | |
download | uritools-29ec2d6b6dccab65335be8bf203f0f139d876f97.tar.gz uritools-29ec2d6b6dccab65335be8bf203f0f139d876f97.zip |
updated urititle from the combined of the version except.py used
-rwxr-xr-x | urititle | 44 |
1 files changed, 30 insertions, 14 deletions
@@ -16,22 +16,38 @@ fi if [ "$qs" ];then path="${path}?${qs}" fi +case "$scheme" in +http*) if [ "$port" ];then - UA="Mozilla/5.0 (impersonator)" + UA="Mozilla/5.0 (impersonator)" # content_type="$(printf "HEAD %s HTTP/1.1\r\nHost: %s\r\nUser-Agent: %s\r\n\r\n" "$path" "$domain" "$UA" | ncat -4 $SSL "$domain" "$port" | grep -i '^Content-Type: ' | head -n1 | cut '-d ' -f2 | cut '-d;' -f1 | tr -d '\r\n')" - a_header="$(curl -Lsi "$1" | egrep -ai '^Location: |^Content-Type: ' | head -n1 | tr -d '\r\n')" - if printf "%s\n" "${a_header}" | grep -i '^Content-Type: ' 2>&1 >/dev/null 2>&1;then - content_type="$(printf '%s\n' "${a_header}" | cut '-d ' -f2- | cut '-d;' -f1)" - else - content_type="redirect probably" + a_header="$(curl -Lsi "$1" | head -c 10000 | egrep -ai '^Location: |^Content-Type: ' | head -n1 | tr -d '\r\n')" + if printf "%s\n" "${a_header}" | grep -i '^Content-Type: ' 2>&1 >/dev/null 2>&1;then + content_type="$(printf '%s\n' "${a_header}" | cut '-d ' -f2- | cut '-d;' -f1)" + else + content_type="redirect probably" + fi + if [ "${content_type}" = "text/html" -o "${content_type}" = "application/xhtml+xml" ];then +# title="$(printf "GET %s HTTP/1.1\r\nHost: %s\r\nUser-Agent: %s\r\n\r\n" "$path" "$domain" "$UA" | ncat -4 $SSL "$domain" "$port" | head -c 10000 | tr -d '\n' | tr '<' '\n' | grep -A 10 '^title>' | grep -B 10 '^\/title>' | cut '-d>' -f2)" + title="$(curl -si "$1" | 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 .)" + printf "title: %s\n" "$title" | html_entities_decode + else + printf "%s\n" "${a_header}" + fi fi - if [ "${content_type}" = "text/html" -o "${content_type}" = "application/xhtml+xml" ];then -# title="$(printf "GET %s HTTP/1.1\r\nHost: %s\r\nUser-Agent: %s\r\n\r\n" "$path" "$domain" "$UA" | ncat -4 $SSL "$domain" "$port" | head -c 10000000 | tr -d '\n' | tr '<' '\n' | grep -A 10 '^title>' | grep -B 10 '^\/title>' | cut '-d>' -f2)" - title="$(curl -si "$1" | head -c 1000000 | tr -d '\n' | tr '<' '\n' | grep -iA 10 '^title' | grep -iB 10 '^\/title>' | cut '-d>' -f2 | sed 's/^ .//g' | sed 's/ .$//g' | grep .)" - printf "title: %s\n" "$title" | html_entities_decode - else - printf "%s\n" "${a_header}" + ;; +gemini) + printf "title: %s\n" "$(gemini-get "$1" | grep '^#' | head -n1 | sed 's/^#* *//g')" + ;; +magnet) + printf "title: %s\n" "$(printf "%s\n" "$1" | tr '&' '\n' | grep ^dn= | cut -d= -f2- | uriunescape)" + ;; +ssh) + if [ ! "$port" ];then + port=22 fi -else + printf "title: %s\n" "$(printf "" | nc "$domain" "$port" | head -n1)" + ;; +*) printf "DONT KNOW HOW TO GET TITLE FOR THIS URL: %s\n" "$1" -fi +esac |