- print $chapter_link->url(),qq(\n);
- my ($chapter) = $chapter_link->url() =~ m/(\d+)\/?$/;
- if (! -d "$manga/$chapter_link") {
- #mkdir("$manga/$chapter");
- my $page = 0;
- $m->get($chapter_link->url_abs());
- $m->follow_link(text_regex => qr{Begin reading});
- while ($m->uri() =~ m{\Q$chapter\E\/\d+/?$}) {
- $page++;
- 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+});
- $m->get($image->url_abs());
+ my ($chapter) = $chapter_link->url() =~ m/([\d.-]+)\/?$/;
+ my $chapter_long = $chapter =~ /\./ ? join('.',map {sprintf'%04d',$_} split /\./,$chapter) : sprintf('%04d',$chapter);
+ if (! -d "$manga/$chapter_long") {
+ print $chapter_link->url(),qq(\n);
+ mm_get($m,$chapter_link->url_abs());
+ my $link = $m->find_link(text_regex => qr{Begin [Rr]eading});
+ if (not defined $link) {
+ #print $m->content();
+ my $temp = $m->find_link(text_regex => qr{Read.*at.*1000manga\.com});
+ mm_get($m,$temp->url_abs());
+ #print $m->content();
+ $link = $m->find_link(text_regex => qr{Begin [Rr]eading});
+ }
+ mm_get($m,$link->url_abs());
+ # print $link->url_abs();
+ # print $m->content();
+ mkdir("$manga/$chapter_long");
+ while ($m->uri() =~ m{\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());