X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=get_one_manga;h=8e9e8cc0fea7f4182976cc9c5c6669c73f7bbe02;hb=dcce90e77c92202b5fadca48de6fd1cefc41ff79;hp=cc0cbd04fa6a981e14ca6e77694625ef02d9ad48;hpb=3cba1dd3f0ba799b128a064cf4cad5ffd62b189d;p=bin.git diff --git a/get_one_manga b/get_one_manga index cc0cbd0..8e9e8cc 100755 --- a/get_one_manga +++ b/get_one_manga @@ -49,7 +49,9 @@ Display this manual. =cut +use URI::Escape; use WWW::Mechanize; +use HTTP::Cookies; use IO::Dir; use IO::File; use vars qw($DEBUG); @@ -90,6 +92,10 @@ if (not @ARGV) { my $failure = 0; my $m = WWW::Mechanize->new(); +$m->cookie_jar(HTTP::Cookies->new()); +$m->cookie_jar()->set_cookie(1,'age_verified','42','/','www.1000manga.com'); +# use Data::Dumper; +# print STDERR Dumper($m->cookie_jar()); for my $manga (@manga_to_get) { # see if the manga exists mm_get($m,$options{onemanga}.'/'.$manga); @@ -102,19 +108,30 @@ for my $manga (@manga_to_get) { 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 $chapter_long = $chapter =~ /\./ ? join('.',map {sprintf'%04d',$_} split /\./,$chapter) : sprintf('%04d',$chapter); if (! -d "$manga/$chapter_long") { print $chapter_link->url(),qq(\n); - mkdir("$manga/$chapter_long"); mm_get($m,$chapter_link->url_abs()); - my $link = $m->find_link(text_regex => qr{Begin reading}); + 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}); - 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/([^\/]+)$/;