diff options
| author | Luke Smith <luke@lukesmith.xyz> | 2018-09-15 20:04:47 -0400 |
|---|---|---|
| committer | Luke Smith <luke@lukesmith.xyz> | 2018-09-15 20:04:47 -0400 |
| commit | 43849795993ef6074746556818be548b61faf1df (patch) | |
| tree | 8f1d2146559611ec0c04333a48bc19ac2c1066ba /.scripts | |
| parent | 4ab18960b338ab47a139a327efd112e973f75573 (diff) | |
| download | eibhear-43849795993ef6074746556818be548b61faf1df.tar.gz eibhear-43849795993ef6074746556818be548b61faf1df.tar.zst eibhear-43849795993ef6074746556818be548b61faf1df.zip | |
linkhandler massively streamlined, posix sh
Diffstat (limited to '.scripts')
| -rwxr-xr-x | .scripts/linkhandler | 39 |
1 files changed, 13 insertions, 26 deletions
diff --git a/.scripts/linkhandler b/.scripts/linkhandler index f540dc0..79e1e29 100755 --- a/.scripts/linkhandler +++ b/.scripts/linkhandler @@ -6,32 +6,19 @@ # if a music file or pdf, it will download, # otherwise it opens link in browser. +# Sci-Hub's domain occasionally changes due to shutdowns: scihub="http://sci-hub.tw/" -# List of sites that will be opened in mpv. -vidsites="youtube.com - \|hooktube.com - \|bitchute.com - " +# setsid nohup -# List of academic sites whose pdfs can be dled via sci-hub. -academic="springer.com" - -ext="${1##*.}" -mpvFiles="mkv mp4 gif webm" -fehFiles="png jpg jpeg jpe" -wgetFiles="mp3 flac opus mp3?source=feed pdf" - -if echo $fehFiles | grep -w $ext > /dev/null; then - setsid nohup feh "$1" >/dev/null & disown -elif echo $mpvFiles | grep -w $ext > /dev/null; then - 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 +case "$1" in + *mkv|*webm|*mp4|*gif|*youtube.com*|*hooktube.com*) + setsid mpv -quiet "$1" >/dev/null 2>&1 & ;; + *png|*jpg|*jpe|*jpeg) + setsid feh "$1" >/dev/null 2>&1 & ;; + *mp3|*flac|*opus|*mp3?source) + setsid tsp wget "$1" >/dev/null 2>&1 & ;; + *springer.com*) + setsid curl -sO "$(curl -s "$scihub$*" | grep -Po "(?<=location.href=').+.pdf")" >/dev/null 2>&1 & ;; + *) setsid "$BROWSER" "$1" >/dev/null 2>&1 & ;; +esac |
