]> git.donarmstrong.com Git - bin.git/blobdiff - get_sgf
add mutt alias which executes neomutt if that exists
[bin.git] / get_sgf
diff --git a/get_sgf b/get_sgf
index 973550d98fcc7312fd68a057e0b1204625c9fd38..f978b81ed5c4a1321158bb88df40a98b58e37ab1 100755 (executable)
--- a/get_sgf
+++ b/get_sgf
@@ -123,6 +123,7 @@ for my $url (@ARGV) {
      $m->get("http://gobase.org$fname");
      $m->save_content('temp.sgf');
      $m->get($uri->as_string);
+     $m->follow_link(text_regex=>qr/PostScript/);
      $m->form_number(2);
      $m->select('scale',$options{scale});
      $m->field('fig',$options{figures});
@@ -130,6 +131,7 @@ for my $url (@ARGV) {
      $m->submit();
      my $content;
      my $state;
+     my $sleep;
  VALID_LOOP: {
          do {
               $state = $m->clone;
@@ -138,8 +140,10 @@ for my $url (@ARGV) {
                    $m->save_content('temp.ps');
                    last VALID_LOOP;
               }
+              $sleep = 240+int(rand()*120);
+              print STDERR "Failure to download content, waiting $sleep seconds\n";
               $m = $state;
-         } while (sleep 30);
+         } while (sleep $sleep);
      }
      system('gzip','temp.ps');
      system("$ENV{HOME}/bin/sgf_rename",'temp.sgf');