if (not @ARGV) {
my $d = IO::Dir->new('.') or die "Unable to open directory . for reading";
while (defined($_ = $d->read)) {
- next if /^./;
+ next if /^\./;
next unless -d $_;
push @manga_to_get,$_;
}
next;
}
if (! -d $manga) {
- #mkdir($manga);
+ mkdir($manga);
}
# figure out where to start getting stuff
my @chapter_links = $m->find_all_links(url_abs_regex => qr{\Q$manga\E\/\d+});
for my $chapter_link (reverse @chapter_links) {
print $chapter_link->url(),qq(\n);
- my ($chapter) = $chapter_link->url() =~ m/(\d+)\/?$/;
- if (! -d "$manga/$chapter_link") {
- #mkdir("$manga/$chapter");
- my $page = 0;
+ my ($chapter) = $chapter_link->url() =~ m/([\d-]+)\/?$/;
+ my $chapter_long = sprintf('%04d',$chapter);
+ if (! -d "$manga/$chapter_long") {
+ mkdir("$manga/$chapter_long");
$m->get($chapter_link->url_abs());
$m->follow_link(text_regex => qr{Begin reading});
- while ($m->uri() =~ m{\Q$chapter\E\/\d+/?$}) {
- $page++;
+ while ($m->uri() =~ m{\Q$chapter\E/(\d\d[^\/]*)/?$}) {
my $image = $m->find_image(alt_regex => qr{Loading\.+\s+media});
- my $next_link = $m->find_link(url_regex => qr{\Q$manga\E/\Q$chapter\E/\d+});
+ my $next_link = $m->find_link(url_regex => qr{\Q$manga\E/\Q$chapter\E/(\d\d[^\/]*)});
$m->get($image->url_abs());
print "getting ".$image->url_abs()."\n";
- # $m->save_content("$manga/$chapter/".sprintf('%04d',$page).".jpg");
+ my ($page) = $image->url_abs =~ m/([^\/]+)$/;
+ $m->save_content("$manga/$chapter_long/$page");
+ last if not defined $next_link;
$m->get($next_link->url_abs());
- print $m->uri();
+ print $m->uri()."\n";
sleep 3;
}
- exit 0;
}
}
}