| t@@ -31,8 +31,8 @@ show_version() {
echo "https://gitlab.com/admesg/dotfiles"
}
-strip_doi() {
- sed 's/^(http:\/\/|https:\/\/)?(dx\.)?(doi\.org\/)//'
+regexmatch() {
+ printf '%s' "$1" | grep -qE "$2"
}
browser_open() {
t@@ -79,6 +79,13 @@ shdl_fetch() {
}
handle_doi() {
+ # direct download of The Cryosphere pdfs
+ if regexmatch "$1" '10.5194/tc-'; then
+ year="$(printf '%s' "$1" | sed 's/.*-\([12][0-9][0-9][0-9]\)$/\1/')"
+ volume="$(printf '%s' "$1" | sed 's,.*/tc-\([0-9][0-9]*\)-.*,\1,')"
+ page="$(printf '%s' "$1" | sed 's,.*/tc-[0-9][0-9]*-\([0-9][0-9]*\).*,\1,')"
+ curl -O "https://tc.copernicus.org/articles/${volume}/${page}/${year}/tc-${volume}-${page}-${year}.pdf"
+ fi
if [ "$browser" = 1 ]; then
shurl="$shhost/$1"
browser_open "$shurl" |