]> git.donarmstrong.com Git - bin.git/blobdiff - get_one_manga
add mutt alias which executes neomutt if that exists
[bin.git] / get_one_manga
index 6336726bff3ef6c493068899993be5325d991267..8e9e8cc0fea7f4182976cc9c5c6669c73f7bbe02 100755 (executable)
@@ -51,6 +51,7 @@ Display this manual.
 
 use URI::Escape;
 use WWW::Mechanize;
+use HTTP::Cookies;
 use IO::Dir;
 use IO::File;
 use vars qw($DEBUG);
@@ -91,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);
@@ -111,10 +116,19 @@ for my $manga (@manga_to_get) {
        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|img)});
                my $next_link = $m->find_link(url_regex => qr{\Q$manga_escaped\E/\Q$chapter\E/(\d\d[^\/]*)});