3 # this script downloads log files from colabti.de.
10 #use LWP::UserAgent::Cached; # Debug purpose
12 my ($all, $help, $channel);
14 'channel=s' => \
$channel,
19 my $out_dir = shift || '.';
26 mkdir $out_dir if !-e
$out_dir;
30 my @existing_files = sort glob "$out_dir/*.log";
31 $last_log = pop @existing_files;
37 my $ua = LWP
::UserAgent
->new;
38 #my $ua = LWP::UserAgent::Cached->new; # Debug purpose
41 my $base_url = "http://colabti.de/irclogger/irclogger_logs";
42 warn " info: getting $base_url/$channel...\n";
43 my $res = $ua->get("$base_url/$channel");
45 if ($res->is_success) {
46 my %links = extract_links
($res->content);
47 while (my ($name, $url) = each %links) {
48 my $local_file = "$out_dir/$name";
49 if (!$all and -e
$local_file and index($last_log, $name) == -1) {
50 warn " $local_file already exists, skipped.\n";
53 warn "generating $local_file...\n";
54 $ua->mirror("http://colabti.de/$url", $local_file);
59 die $res->status_line;
70 --channel
<name
> Specify the IRC channel
. Defaults to
#perl6.
71 --all Download very
log file even
if there
's one in out-dir.
72 --help Show this help.
81 m{"/irclogger/irclogger_log/$channel\?date=(\d+-\d+-\d+),\w+;raw=on"}g) {
82 my ($name, $url) = ("$channel-$1.log", $&);