forked from wesleyd/pipermail-archive-to-maildir
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlist-pipermail-files
executable file
·47 lines (38 loc) · 1.04 KB
/
list-pipermail-files
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
#!/usr/bin/env perl
#
# Given a pipermail archive URL, parse it and return a list of the files it
# refers to...
#
# Copyright (c) Wesley Darlington, 2010.
use warnings;
use strict;
use LWP::Simple;
sub usage() { # And die!
die "Usage: $0 <http://host/pipermail/listname/>\n"
. " Parse the pipermail directory, return its archives\n";
}
# TODO: parse command line args a bit better...
my %ARGV; @ARGV{@ARGV} = @ARGV;
usage if exists $ARGV{"-h"};
usage if exists $ARGV{"--help"};
my $base_url = shift;
usage unless defined $base_url;
my $content = get($base_url);
if (!defined $content) {
die "Error fetching '$base_url' with LWP::get.\n";
}
my @lines = split /\n/, $content;
my @files;
foreach my $line (@lines) {
next unless $line =~ m{Text};
if ($line =~ m{<td><A href="(.*)">\[ (Gzip'd )?Text.*\]</a></td>}) {
push @files, $1;
} else {
my $line2 = $line;
chomp $line2;
print STDERR "Didn't find a match in: '$line2'\n";
}
}
foreach my $file (@files) {
print "$base_url/$file\n";
}