-
Notifications
You must be signed in to change notification settings - Fork 0
/
getIAFiles.pl
58 lines (44 loc) · 1.18 KB
/
getIAFiles.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/perl -w
use strict;
use FileHandle;
use LWP::Simple;
use Switch;
main();
#-----------------------------------------------------------------------------
sub main
{
showUsage()
if scalar(@ARGV) != 2;
my ($ids, $type) = @ARGV;
my $inputFH = new FileHandle;
$inputFH->open($ids);
while(not($inputFH->eof)) {
my $id = $inputFH->getline;
chomp $id;
my $ext;
switch ($type) {
case 'abbyy' { $ext = '_abbyy.gz' }
case 'pdf' { $ext = '.pdf' }
case 'orig' { $ext = '_orig_jp2.tar' }
case 'jp2' { $ext = '_jp2.zip' }
}
my $url = 'https://archive.org/download/' . $id . '/' . $id . $ext;
my $file = $id . $ext;
my $status = getstore($url, $file);
if (is_error($status)) {
print "ERROR $status while fetching $url\n";
}
}
}
#-----------------------------------------------------------------------------
sub showUsage
{
print "\nUsage:\n\n";
print "getIAFiles.pl ids filetype\n\n";
print "Where\nids is file containing IA ids\n\nfiletype can be
ABBYY Full text -> abbyy
Single PDF -> pdf
Single Page Original JP2 -> orig
Single Page Cropped JP2 -> jp2\n";
exit 1;
}