+if (-r "$ENV{HOME}/.get_sgf") {
+ my $sgf_fh = IO::File->new("$ENV{HOME}/.get_sgf") or
+ die "Unable to open .get_sgf for reading";
+ local $/;
+ my $sgf_file = <$sgf_fh>;
+ ($options{username},$options{password}) = $sgf_file =~ /^(\w+)\:(\w+)$/;
+ close $sgf_fh;
+}
+
+my $olddir = getcwd();
+
+#my $tmpdir = tempdir(CLEANUP=>1);
+#chdir($tmpdir);
+
+# /games/japan/titles/kisei/31/game-01.sgf
+
+
+my $m = WWW::Mechanize->new();
+$m->credentials($options{username},$options{password});
+my $base = 'http://gobase.org/online/sgf2misc/?fname=/games/japan/titles/kisei/31/game-01.sgf';
+for my $url (@ARGV) {
+ # strip of leading stuff
+ $url =~ s/[^=]+=//;
+ my $fname = $url;
+ my $uri = URI->new($base);
+ $uri->query_form(mode => $options{mode},
+ fname => $fname,
+ );
+ $m->get("http://gobase.org$fname");
+ $m->save_content('temp.sgf');
+ $m->get($uri->as_string);
+ $m->form_number(2);
+ $m->select('scale',$options{scale});
+ $m->field('fig',$options{figures});
+ $m->select('paper',$options{paper});
+ $m->submit();
+ $m->follow_link(url_regex=>qr/\.ps\.gz/);
+ $m->save_content('temp.ps.gz');
+ system("$ENV{HOME}/bin/sgf_rename",'temp.sgf');
+}