From abdfebe38ab1334298cc8dd22e77c2a74123aabc Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Sat, 28 Jul 2018 10:54:46 -0400 Subject: [PATCH] sci-hub handler added for academic sites --- .scripts/linkhandler | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.scripts/linkhandler b/.scripts/linkhandler index 20b1bd3..94fdd83 100755 --- a/.scripts/linkhandler +++ b/.scripts/linkhandler @@ -6,11 +6,17 @@ # if a music file or pdf, it will download, # otherwise it opens link in browser. +scihub="http://sci-hub.tw/" + # List of sites that will be opened in mpv. vidsites="youtube.com \|hooktube.com \|bitchute.com " + +# 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" @@ -24,6 +30,8 @@ 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 location.href | grep -o http.*pdf) & disown else setsid nohup $BROWSER "$1" 2>/dev/null & disown fi