From f0a9406b2fb0a72b4b4d55dcd306bf4a45b66075 Mon Sep 17 00:00:00 2001 From: Don Armstrong Date: Tue, 12 Mar 2013 16:00:36 -0700 Subject: [PATCH 1/1] add use-links option to avoid using links if we want a fully automated download --- get_pdf | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/get_pdf b/get_pdf index 4a3f76b..2aa8416 100755 --- a/get_pdf +++ b/get_pdf @@ -65,12 +65,14 @@ use WWW::Mechanize; my %options = (debug => 0, help => 0, man => 0, + use_links => 1, ); my %REFERENCE_TYPES = (pmid => 'pmid|p'); GetOptions(\%options, values %REFERENCE_TYPES, + 'use_links|use-links!', 'cgi_proxy|cgi-proxy|C=s', 'http_proxy|http-proxy|H=s', 'debug|d+','help|h|?','man|m'); @@ -152,13 +154,15 @@ if ($options{pmid}) { }; if ($@) { print STDERR "$@\n" if $DEBUG; - system('links2', - # links2 doesn't like the leading http:// of proxies for some reason - exists $options{http_proxy}?('-http-proxy',(map {s{http://}{}; $_} $options{http_proxy})):(), - $url - ) == 0 or next; - rename('temp.pdf',"${pmid}.pdf") if -e 'temp.pdf'; - } + if ($options{use_links}) { + system('links2', + # links2 doesn't like the leading http:// of proxies for some reason + exists $options{http_proxy}?('-http-proxy',(map {s{http://}{}; $_} $options{http_proxy})):(), + $url + ) == 0 or next; + rename('temp.pdf',"${pmid}.pdf") if -e 'temp.pdf'; + } + } } } -- 2.39.2