Add support for bpa.st and spunge.us to readwwwlog
This commit is contained in:
parent
23ad6625ba
commit
7b35fb38c9
@ -25,25 +25,46 @@ for url in ${urls}; do
|
||||
elif [[ ${url} =~ 'irccloud\.com' && ! ${url} =~ '/raw/' ]]; then
|
||||
local id=${${(@s:/:)url}[4]}
|
||||
url="https://www.irccloud.com/pastebin/raw/${id}"
|
||||
elif [[ ${url} =~ 'bpa\.st' && ! ${url} =~ '/download-archive/' ]]; then
|
||||
local id=${url##*/}
|
||||
url="https://bpa.st/download-archive/${id}"
|
||||
fi
|
||||
|
||||
if [[ ${TERMINAL} =~ "alacritty|xfce4-terminal" ]]; then
|
||||
termopts="--title=${url}"
|
||||
fi
|
||||
|
||||
if curl --silent --location --head ${url} | grep -q 'text/plain'; then
|
||||
sleep 1 # dpaste.com workaround
|
||||
local file="$(mktemp --suffix='.readwwwlog')"
|
||||
curl --silent --location --output ${file} ${url}
|
||||
local curl="$(curl --silent --location --head ${url})"
|
||||
local -a headers=(${(ps:\r\n:)curl})
|
||||
local file="$(mktemp --suffix='.readwwwlog')"
|
||||
local -a cmd=(less +1 --LINE-NUMBERS --ignore-case \
|
||||
--pattern='(error|fail):')
|
||||
if [[ -o NO_INTERACTIVE ]]; then
|
||||
cmd=(${TERMINAL} ${termopts} -e ${cmd})
|
||||
fi
|
||||
|
||||
local -a cmd=(less +1 --LINE-NUMBERS --ignore-case \
|
||||
--pattern='(error|fail):' ${file})
|
||||
if [[ -o NO_INTERACTIVE ]]; then
|
||||
cmd=(${TERMINAL} ${termopts} -e ${cmd})
|
||||
fi
|
||||
${cmd}
|
||||
if [[ ${headers[(I)*text/plain]} -ne 0 ]] || \
|
||||
[[ ${headers[(I)*HTTP/1.1 405*]} -ne 0 ]]; then # No HEAD allowed
|
||||
sleep 1 # dpaste.com workaround
|
||||
curl --silent --location --output ${file} ${url}
|
||||
${cmd} ${file}
|
||||
|
||||
rm ${file}
|
||||
elif [[ ${headers[(I)*application/zip]} -ne 0 ]]; then
|
||||
rm ${file}
|
||||
local dir=${file}
|
||||
mkdir ${dir}
|
||||
file=${dir}/archive.zip
|
||||
|
||||
curl --silent --location --output ${file} ${url}
|
||||
unzip -qd ${dir} ${file}
|
||||
for txt in ${dir}/*; do
|
||||
if [[ ${txt} != "${dir}/archive.zip" ]]; then
|
||||
${cmd} ${txt}
|
||||
fi
|
||||
done
|
||||
|
||||
rm -r ${dir}
|
||||
else
|
||||
${default_cmd} ${url}
|
||||
fi
|
||||
|
@ -29,6 +29,8 @@ local -A assignments=(
|
||||
'^(gemini|gopher)://' "kristall"
|
||||
'\.(log|txt)$' "readwwwlog"
|
||||
'^https?://(www\.)?(dpaste|pastebin|irccloud)\.com/' "readwwwlog"
|
||||
'^https?://bpa\.st/' "readwwwlog"
|
||||
'^https?://sprunge\.us/' "readwwwlog"
|
||||
'\.(webm|png|jpe?g|gif|svg|bmp|xcf)(\?.+)?$' "openwwwimg"
|
||||
'(^magnet:|\.torrent$)' "transmission-remote-gtk"
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user