=cut
+use URI::Escape;
use WWW::Mechanize;
use IO::Dir;
use IO::File;
my $m = WWW::Mechanize->new();
for my $manga (@manga_to_get) {
# see if the manga exists
- mm_get($options{onemanga}.'/'.$manga);
+ mm_get($m,$options{onemanga}.'/'.$manga);
if ($m->status() != 200) {
print STDERR "Manga $manga doesn't exist\n";
$failure ||= 1;
mkdir($manga);
}
# figure out where to start getting stuff
+ # we need to escape ! apparently; there are probably other characters as well
+ my $manga_escaped = uri_escape($manga,'!');
my @chapter_links = $m->find_all_links(url_abs_regex => qr{\Q$manga\E\/\d+});
for my $chapter_link (reverse @chapter_links) {
my ($chapter) = $chapter_link->url() =~ m/([\d.-]+)\/?$/;
my $link = $m->find_link(text_regex => qr{Begin reading});
mm_get($m,$link->url_abs());
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\d[^\/]*)});
+ my $image = $m->find_image(alt_regex => qr{Loading\.+\s+(media|img)});
+ my $next_link = $m->find_link(url_regex => qr{\Q$manga_escaped\E/\Q$chapter\E/(\d\d[^\/]*)});
mm_get($m,$image->url_abs());
print "getting ".$image->url_abs()."\n";
my ($page) = $image->url_abs =~ m/([^\/]+)$/;
$return = $m->get($url);
};
} while ($@ and
- $rerun-- > 0 and sleep 5);
+ ($rerun-- > 0) and sleep 5);
return $return;
}