linkhandler massively streamlined, posix sh
This commit is contained in:
parent
4ab18960b3
commit
4384979599
1 changed files with 13 additions and 26 deletions
|
@ -6,32 +6,19 @@
|
||||||
# if a music file or pdf, it will download,
|
# if a music file or pdf, it will download,
|
||||||
# otherwise it opens link in browser.
|
# otherwise it opens link in browser.
|
||||||
|
|
||||||
|
# Sci-Hub's domain occasionally changes due to shutdowns:
|
||||||
scihub="http://sci-hub.tw/"
|
scihub="http://sci-hub.tw/"
|
||||||
|
|
||||||
# List of sites that will be opened in mpv.
|
# setsid nohup
|
||||||
vidsites="youtube.com
|
|
||||||
\|hooktube.com
|
|
||||||
\|bitchute.com
|
|
||||||
"
|
|
||||||
|
|
||||||
# List of academic sites whose pdfs can be dled via sci-hub.
|
case "$1" in
|
||||||
academic="springer.com"
|
*mkv|*webm|*mp4|*gif|*youtube.com*|*hooktube.com*)
|
||||||
|
setsid mpv -quiet "$1" >/dev/null 2>&1 & ;;
|
||||||
ext="${1##*.}"
|
*png|*jpg|*jpe|*jpeg)
|
||||||
mpvFiles="mkv mp4 gif webm"
|
setsid feh "$1" >/dev/null 2>&1 & ;;
|
||||||
fehFiles="png jpg jpeg jpe"
|
*mp3|*flac|*opus|*mp3?source)
|
||||||
wgetFiles="mp3 flac opus mp3?source=feed pdf"
|
setsid tsp wget "$1" >/dev/null 2>&1 & ;;
|
||||||
|
*springer.com*)
|
||||||
if echo $fehFiles | grep -w $ext > /dev/null; then
|
setsid curl -sO "$(curl -s "$scihub$*" | grep -Po "(?<=location.href=').+.pdf")" >/dev/null 2>&1 & ;;
|
||||||
setsid nohup feh "$1" >/dev/null & disown
|
*) setsid "$BROWSER" "$1" >/dev/null 2>&1 & ;;
|
||||||
elif echo $mpvFiles | grep -w $ext > /dev/null; then
|
esac
|
||||||
setsid nohup mpv -quiet "$1" > /dev/null & disown
|
|
||||||
elif echo $wgetFiles | grep -w $ext > /dev/null; then
|
|
||||||
wget "$1" >/dev/null & disown
|
|
||||||
elif echo "$@" | grep "$vidsites">/dev/null; then
|
|
||||||
setsid nohup mpv -quiet "$1" > /dev/null & disown
|
|
||||||
elif echo "$@" | grep "$academic">/dev/null; then
|
|
||||||
curl -sO "$(curl -s "$scihub$*" | grep -Po "(?<=location.href=').+.pdf")" & disown
|
|
||||||
else
|
|
||||||
setsid nohup $BROWSER "$1" 2>/dev/null & disown
|
|
||||||
fi
|
|
||||||
|
|
Loading…
Reference in a new issue