tDirectly download pdfs from The Cryosphere - scholarref - tools for DOI and BiBTeX reference extraction, fetching, and parsing
 (HTM) git clone git://src.adamsgaard.dk/scholarref
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 62fa6286f3333be87b6e2b89c92d83504e60a076
 (DIR) parent 344cb74ecf5cb2e2b5f25f25e8d303143b1371f4
 (HTM) Author: Anders Damsgaard <anders@adamsgaard.dk>
       Date:   Mon,  6 Jul 2020 10:47:05 +0200
       
       Directly download pdfs from The Cryosphere
       
       Diffstat:
         M shdl                                |      11 +++++++++--
       
       1 file changed, 9 insertions(+), 2 deletions(-)
       ---
 (DIR) diff --git a/shdl b/shdl
       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"